@aztec/p2p 0.0.1-commit.96dac018d → 0.0.1-commit.993d240
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 +7 -7
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +34 -16
- package/dest/client/interface.d.ts +17 -8
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +15 -11
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +93 -49
- package/dest/config.d.ts +153 -102
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +134 -35
- 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 +99 -59
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +267 -197
- 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 +181 -65
- 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 +4 -2
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +33 -15
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +2 -0
- 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/interfaces.d.ts +7 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +8 -6
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +12 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +44 -12
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +81 -22
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -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 +26 -44
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +4 -2
- 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 +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +2 -1
- 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 +133 -110
- 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 +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/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 +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.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/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 +27 -7
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +47 -17
- 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 +48 -7
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +88 -41
- package/dest/msg_validators/tx_validator/index.d.ts +4 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +3 -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/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/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 +11 -15
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +12 -16
- package/dest/services/encoding.d.ts +6 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +14 -8
- package/dest/services/gossipsub/topic_score_params.d.ts +13 -2
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +21 -4
- 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 +39 -50
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +299 -250
- 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 +32 -10
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -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 +84 -71
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +10 -6
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +5 -4
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +13 -7
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +3 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +3 -0
- 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/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 +4 -2
- 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 +43 -215
- package/dest/services/service.d.ts +9 -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/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 +36 -55
- 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 +9 -7
- 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 +5 -6
- 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 +24 -11
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +45 -45
- 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 +17 -19
- 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 +12 -14
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +42 -15
- 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 +88 -42
- 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 +12 -7
- 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 +65 -21
- package/src/client/interface.ts +18 -20
- package/src/client/p2p_client.ts +108 -82
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +226 -36
- 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 +318 -242
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +204 -68
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +22 -14
- package/src/mem_pools/tx_pool_v2/README.md +9 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +3 -0
- 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/interfaces.ts +11 -1
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +15 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +12 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +121 -27
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +29 -43
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +16 -1
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +141 -114
- 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 +14 -7
- 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 +15 -3
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
- 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/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 +61 -10
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +121 -39
- package/src/msg_validators/tx_validator/index.ts +3 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- 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 +14 -39
- package/src/services/encoding.ts +14 -7
- package/src/services/gossipsub/topic_score_params.ts +36 -4
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +326 -287
- 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 +27 -5
- package/src/services/reqresp/README.md +215 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +83 -77
- package/src/services/reqresp/batch-tx-requester/interface.ts +13 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +13 -6
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +5 -0
- 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/block_txs_handler.ts +4 -2
- 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 +48 -261
- package/src/services/service.ts +12 -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/request_tracker.ts +127 -0
- package/src/services/tx_collection/tx_collection.ts +331 -176
- package/src/services/tx_collection/tx_collection_sink.ts +2 -2
- package/src/services/tx_collection/tx_source.ts +8 -7
- 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 +4 -3
- package/src/test-helpers/mock-pubsub.ts +49 -66
- package/src/test-helpers/reqresp-nodes.ts +15 -28
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +53 -28
- package/src/testbench/p2p_client_testbench_worker.ts +91 -61
- package/src/testbench/worker_client_manager.ts +72 -25
- package/src/util.ts +33 -18
- 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 -122
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- package/dest/services/reqresp/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 -54
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/fast_tx_collection.js +0 -327
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
- package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -49
- 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 -346
- 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 -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 -387
- package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -113
- package/src/services/tx_collection/slow_tx_collection.ts +0 -266
|
@@ -2,7 +2,7 @@ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
|
2
2
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
3
3
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
4
4
|
import { type AztecNode, createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { Tx, TxHash, TxValidator } from '@aztec/stdlib/tx';
|
|
6
6
|
import { type ComponentsVersions, getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
7
7
|
import { makeTracedFetch } from '@aztec/telemetry-client';
|
|
8
8
|
|
|
@@ -16,12 +16,13 @@ export interface TxSource {
|
|
|
16
16
|
export class NodeRpcTxSource implements TxSource {
|
|
17
17
|
constructor(
|
|
18
18
|
private readonly client: Pick<AztecNode, 'getTxsByHash'>,
|
|
19
|
+
private readonly txValidator: TxValidator,
|
|
19
20
|
private readonly info: string,
|
|
20
21
|
) {}
|
|
21
22
|
|
|
22
|
-
public static fromUrl(nodeUrl: string, versions: ComponentsVersions): NodeRpcTxSource {
|
|
23
|
+
public static fromUrl(nodeUrl: string, txValidator: TxValidator, versions: ComponentsVersions): NodeRpcTxSource {
|
|
23
24
|
const client = createAztecNodeClient(nodeUrl, versions, makeTracedFetch([1, 2, 3], false));
|
|
24
|
-
return new NodeRpcTxSource(client, nodeUrl);
|
|
25
|
+
return new NodeRpcTxSource(client, txValidator, nodeUrl);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
public getInfo() {
|
|
@@ -38,8 +39,8 @@ export class NodeRpcTxSource implements TxSource {
|
|
|
38
39
|
const invalidTxHashes: string[] = [];
|
|
39
40
|
await Promise.all(
|
|
40
41
|
txs.map(async tx => {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
42
|
+
const validation = await this.txValidator.validateTx(tx);
|
|
43
|
+
if (validation.result === 'valid') {
|
|
43
44
|
validTxs.push(tx);
|
|
44
45
|
} else {
|
|
45
46
|
invalidTxHashes.push(tx.getTxHash().toString());
|
|
@@ -50,7 +51,7 @@ export class NodeRpcTxSource implements TxSource {
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
export function createNodeRpcTxSources(urls: string[], chainConfig: ChainConfig) {
|
|
54
|
+
export function createNodeRpcTxSources(urls: string[], txValidator: TxValidator, chainConfig: ChainConfig) {
|
|
54
55
|
const versions = getComponentsVersionsFromConfig(chainConfig, protocolContractsHash, getVKTreeRoot());
|
|
55
|
-
return urls.map(url => NodeRpcTxSource.fromUrl(url, versions));
|
|
56
|
+
return urls.map(url => NodeRpcTxSource.fromUrl(url, txValidator, versions));
|
|
56
57
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FifoSet } from '@aztec/foundation/fifo-set';
|
|
1
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { RunningPromise } from '@aztec/foundation/promise';
|
|
3
4
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
@@ -10,6 +11,8 @@ import type { TxPoolV2 } from '../../mem_pools/index.js';
|
|
|
10
11
|
import type { TxFileStoreConfig } from './config.js';
|
|
11
12
|
import { TxFileStoreInstrumentation } from './instrumentation.js';
|
|
12
13
|
|
|
14
|
+
const MAX_RECENT_UPLOADS = 1000;
|
|
15
|
+
|
|
13
16
|
/**
|
|
14
17
|
* Uploads validated transactions to a file store as a fallback retrieval mechanism.
|
|
15
18
|
* Listens to TxPool txs-added events and uploads txs asynchronously with bounded concurrency.
|
|
@@ -21,9 +24,7 @@ export class TxFileStore {
|
|
|
21
24
|
private readonly handleTxsAdded: (args: { txs: Tx[]; source?: string }) => void;
|
|
22
25
|
|
|
23
26
|
/** Recently uploaded tx hashes for deduplication. */
|
|
24
|
-
private recentUploads
|
|
25
|
-
private recentUploadsOrder: string[] = [];
|
|
26
|
-
private readonly maxRecentUploads = 1000;
|
|
27
|
+
private recentUploads = FifoSet.withLimit<string>(MAX_RECENT_UPLOADS);
|
|
27
28
|
|
|
28
29
|
private constructor(
|
|
29
30
|
private readonly fileStore: FileStore,
|
|
@@ -127,24 +128,11 @@ export class TxFileStore {
|
|
|
127
128
|
const path = `${this.basePath}/txs/${txHash}.bin`;
|
|
128
129
|
const timer = new Timer();
|
|
129
130
|
|
|
130
|
-
if (this.recentUploads.
|
|
131
|
+
if (!this.recentUploads.addIfAbsent(txHash)) {
|
|
131
132
|
return;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
try {
|
|
135
|
-
this.recentUploads.add(txHash);
|
|
136
|
-
this.recentUploadsOrder.push(txHash);
|
|
137
|
-
|
|
138
|
-
if (this.recentUploadsOrder.length > this.maxRecentUploads) {
|
|
139
|
-
// delete old entries in recentUploads
|
|
140
|
-
for (const txHashToRemove of this.recentUploadsOrder.splice(
|
|
141
|
-
0,
|
|
142
|
-
this.recentUploadsOrder.length - this.maxRecentUploads,
|
|
143
|
-
)) {
|
|
144
|
-
this.recentUploads.delete(txHashToRemove);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
136
|
await retry(
|
|
149
137
|
() => this.fileStore.save(path, tx.toBuffer(), { compress: true }),
|
|
150
138
|
`Uploading tx ${txHash}`,
|
|
@@ -32,6 +32,11 @@ export class TxProvider implements ITxProvider {
|
|
|
32
32
|
this.instrumentation = new TxProviderInstrumentation(client, 'TxProvider');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/** Returns whether each tx hash is currently in the local tx pool. */
|
|
36
|
+
public hasTxs(txHashes: TxHash[]): Promise<boolean[]> {
|
|
37
|
+
return this.txPool.hasTxs(txHashes);
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
/** Returns txs from the tx pool given their hashes.*/
|
|
36
41
|
public async getAvailableTxs(txHashes: TxHash[]): Promise<{ txs: Tx[]; missingTxs: TxHash[] }> {
|
|
37
42
|
const response = await this.txPool.getTxsByHash(txHashes);
|
|
@@ -4,10 +4,10 @@ import { SecretValue } from '@aztec/foundation/config';
|
|
|
4
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
6
6
|
import { sleep } from '@aztec/foundation/sleep';
|
|
7
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
8
7
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
8
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
9
9
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
10
|
-
import {
|
|
10
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
11
11
|
|
|
12
12
|
import { createP2PClient } from '../client/index.js';
|
|
13
13
|
import type { P2PClient } from '../client/p2p_client.js';
|
|
@@ -98,12 +98,12 @@ export async function makeTestP2PClient(
|
|
|
98
98
|
const kvStore = await openTmpStore('test');
|
|
99
99
|
|
|
100
100
|
const client = await createP2PClient(
|
|
101
|
-
P2PClientType.Full,
|
|
102
101
|
config,
|
|
103
102
|
l2BlockSource,
|
|
104
103
|
proofVerifier,
|
|
105
104
|
mockWorldState,
|
|
106
105
|
mockEpochCache,
|
|
106
|
+
{ getCurrentMinFees: () => Promise.resolve(GasFees.empty()) },
|
|
107
107
|
'test-p2p-client',
|
|
108
108
|
undefined,
|
|
109
109
|
undefined,
|
|
@@ -114,6 +114,7 @@ export async function makeTestP2PClient(
|
|
|
114
114
|
logger,
|
|
115
115
|
p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork),
|
|
116
116
|
},
|
|
117
|
+
await l2BlockSource.getInitialHeader().hash(),
|
|
117
118
|
);
|
|
118
119
|
|
|
119
120
|
return client;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
3
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
5
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
5
6
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
7
|
+
import type { BlockMinFeesProvider } from '@aztec/stdlib/gas';
|
|
6
8
|
import type { ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
7
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
8
9
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
9
10
|
|
|
10
11
|
import type { GossipsubEvents, GossipsubMessage } from '@chainsafe/libp2p-gossipsub';
|
|
@@ -22,15 +23,12 @@ import type { MemPools } from '../mem_pools/interface.js';
|
|
|
22
23
|
import { DummyPeerDiscoveryService, DummyPeerManager, LibP2PService } from '../services/index.js';
|
|
23
24
|
import type { P2PReqRespConfig } from '../services/reqresp/config.js';
|
|
24
25
|
import type { ConnectionSampler } from '../services/reqresp/connection-sampler/connection_sampler.js';
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
type ReqRespSubProtocolValidators,
|
|
32
|
-
type SubProtocolMap,
|
|
33
|
-
responseFromBuffer,
|
|
26
|
+
import type {
|
|
27
|
+
ReqRespInterface,
|
|
28
|
+
ReqRespResponse,
|
|
29
|
+
ReqRespSubProtocol,
|
|
30
|
+
ReqRespSubProtocolHandler,
|
|
31
|
+
ReqRespSubProtocolHandlers,
|
|
34
32
|
} from '../services/reqresp/interface.js';
|
|
35
33
|
import { ReqRespStatus } from '../services/reqresp/status.js';
|
|
36
34
|
import { GossipSubEvent } from '../types/index.js';
|
|
@@ -42,11 +40,10 @@ type GossipSubService = PubSubLibp2p['services']['pubsub'];
|
|
|
42
40
|
* Given a mock gossip sub network, returns a factory function that creates an instance LibP2PService connected to it.
|
|
43
41
|
* Designed to be used in tests in P2PClientDeps.p2pServiceFactory.
|
|
44
42
|
*/
|
|
45
|
-
export function getMockPubSubP2PServiceFactory
|
|
43
|
+
export function getMockPubSubP2PServiceFactory(
|
|
46
44
|
network: MockGossipSubNetwork,
|
|
47
|
-
): (...args: Parameters<(typeof LibP2PService
|
|
45
|
+
): (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService> {
|
|
48
46
|
return (
|
|
49
|
-
clientType: P2PClientType,
|
|
50
47
|
config: P2PConfig,
|
|
51
48
|
peerId: PeerId,
|
|
52
49
|
deps: {
|
|
@@ -57,6 +54,7 @@ export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
|
|
|
57
54
|
proofVerifier: ClientProtocolCircuitVerifier;
|
|
58
55
|
worldStateSynchronizer: WorldStateSynchronizer;
|
|
59
56
|
peerStore: AztecAsyncKVStore;
|
|
57
|
+
blockMinFeesProvider: BlockMinFeesProvider;
|
|
60
58
|
telemetry: TelemetryClient;
|
|
61
59
|
logger: Logger;
|
|
62
60
|
},
|
|
@@ -66,8 +64,7 @@ export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
|
|
|
66
64
|
const peerManager = new DummyPeerManager(peerId, network);
|
|
67
65
|
const reqresp: ReqRespInterface = new MockReqResp(peerId, network);
|
|
68
66
|
const peerDiscoveryService = new DummyPeerDiscoveryService();
|
|
69
|
-
const service = new LibP2PService
|
|
70
|
-
clientType as T,
|
|
67
|
+
const service = new LibP2PService(
|
|
71
68
|
config,
|
|
72
69
|
libp2p,
|
|
73
70
|
peerDiscoveryService,
|
|
@@ -78,6 +75,7 @@ export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
|
|
|
78
75
|
deps.epochCache,
|
|
79
76
|
deps.proofVerifier,
|
|
80
77
|
deps.worldStateSynchronizer,
|
|
78
|
+
deps.blockMinFeesProvider,
|
|
81
79
|
deps.telemetry,
|
|
82
80
|
deps.logger,
|
|
83
81
|
);
|
|
@@ -88,8 +86,8 @@ export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
|
|
|
88
86
|
|
|
89
87
|
/**
|
|
90
88
|
* Mock implementation of ReqRespInterface that routes requests to other peers' handlers through the mock network.
|
|
91
|
-
* When a peer calls
|
|
92
|
-
*
|
|
89
|
+
* When a peer calls sendRequestToPeer, the mock looks up the target peer's registered handler for the
|
|
90
|
+
* sub-protocol and invokes it, simulating the request-response protocol without actual libp2p streams.
|
|
93
91
|
*/
|
|
94
92
|
class MockReqResp implements ReqRespInterface {
|
|
95
93
|
private handlers: Partial<ReqRespSubProtocolHandlers> = {};
|
|
@@ -103,20 +101,14 @@ class MockReqResp implements ReqRespInterface {
|
|
|
103
101
|
}
|
|
104
102
|
|
|
105
103
|
updateConfig(_config: Partial<P2PReqRespConfig>): void {}
|
|
104
|
+
setShouldRejectPeer(): void {}
|
|
106
105
|
|
|
107
|
-
start(
|
|
108
|
-
subProtocolHandlers: Partial<ReqRespSubProtocolHandlers>,
|
|
109
|
-
_subProtocolValidators: ReqRespSubProtocolValidators,
|
|
110
|
-
): Promise<void> {
|
|
106
|
+
start(subProtocolHandlers: Partial<ReqRespSubProtocolHandlers>): Promise<void> {
|
|
111
107
|
Object.assign(this.handlers, subProtocolHandlers);
|
|
112
108
|
return Promise.resolve();
|
|
113
109
|
}
|
|
114
110
|
|
|
115
|
-
addSubProtocol(
|
|
116
|
-
subProtocol: ReqRespSubProtocol,
|
|
117
|
-
handler: ReqRespSubProtocolHandler,
|
|
118
|
-
_validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
|
|
119
|
-
): Promise<void> {
|
|
111
|
+
addSubProtocol(subProtocol: ReqRespSubProtocol, handler: ReqRespSubProtocolHandler): Promise<void> {
|
|
120
112
|
this.handlers[subProtocol] = handler;
|
|
121
113
|
return Promise.resolve();
|
|
122
114
|
}
|
|
@@ -130,41 +122,6 @@ class MockReqResp implements ReqRespInterface {
|
|
|
130
122
|
return this.handlers[subProtocol];
|
|
131
123
|
}
|
|
132
124
|
|
|
133
|
-
async sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(
|
|
134
|
-
subProtocol: SubProtocol,
|
|
135
|
-
requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[],
|
|
136
|
-
pinnedPeer: PeerId | undefined,
|
|
137
|
-
_timeoutMs?: number,
|
|
138
|
-
_maxPeers?: number,
|
|
139
|
-
_maxRetryAttempts?: number,
|
|
140
|
-
): Promise<InstanceType<SubProtocolMap[SubProtocol]['response']>[]> {
|
|
141
|
-
const responses: InstanceType<SubProtocolMap[SubProtocol]['response']>[] = [];
|
|
142
|
-
const peers = this.network.getReqRespPeers().filter(p => !p.peerId.equals(this.peerId));
|
|
143
|
-
const targetPeers = pinnedPeer ? peers.filter(p => p.peerId.equals(pinnedPeer)) : peers;
|
|
144
|
-
|
|
145
|
-
for (const request of requests) {
|
|
146
|
-
const requestBuffer = request.toBuffer();
|
|
147
|
-
for (const peer of targetPeers) {
|
|
148
|
-
const handler = peer.getHandler(subProtocol);
|
|
149
|
-
if (!handler) {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
try {
|
|
153
|
-
const responseBuffer = await handler(this.peerId, requestBuffer);
|
|
154
|
-
if (responseBuffer.length > 0) {
|
|
155
|
-
const response = responseFromBuffer(subProtocol, responseBuffer);
|
|
156
|
-
responses.push(response as InstanceType<SubProtocolMap[SubProtocol]['response']>);
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
} catch (err) {
|
|
160
|
-
this.logger.debug(`Mock reqresp handler error from peer ${peer.peerId}`, { err });
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return responses;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
125
|
async sendRequestToPeer(
|
|
169
126
|
peerId: PeerId,
|
|
170
127
|
subProtocol: ReqRespSubProtocol,
|
|
@@ -177,7 +134,12 @@ class MockReqResp implements ReqRespInterface {
|
|
|
177
134
|
return { status: ReqRespStatus.SUCCESS, data: Buffer.from([]) };
|
|
178
135
|
}
|
|
179
136
|
try {
|
|
137
|
+
const delayMs = this.network.getPropagationDelayMs();
|
|
138
|
+
if (delayMs > 0) {
|
|
139
|
+
await sleep(delayMs);
|
|
140
|
+
}
|
|
180
141
|
const data = await handler(this.peerId, payload);
|
|
142
|
+
|
|
181
143
|
return { status: ReqRespStatus.SUCCESS, data };
|
|
182
144
|
} catch {
|
|
183
145
|
return { status: ReqRespStatus.FAILURE };
|
|
@@ -215,6 +177,13 @@ export class MockPubSub implements PubSubLibp2p {
|
|
|
215
177
|
get services() {
|
|
216
178
|
return {
|
|
217
179
|
pubsub: this.gossipSub,
|
|
180
|
+
components: {
|
|
181
|
+
addressManager: {
|
|
182
|
+
addObservedAddr: () => {},
|
|
183
|
+
confirmObservedAddr: () => {},
|
|
184
|
+
removeObservedAddr: () => {},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
218
187
|
};
|
|
219
188
|
}
|
|
220
189
|
|
|
@@ -245,10 +214,10 @@ class MockGossipSubService extends TypedEventEmitter<GossipsubEvents> implements
|
|
|
245
214
|
score: (_peerId: PeerIdStr) => 0,
|
|
246
215
|
};
|
|
247
216
|
|
|
248
|
-
publish(topic: TopicStr, data: Uint8Array, _opts?: PublishOpts): Promise<PublishResult> {
|
|
217
|
+
async publish(topic: TopicStr, data: Uint8Array, _opts?: PublishOpts): Promise<PublishResult> {
|
|
249
218
|
this.logger.debug(`Publishing message on topic ${topic}`, { topic, sender: this.peerId.toString() });
|
|
250
|
-
this.network.publishToPeers(topic, data, this.peerId);
|
|
251
|
-
return
|
|
219
|
+
await this.network.publishToPeers(topic, data, this.peerId);
|
|
220
|
+
return { recipients: this.network.getPeers().filter(peer => !this.peerId.equals(peer)) };
|
|
252
221
|
}
|
|
253
222
|
|
|
254
223
|
receive(msg: GossipsubMessage) {
|
|
@@ -284,7 +253,8 @@ class MockGossipSubService extends TypedEventEmitter<GossipsubEvents> implements
|
|
|
284
253
|
|
|
285
254
|
/**
|
|
286
255
|
* Mock gossip sub network used for testing.
|
|
287
|
-
* All instances of MockGossipSubService connected to the same network
|
|
256
|
+
* All instances of MockGossipSubService connected to the same network receive the same messages,
|
|
257
|
+
* optionally delayed by a configurable propagation time.
|
|
288
258
|
*/
|
|
289
259
|
export class MockGossipSubNetwork {
|
|
290
260
|
private peers: MockGossipSubService[] = [];
|
|
@@ -293,6 +263,15 @@ export class MockGossipSubNetwork {
|
|
|
293
263
|
|
|
294
264
|
private logger = createLogger('p2p:test:mock-gossipsub-network');
|
|
295
265
|
|
|
266
|
+
constructor(
|
|
267
|
+
/** Artificial propagation delay in milliseconds applied to each message delivery. */
|
|
268
|
+
private propagationDelayMs: number = 0,
|
|
269
|
+
) {}
|
|
270
|
+
|
|
271
|
+
public getPropagationDelayMs(): number {
|
|
272
|
+
return this.propagationDelayMs;
|
|
273
|
+
}
|
|
274
|
+
|
|
296
275
|
public getPeers(): PeerId[] {
|
|
297
276
|
return this.peers.map(peer => peer.peerId);
|
|
298
277
|
}
|
|
@@ -309,7 +288,7 @@ export class MockGossipSubNetwork {
|
|
|
309
288
|
return this.reqRespPeers;
|
|
310
289
|
}
|
|
311
290
|
|
|
312
|
-
public publishToPeers(topic: TopicStr, data: Uint8Array, sender: PeerId): void {
|
|
291
|
+
public async publishToPeers(topic: TopicStr, data: Uint8Array, sender: PeerId): Promise<void> {
|
|
313
292
|
const msgId = (this.nextMsgId++).toString();
|
|
314
293
|
this.logger.debug(`Network is distributing message on topic ${topic}`, {
|
|
315
294
|
topic,
|
|
@@ -318,6 +297,10 @@ export class MockGossipSubNetwork {
|
|
|
318
297
|
msgId,
|
|
319
298
|
});
|
|
320
299
|
|
|
300
|
+
if (this.propagationDelayMs > 0) {
|
|
301
|
+
await sleep(this.propagationDelayMs);
|
|
302
|
+
}
|
|
303
|
+
|
|
321
304
|
const gossipSubMsg: GossipsubMessage = { msgId, msg: { type: 'unsigned', topic, data }, propagationSource: sender };
|
|
322
305
|
for (const peer of this.peers) {
|
|
323
306
|
if (peer.subscribedTopics.has(topic)) {
|
|
@@ -2,17 +2,17 @@ import type { EpochCache } from '@aztec/epoch-cache';
|
|
|
2
2
|
import { timesParallel } from '@aztec/foundation/collection';
|
|
3
3
|
import { SecretValue } from '@aztec/foundation/config';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
6
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
7
6
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
8
7
|
import { type ChainConfig, emptyChainConfig } from '@aztec/stdlib/config';
|
|
9
8
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
9
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
10
10
|
import type {
|
|
11
11
|
ClientProtocolCircuitVerifier,
|
|
12
12
|
IVCProofVerificationResult,
|
|
13
13
|
WorldStateSynchronizer,
|
|
14
14
|
} from '@aztec/stdlib/interfaces/server';
|
|
15
|
-
import type {
|
|
15
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
16
16
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
17
17
|
import { compressComponentVersions } from '@aztec/stdlib/versioning';
|
|
18
18
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -31,7 +31,7 @@ import getPort from 'get-port';
|
|
|
31
31
|
import { type Libp2p, type Libp2pOptions, createLibp2p } from 'libp2p';
|
|
32
32
|
|
|
33
33
|
import { BootstrapNode } from '../bootstrap/bootstrap.js';
|
|
34
|
-
import type
|
|
34
|
+
import { type BootnodeConfig, DEFAULT_PUBLIC_IP_SERVICES, type P2PConfig } from '../config.js';
|
|
35
35
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
36
36
|
import { DiscV5Service } from '../services/discv5/discV5_service.js';
|
|
37
37
|
import { APP_SPECIFIC_WEIGHT } from '../services/gossipsub/scoring.js';
|
|
@@ -43,8 +43,6 @@ import {
|
|
|
43
43
|
ReqRespSubProtocol,
|
|
44
44
|
type ReqRespSubProtocolHandlers,
|
|
45
45
|
type ReqRespSubProtocolRateLimits,
|
|
46
|
-
type ReqRespSubProtocolValidators,
|
|
47
|
-
noopValidator,
|
|
48
46
|
} from '../services/reqresp/interface.js';
|
|
49
47
|
import { pingHandler } from '../services/reqresp/protocols/index.js';
|
|
50
48
|
import { ReqResp } from '../services/reqresp/reqresp.js';
|
|
@@ -77,6 +75,10 @@ export async function createLibp2pNode(
|
|
|
77
75
|
identify: identify({
|
|
78
76
|
protocolPrefix: 'aztec',
|
|
79
77
|
}),
|
|
78
|
+
components: (components: { connectionManager: any; addressManager: any }) => ({
|
|
79
|
+
connectionManager: components.connectionManager,
|
|
80
|
+
addressManager: components.addressManager,
|
|
81
|
+
}),
|
|
80
82
|
},
|
|
81
83
|
};
|
|
82
84
|
|
|
@@ -107,8 +109,7 @@ export async function createLibp2pNode(
|
|
|
107
109
|
*
|
|
108
110
|
*
|
|
109
111
|
*/
|
|
110
|
-
export async function createTestLibP2PService
|
|
111
|
-
clientType: T,
|
|
112
|
+
export async function createTestLibP2PService(
|
|
112
113
|
boostrapAddrs: string[] = [],
|
|
113
114
|
archiver: L2BlockSource & ContractDataSource,
|
|
114
115
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
@@ -155,12 +156,13 @@ export async function createTestLibP2PService<T extends P2PClientType>(
|
|
|
155
156
|
epochCache,
|
|
156
157
|
);
|
|
157
158
|
|
|
159
|
+
reqresp.setShouldRejectPeer(peerId => peerManager.shouldDisableP2PGossip(peerId));
|
|
160
|
+
|
|
158
161
|
p2pNode.services.pubsub.score.params.appSpecificWeight = APP_SPECIFIC_WEIGHT;
|
|
159
162
|
p2pNode.services.pubsub.score.params.appSpecificScore = (peerId: string) =>
|
|
160
163
|
peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
|
|
161
164
|
|
|
162
|
-
return new LibP2PService
|
|
163
|
-
clientType,
|
|
165
|
+
return new LibP2PService(
|
|
164
166
|
config,
|
|
165
167
|
p2pNode as PubSubLibp2p,
|
|
166
168
|
discoveryService,
|
|
@@ -171,6 +173,7 @@ export async function createTestLibP2PService<T extends P2PClientType>(
|
|
|
171
173
|
epochCache,
|
|
172
174
|
proofVerifier,
|
|
173
175
|
worldStateSynchronizer,
|
|
176
|
+
{ getCurrentMinFees: () => Promise.resolve(GasFees.empty()) },
|
|
174
177
|
telemetry,
|
|
175
178
|
);
|
|
176
179
|
}
|
|
@@ -190,23 +193,10 @@ export const MOCK_SUB_PROTOCOL_HANDLERS: ReqRespSubProtocolHandlers = {
|
|
|
190
193
|
[ReqRespSubProtocol.STATUS]: (_msg: any) => Promise.resolve(Buffer.from('status')),
|
|
191
194
|
[ReqRespSubProtocol.TX]: (_msg: any) => Promise.resolve(Buffer.from('tx')),
|
|
192
195
|
[ReqRespSubProtocol.GOODBYE]: (_msg: any) => Promise.resolve(Buffer.from('goodbye')),
|
|
193
|
-
[ReqRespSubProtocol.BLOCK]: (_msg: any) => Promise.resolve(Buffer.from('block')),
|
|
194
196
|
[ReqRespSubProtocol.AUTH]: (_msg: any) => Promise.resolve(Buffer.from('auth')),
|
|
195
197
|
[ReqRespSubProtocol.BLOCK_TXS]: (_msg: any) => Promise.resolve(Buffer.from('block_txs')),
|
|
196
198
|
};
|
|
197
199
|
|
|
198
|
-
// By default, all requests are valid
|
|
199
|
-
// If you want to test an invalid response, you can override the validator
|
|
200
|
-
export const MOCK_SUB_PROTOCOL_VALIDATORS: ReqRespSubProtocolValidators = {
|
|
201
|
-
[ReqRespSubProtocol.PING]: noopValidator,
|
|
202
|
-
[ReqRespSubProtocol.STATUS]: noopValidator,
|
|
203
|
-
[ReqRespSubProtocol.TX]: noopValidator,
|
|
204
|
-
[ReqRespSubProtocol.GOODBYE]: noopValidator,
|
|
205
|
-
[ReqRespSubProtocol.BLOCK]: noopValidator,
|
|
206
|
-
[ReqRespSubProtocol.AUTH]: noopValidator,
|
|
207
|
-
[ReqRespSubProtocol.BLOCK_TXS]: noopValidator,
|
|
208
|
-
};
|
|
209
|
-
|
|
210
200
|
/**
|
|
211
201
|
* @param numberOfNodes - the number of nodes to create
|
|
212
202
|
* @returns An array of the created nodes
|
|
@@ -219,13 +209,9 @@ export const createNodes = (
|
|
|
219
209
|
return timesParallel(numberOfNodes, () => createReqResp(peerScoring, rateLimits));
|
|
220
210
|
};
|
|
221
211
|
|
|
222
|
-
export const startNodes = async (
|
|
223
|
-
nodes: ReqRespNode[],
|
|
224
|
-
subProtocolHandlers = MOCK_SUB_PROTOCOL_HANDLERS,
|
|
225
|
-
subProtocolValidators = MOCK_SUB_PROTOCOL_VALIDATORS,
|
|
226
|
-
) => {
|
|
212
|
+
export const startNodes = async (nodes: ReqRespNode[], subProtocolHandlers = MOCK_SUB_PROTOCOL_HANDLERS) => {
|
|
227
213
|
for (const node of nodes) {
|
|
228
|
-
await node.req.start(subProtocolHandlers
|
|
214
|
+
await node.req.start(subProtocolHandlers);
|
|
229
215
|
}
|
|
230
216
|
};
|
|
231
217
|
|
|
@@ -293,6 +279,7 @@ export function createBootstrapNodeConfig(privateKey: string, port: number, chai
|
|
|
293
279
|
bootstrapNodes: [],
|
|
294
280
|
listenAddress: '127.0.0.1',
|
|
295
281
|
queryForIp: false,
|
|
282
|
+
publicIpServices: DEFAULT_PUBLIC_IP_SERVICES,
|
|
296
283
|
};
|
|
297
284
|
}
|
|
298
285
|
|
|
@@ -31,6 +31,11 @@ export class TestTxProvider implements ITxProvider {
|
|
|
31
31
|
return this.getTxsByHashes(txHashes);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** Returns whether each tx hash is in the seeded collection. */
|
|
35
|
+
hasTxs(txHashes: TxHash[]): Promise<boolean[]> {
|
|
36
|
+
return Promise.resolve(txHashes.map(h => this.txs.has(h.toString())));
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
/** Get txs for a block proposal, returning any seeded txs that match the requested hashes. */
|
|
35
40
|
getTxsForBlockProposal(
|
|
36
41
|
blockProposal: BlockProposal,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
+
import type { CheckpointProposalHash } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
4
|
import type { Logger } from '@aztec/foundation/log';
|
|
4
5
|
import type { L2Block, L2BlockId } from '@aztec/stdlib/block';
|
|
5
6
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import type {
|
|
7
|
-
BlockProposal,
|
|
8
|
-
CheckpointAttestation,
|
|
9
|
-
CheckpointProposal,
|
|
10
|
-
CheckpointProposalCore,
|
|
11
|
-
} from '@aztec/stdlib/p2p';
|
|
7
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposalCore } from '@aztec/stdlib/p2p';
|
|
12
8
|
import { type BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
13
9
|
|
|
14
10
|
import EventEmitter from 'events';
|
|
@@ -214,6 +210,7 @@ export class InMemoryTxPool extends EventEmitter implements TxPoolV2 {
|
|
|
214
210
|
*/
|
|
215
211
|
export class InMemoryAttestationPool {
|
|
216
212
|
private proposals = new Map<string, BlockProposal>();
|
|
213
|
+
private checkpoints = new Map<SlotNumber, CheckpointProposalCore[]>();
|
|
217
214
|
|
|
218
215
|
tryAddBlockProposal(blockProposal: BlockProposal): Promise<TryAddResult> {
|
|
219
216
|
const id = blockProposal.archive.toString();
|
|
@@ -225,16 +222,29 @@ export class InMemoryAttestationPool {
|
|
|
225
222
|
return Promise.resolve({ added: true, alreadyExists: false, count: 1 });
|
|
226
223
|
}
|
|
227
224
|
|
|
228
|
-
|
|
225
|
+
getBlockProposalByArchive(id: string): Promise<BlockProposal | undefined> {
|
|
229
226
|
return Promise.resolve(this.proposals.get(id));
|
|
230
227
|
}
|
|
231
228
|
|
|
232
|
-
tryAddCheckpointProposal(
|
|
229
|
+
tryAddCheckpointProposal(proposal: CheckpointProposalCore): Promise<TryAddResult> {
|
|
230
|
+
const proposals = this.checkpoints.get(proposal.slotNumber) ?? [];
|
|
231
|
+
proposals.push(proposal);
|
|
232
|
+
this.checkpoints.set(proposal.slotNumber, proposals);
|
|
233
233
|
return Promise.resolve({ added: true, alreadyExists: false, count: 1 });
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
getCheckpointProposal(
|
|
237
|
-
return Promise.resolve(
|
|
236
|
+
getCheckpointProposal(slot: SlotNumber): Promise<CheckpointProposalCore | undefined> {
|
|
237
|
+
return Promise.resolve(this.checkpoints.get(slot)?.[0]);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
getProposalsForSlot(slot: SlotNumber): Promise<{
|
|
241
|
+
blockProposals: BlockProposal[];
|
|
242
|
+
checkpointProposals: CheckpointProposalCore[];
|
|
243
|
+
}> {
|
|
244
|
+
return Promise.resolve({
|
|
245
|
+
blockProposals: [...this.proposals.values()].filter(proposal => proposal.slotNumber === slot),
|
|
246
|
+
checkpointProposals: this.checkpoints.get(slot) ?? [],
|
|
247
|
+
});
|
|
238
248
|
}
|
|
239
249
|
|
|
240
250
|
async addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {}
|
|
@@ -247,7 +257,7 @@ export class InMemoryAttestationPool {
|
|
|
247
257
|
|
|
248
258
|
getCheckpointAttestationsForSlotAndProposal(
|
|
249
259
|
_slot: SlotNumber,
|
|
250
|
-
|
|
260
|
+
_proposalPayloadHash: CheckpointProposalHash,
|
|
251
261
|
): Promise<CheckpointAttestation[]> {
|
|
252
262
|
return Promise.resolve([]);
|
|
253
263
|
}
|
|
@@ -261,11 +271,12 @@ export class InMemoryAttestationPool {
|
|
|
261
271
|
}
|
|
262
272
|
|
|
263
273
|
isEmpty(): Promise<boolean> {
|
|
264
|
-
return Promise.resolve(this.proposals.size === 0);
|
|
274
|
+
return Promise.resolve(this.proposals.size === 0 && this.checkpoints.size === 0);
|
|
265
275
|
}
|
|
266
276
|
|
|
267
277
|
resetState(): void {
|
|
268
278
|
this.proposals.clear();
|
|
279
|
+
this.checkpoints.clear();
|
|
269
280
|
}
|
|
270
281
|
}
|
|
271
282
|
|
|
@@ -273,17 +284,42 @@ export class InMemoryAttestationPool {
|
|
|
273
284
|
* Creates a mock EpochCache for testing.
|
|
274
285
|
*/
|
|
275
286
|
export function createMockEpochCache(): EpochCacheInterface {
|
|
276
|
-
|
|
287
|
+
const cache: EpochCacheInterface = {
|
|
277
288
|
getCommittee: () => Promise.resolve({ committee: [], seed: 1n, epoch: EpochNumber.ZERO, isEscapeHatchOpen: false }),
|
|
278
289
|
getProposerIndexEncoding: () => '0x' as `0x${string}`,
|
|
279
|
-
|
|
290
|
+
getSlotNow: () => SlotNumber.ZERO,
|
|
291
|
+
getTargetSlot: () => SlotNumber.ZERO,
|
|
292
|
+
getEpochNow: () => EpochNumber.ZERO,
|
|
293
|
+
getTargetEpoch: () => EpochNumber.ZERO,
|
|
294
|
+
getEpochAndSlotNow: () => ({
|
|
295
|
+
epoch: EpochNumber.ZERO,
|
|
296
|
+
slot: SlotNumber.ZERO,
|
|
297
|
+
ts: 0n,
|
|
298
|
+
nowMs: 0n,
|
|
299
|
+
}),
|
|
300
|
+
isProposerPipeliningEnabled: () => false,
|
|
301
|
+
pipeliningOffset: () => 0,
|
|
280
302
|
computeProposerIndex: () => 0n,
|
|
281
303
|
getCurrentAndNextSlot: () => ({ currentSlot: SlotNumber.ZERO, nextSlot: SlotNumber.ZERO }),
|
|
304
|
+
getTargetAndNextSlot: () => ({ targetSlot: SlotNumber.ZERO, nextSlot: SlotNumber.ZERO }),
|
|
282
305
|
getProposerAttesterAddressInSlot: () => Promise.resolve(undefined),
|
|
283
|
-
getEpochAndSlotInNextL1Slot: () => ({
|
|
306
|
+
getEpochAndSlotInNextL1Slot: () => ({
|
|
307
|
+
epoch: EpochNumber.ZERO,
|
|
308
|
+
slot: SlotNumber.ZERO,
|
|
309
|
+
ts: 0n,
|
|
310
|
+
nowSeconds: 0n,
|
|
311
|
+
}),
|
|
312
|
+
getTargetEpochAndSlotInNextL1Slot: () => ({
|
|
313
|
+
epoch: EpochNumber.ZERO,
|
|
314
|
+
slot: SlotNumber.ZERO,
|
|
315
|
+
ts: 0n,
|
|
316
|
+
nowSeconds: 0n,
|
|
317
|
+
}),
|
|
284
318
|
isInCommittee: () => Promise.resolve(false),
|
|
285
319
|
getRegisteredValidators: () => Promise.resolve([]),
|
|
286
320
|
filterInCommittee: () => Promise.resolve([]),
|
|
321
|
+
isEscapeHatchOpen: () => Promise.resolve(false),
|
|
322
|
+
isEscapeHatchOpenAtSlot: () => Promise.resolve(false),
|
|
287
323
|
getL1Constants: () => ({
|
|
288
324
|
l1StartBlock: 0n,
|
|
289
325
|
l1GenesisTime: 0n,
|
|
@@ -292,8 +328,10 @@ export function createMockEpochCache(): EpochCacheInterface {
|
|
|
292
328
|
ethereumSlotDuration: 1,
|
|
293
329
|
proofSubmissionEpochs: 1,
|
|
294
330
|
targetCommitteeSize: 48,
|
|
331
|
+
rollupManaLimit: Number.MAX_SAFE_INTEGER,
|
|
295
332
|
}),
|
|
296
333
|
};
|
|
334
|
+
return cache;
|
|
297
335
|
}
|
|
298
336
|
|
|
299
337
|
/**
|
|
@@ -340,19 +378,6 @@ export function installUnlimitedRateLimitsOnReqResp(reqResp: any): void {
|
|
|
340
378
|
*/
|
|
341
379
|
export type DistributionPattern = 'uniform' | 'sparse' | 'pinned-only';
|
|
342
380
|
|
|
343
|
-
/**
|
|
344
|
-
* Collector implementation types for benchmarking.
|
|
345
|
-
*/
|
|
346
|
-
export type CollectorType = 'batch-requester' | 'send-batch-request';
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Display names for collector types (for output/logging only).
|
|
350
|
-
*/
|
|
351
|
-
export const COLLECTOR_DISPLAY_NAMES: Record<CollectorType, string> = {
|
|
352
|
-
'batch-requester': 'batch-requester (new)',
|
|
353
|
-
'send-batch-request': 'send-batch-request (old)',
|
|
354
|
-
};
|
|
355
|
-
|
|
356
381
|
/**
|
|
357
382
|
* Benchmark timing constants.
|
|
358
383
|
*/
|