@aztec/p2p 0.0.1-commit.934299a21 → 0.0.1-commit.949a33fd8
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/client/factory.d.ts +6 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +29 -14
- package/dest/client/interface.d.ts +12 -5
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +6 -5
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +47 -39
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +21 -8
- package/dest/config.d.ts +128 -100
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +97 -34
- 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/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 +7 -5
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +16 -9
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
- 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 +62 -29
- 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 +2 -2
- 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 +8 -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 +8 -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 +17 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +83 -48
- 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 +24 -20
- 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/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 +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +35 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +23 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +37 -11
- 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 +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +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/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/dummy_service.d.ts +6 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +6 -1
- 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 +23 -32
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +202 -151
- 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 +39 -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 +69 -65
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +3 -2
- 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/config.d.ts +3 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/interface.d.ts +14 -9
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +10 -11
- 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/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 +4 -2
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +30 -12
- package/dest/services/service.d.ts +5 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +57 -73
- 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/proposal_tx_collector.d.ts +6 -7
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +4 -4
- 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/slow_tx_collection.js +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +3 -6
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- 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/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 +4 -2
- package/dest/test-helpers/mock-pubsub.d.ts +12 -5
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +37 -12
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +6 -4
- package/dest/test-helpers/testbench-utils.d.ts +1 -1
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +23 -3
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +78 -21
- package/dest/testbench/worker_client_manager.d.ts +10 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +55 -3
- package/dest/util.d.ts +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +48 -19
- package/src/client/interface.ts +12 -10
- package/src/client/p2p_client.ts +52 -51
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +22 -11
- package/src/config.ts +146 -36
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +17 -12
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
- 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 +70 -26
- 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 +12 -2
- 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 +22 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +33 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +99 -49
- package/src/msg_validators/tx_validator/README.md +15 -3
- 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/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/factory.ts +46 -4
- 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 +1 -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/services/data_store.ts +5 -13
- package/src/services/dummy_service.ts +8 -2
- 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 +206 -164
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +45 -11
- package/src/services/peer-manager/peer_scoring.ts +27 -5
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +64 -69
- package/src/services/reqresp/batch-tx-requester/interface.ts +2 -1
- 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/config.ts +2 -2
- package/src/services/reqresp/interface.ts +21 -11
- package/src/services/reqresp/metrics.ts +0 -1
- 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 +40 -13
- package/src/services/service.ts +6 -1
- package/src/services/tx_collection/fast_tx_collection.ts +57 -83
- package/src/services/tx_collection/file_store_tx_source.ts +43 -31
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -13
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +1 -1
- package/src/services/tx_collection/tx_collection.ts +3 -5
- package/src/services/tx_collection/tx_source.ts +8 -7
- package/src/test-helpers/make-test-p2p-clients.ts +3 -3
- package/src/test-helpers/mock-pubsub.ts +37 -11
- package/src/test-helpers/reqresp-nodes.ts +7 -8
- package/src/test-helpers/testbench-utils.ts +30 -3
- package/src/testbench/p2p_client_testbench_worker.ts +77 -21
- package/src/testbench/worker_client_manager.ts +68 -6
- package/src/util.ts +1 -1
- 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/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/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/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/protocols/block.ts +0 -37
- package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
package/src/client/factory.ts
CHANGED
|
@@ -3,13 +3,13 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
5
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
6
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
7
6
|
import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
|
|
8
7
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
8
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
10
9
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
|
+
import type { BlockMinFeesProvider } from '@aztec/stdlib/gas';
|
|
11
11
|
import type { AztecNode, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
12
|
-
import {
|
|
12
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
13
13
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
14
|
|
|
15
15
|
import { P2PClient } from '../client/p2p_client.js';
|
|
@@ -18,7 +18,12 @@ import { AttestationPool, type AttestationPoolApi } from '../mem_pools/attestati
|
|
|
18
18
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
19
19
|
import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
20
20
|
import { AztecKVTxPoolV2 } from '../mem_pools/tx_pool_v2/tx_pool_v2.js';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
createCheckAllowedSetupCalls,
|
|
23
|
+
createTxValidatorForReqResponseReceivedTxs,
|
|
24
|
+
createTxValidatorForTransactionsEnteringPendingTxPool,
|
|
25
|
+
getDefaultAllowedSetupFunctions,
|
|
26
|
+
} from '../msg_validators/index.js';
|
|
22
27
|
import { DummyP2PService } from '../services/dummy_service.js';
|
|
23
28
|
import { LibP2PService } from '../services/index.js';
|
|
24
29
|
import { createFileStoreTxSources } from '../services/tx_collection/file_store_tx_source.js';
|
|
@@ -27,14 +32,14 @@ import { NodeRpcTxSource, type TxSource, createNodeRpcTxSources } from '../servi
|
|
|
27
32
|
import { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
|
|
28
33
|
import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
|
|
29
34
|
|
|
30
|
-
export type P2PClientDeps
|
|
35
|
+
export type P2PClientDeps = {
|
|
31
36
|
txPool?: TxPoolV2;
|
|
32
37
|
store?: AztecAsyncKVStore;
|
|
33
38
|
attestationPool?: AttestationPoolApi;
|
|
34
39
|
logger?: Logger;
|
|
35
40
|
txCollectionNodeSources?: TxSource[];
|
|
36
41
|
rpcTxProviders?: AztecNode[];
|
|
37
|
-
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService
|
|
42
|
+
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService>;
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
export const P2P_STORE_NAME = 'p2p';
|
|
@@ -42,17 +47,17 @@ export const P2P_ARCHIVE_STORE_NAME = 'p2p-archive';
|
|
|
42
47
|
export const P2P_PEER_STORE_NAME = 'p2p-peers';
|
|
43
48
|
export const P2P_ATTESTATION_STORE_NAME = 'p2p-attestation';
|
|
44
49
|
|
|
45
|
-
export async function createP2PClient
|
|
46
|
-
clientType: T,
|
|
50
|
+
export async function createP2PClient(
|
|
47
51
|
inputConfig: P2PConfig & DataStoreConfig & ChainConfig,
|
|
48
52
|
archiver: L2BlockSource & ContractDataSource,
|
|
49
53
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
50
54
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
51
55
|
epochCache: EpochCacheInterface,
|
|
56
|
+
blockMinFeesProvider: BlockMinFeesProvider,
|
|
52
57
|
packageVersion: string,
|
|
53
58
|
dateProvider: DateProvider = new DateProvider(),
|
|
54
59
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
55
|
-
deps: P2PClientDeps
|
|
60
|
+
deps: P2PClientDeps = {},
|
|
56
61
|
) {
|
|
57
62
|
const config = await configureP2PClientAddresses({
|
|
58
63
|
...inputConfig,
|
|
@@ -71,12 +76,22 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
71
76
|
const store = deps.store ?? (await createStore(P2P_STORE_NAME, 2, config, bindings));
|
|
72
77
|
const archive = await createStore(P2P_ARCHIVE_STORE_NAME, 1, config, bindings);
|
|
73
78
|
const peerStore = await createStore(P2P_PEER_STORE_NAME, 1, config, bindings);
|
|
74
|
-
const attestationStore = await createStore(P2P_ATTESTATION_STORE_NAME,
|
|
79
|
+
const attestationStore = await createStore(P2P_ATTESTATION_STORE_NAME, 2, config, bindings);
|
|
75
80
|
const l1Constants = await archiver.getL1Constants();
|
|
76
81
|
|
|
77
82
|
const rollupAddress = inputConfig.l1Contracts.rollupAddress.toString().toLowerCase().replace(/^0x/, '');
|
|
78
83
|
const txFileStoreBasePath = `aztec-${inputConfig.l1ChainId}-${inputConfig.rollupVersion}-0x${rollupAddress}`;
|
|
79
84
|
|
|
85
|
+
const allowedInSetup = [
|
|
86
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
87
|
+
...(inputConfig.txPublicSetupAllowListExtend ?? []),
|
|
88
|
+
];
|
|
89
|
+
const checkAllowedSetupCalls = createCheckAllowedSetupCalls(
|
|
90
|
+
archiver,
|
|
91
|
+
allowedInSetup,
|
|
92
|
+
() => epochCache.getEpochAndSlotInNextL1Slot().ts,
|
|
93
|
+
);
|
|
94
|
+
|
|
80
95
|
const txPool =
|
|
81
96
|
deps.txPool ??
|
|
82
97
|
new AztecKVTxPoolV2(
|
|
@@ -85,16 +100,25 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
85
100
|
{
|
|
86
101
|
l2BlockSource: archiver,
|
|
87
102
|
worldStateSynchronizer,
|
|
103
|
+
checkAllowedSetupCalls,
|
|
88
104
|
createTxValidator: async () => {
|
|
89
|
-
// We accept transactions if they are not expired by the next slot and block number (checked based on the ExpirationTimestamp field)
|
|
90
105
|
const currentBlockNumber = await archiver.getBlockNumber();
|
|
91
106
|
const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
|
|
107
|
+
const l1Constants = await archiver.getL1Constants();
|
|
108
|
+
const gasFees = await blockMinFeesProvider.getCurrentMinFees();
|
|
92
109
|
return createTxValidatorForTransactionsEnteringPendingTxPool(
|
|
93
110
|
worldStateSynchronizer,
|
|
94
111
|
nextSlotTimestamp,
|
|
95
112
|
BlockNumber(currentBlockNumber + 1),
|
|
113
|
+
{
|
|
114
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
115
|
+
maxBlockL2Gas: config.validateMaxL2BlockGas,
|
|
116
|
+
maxBlockDAGas: config.validateMaxDABlockGas,
|
|
117
|
+
},
|
|
118
|
+
gasFees,
|
|
96
119
|
);
|
|
97
120
|
},
|
|
121
|
+
blockMinFeesProvider,
|
|
98
122
|
},
|
|
99
123
|
telemetry,
|
|
100
124
|
{
|
|
@@ -102,6 +126,7 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
102
126
|
archivedTxLimit: config.archivedTxLimit,
|
|
103
127
|
minTxPoolAgeMs: config.minTxPoolAgeMs,
|
|
104
128
|
dropTransactionsProbability: config.dropTransactionsProbability,
|
|
129
|
+
priceBumpPercentage: config.priceBumpPercentage,
|
|
105
130
|
},
|
|
106
131
|
dateProvider,
|
|
107
132
|
);
|
|
@@ -111,13 +136,13 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
111
136
|
attestationPool: deps.attestationPool ?? new AttestationPool(attestationStore, telemetry),
|
|
112
137
|
};
|
|
113
138
|
|
|
114
|
-
const p2pService = await createP2PService
|
|
139
|
+
const p2pService = await createP2PService(
|
|
115
140
|
config,
|
|
116
|
-
clientType,
|
|
117
141
|
archiver,
|
|
118
142
|
proofVerifier,
|
|
119
143
|
worldStateSynchronizer,
|
|
120
144
|
epochCache,
|
|
145
|
+
blockMinFeesProvider,
|
|
121
146
|
store,
|
|
122
147
|
peerStore,
|
|
123
148
|
mempools,
|
|
@@ -127,9 +152,12 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
127
152
|
telemetry,
|
|
128
153
|
);
|
|
129
154
|
|
|
155
|
+
const txValidatorForTxCollection = createTxValidatorForReqResponseReceivedTxs(proofVerifier, config);
|
|
130
156
|
const nodeSources = [
|
|
131
|
-
...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, config),
|
|
132
|
-
...(deps.rpcTxProviders ?? []).map(
|
|
157
|
+
...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, txValidatorForTxCollection, config),
|
|
158
|
+
...(deps.rpcTxProviders ?? []).map(
|
|
159
|
+
(node, i) => new NodeRpcTxSource(node, txValidatorForTxCollection, `node-rpc-provider-${i}`),
|
|
160
|
+
),
|
|
133
161
|
...(deps.txCollectionNodeSources ?? []),
|
|
134
162
|
];
|
|
135
163
|
if (nodeSources.length > 0) {
|
|
@@ -141,6 +169,7 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
141
169
|
const fileStoreSources = await createFileStoreTxSources(
|
|
142
170
|
config.txCollectionFileStoreUrls,
|
|
143
171
|
txFileStoreBasePath,
|
|
172
|
+
txValidatorForTxCollection,
|
|
144
173
|
logger.createChild('file-store-tx-source'),
|
|
145
174
|
telemetry,
|
|
146
175
|
);
|
|
@@ -171,7 +200,6 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
171
200
|
);
|
|
172
201
|
|
|
173
202
|
return new P2PClient(
|
|
174
|
-
clientType,
|
|
175
203
|
store,
|
|
176
204
|
archiver,
|
|
177
205
|
mempools,
|
|
@@ -185,17 +213,17 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
185
213
|
);
|
|
186
214
|
}
|
|
187
215
|
|
|
188
|
-
async function createP2PService
|
|
216
|
+
async function createP2PService(
|
|
189
217
|
config: P2PConfig & DataStoreConfig,
|
|
190
|
-
clientType: T,
|
|
191
218
|
archiver: L2BlockSource & ContractDataSource,
|
|
192
219
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
193
220
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
194
221
|
epochCache: EpochCacheInterface,
|
|
222
|
+
blockMinFeesProvider: BlockMinFeesProvider,
|
|
195
223
|
store: AztecAsyncKVStore,
|
|
196
224
|
peerStore: AztecLMDBStoreV2,
|
|
197
225
|
mempools: MemPools,
|
|
198
|
-
p2pServiceFactory: P2PClientDeps
|
|
226
|
+
p2pServiceFactory: P2PClientDeps['p2pServiceFactory'],
|
|
199
227
|
packageVersion: string,
|
|
200
228
|
logger: Logger,
|
|
201
229
|
telemetry: TelemetryClient,
|
|
@@ -211,7 +239,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
211
239
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
|
|
212
240
|
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey.getValue());
|
|
213
241
|
|
|
214
|
-
const p2pService = await (p2pServiceFactory ?? LibP2PService.new
|
|
242
|
+
const p2pService = await (p2pServiceFactory ?? LibP2PService.new)(config, peerId, {
|
|
215
243
|
packageVersion,
|
|
216
244
|
mempools,
|
|
217
245
|
l2BlockSource: archiver,
|
|
@@ -219,6 +247,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
219
247
|
proofVerifier,
|
|
220
248
|
worldStateSynchronizer,
|
|
221
249
|
peerStore,
|
|
250
|
+
blockMinFeesProvider,
|
|
222
251
|
telemetry,
|
|
223
252
|
logger: logger.createChild(`libp2p_service`),
|
|
224
253
|
});
|
package/src/client/interface.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
|
|
3
|
-
import type { ITxProvider,
|
|
4
|
-
import type {
|
|
5
|
-
BlockProposal,
|
|
6
|
-
CheckpointAttestation,
|
|
7
|
-
CheckpointProposal,
|
|
8
|
-
P2PClientType,
|
|
9
|
-
TopicType,
|
|
10
|
-
} from '@aztec/stdlib/p2p';
|
|
3
|
+
import type { ITxProvider, P2PClient } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
|
|
11
5
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
12
6
|
|
|
13
7
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -54,7 +48,7 @@ export interface P2PSyncState {
|
|
|
54
48
|
/**
|
|
55
49
|
* Interface of a P2P client.
|
|
56
50
|
**/
|
|
57
|
-
export type P2P
|
|
51
|
+
export type P2P = P2PClient & {
|
|
58
52
|
/**
|
|
59
53
|
* Broadcasts a block proposal to other peers.
|
|
60
54
|
*
|
|
@@ -88,7 +82,15 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
88
82
|
*
|
|
89
83
|
* @param handler - A function taking a received checkpoint proposal and producing attestations
|
|
90
84
|
*/
|
|
91
|
-
|
|
85
|
+
registerValidatorCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Registers a callback that runs for ALL nodes (not just validators) when a checkpoint proposal is received.
|
|
89
|
+
* Used to set the proposed checkpoint number on the archiver so the sequencer can build on top of it.
|
|
90
|
+
*
|
|
91
|
+
* @param handler - A function taking a received checkpoint proposal
|
|
92
|
+
*/
|
|
93
|
+
registerAllNodesCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
|
|
92
94
|
|
|
93
95
|
/**
|
|
94
96
|
* Registers a callback invoked when a duplicate proposal is detected (equivocation).
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
3
2
|
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -9,6 +8,7 @@ import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
|
9
8
|
import {
|
|
10
9
|
type CheckpointId,
|
|
11
10
|
type EthAddress,
|
|
11
|
+
GENESIS_BLOCK_HEADER_HASH,
|
|
12
12
|
type L2Block,
|
|
13
13
|
type L2BlockId,
|
|
14
14
|
type L2BlockSource,
|
|
@@ -18,15 +18,8 @@ import {
|
|
|
18
18
|
type L2TipsStore,
|
|
19
19
|
} from '@aztec/stdlib/block';
|
|
20
20
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
21
|
-
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
22
21
|
import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
|
|
23
|
-
import {
|
|
24
|
-
type BlockProposal,
|
|
25
|
-
CheckpointAttestation,
|
|
26
|
-
type CheckpointProposal,
|
|
27
|
-
type P2PClientType,
|
|
28
|
-
type TopicType,
|
|
29
|
-
} from '@aztec/stdlib/p2p';
|
|
22
|
+
import { type BlockProposal, CheckpointAttestation, type CheckpointProposal, type TopicType } from '@aztec/stdlib/p2p';
|
|
30
23
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
31
24
|
import { Attributes, type TelemetryClient, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
32
25
|
|
|
@@ -59,10 +52,7 @@ import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
|
59
52
|
/**
|
|
60
53
|
* The P2P client implementation.
|
|
61
54
|
*/
|
|
62
|
-
export class P2PClient
|
|
63
|
-
extends WithTracer
|
|
64
|
-
implements P2P, P2P<P2PClientType.Prover>
|
|
65
|
-
{
|
|
55
|
+
export class P2PClient extends WithTracer implements P2P {
|
|
66
56
|
/** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */
|
|
67
57
|
private runningPromise!: Promise<void>;
|
|
68
58
|
|
|
@@ -94,7 +84,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
94
84
|
private slotMonitor: RunningPromise | undefined;
|
|
95
85
|
|
|
96
86
|
constructor(
|
|
97
|
-
_clientType: T,
|
|
98
87
|
private store: AztecAsyncKVStore,
|
|
99
88
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
100
89
|
mempools: MemPools,
|
|
@@ -121,27 +110,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
121
110
|
this.telemetry,
|
|
122
111
|
);
|
|
123
112
|
|
|
124
|
-
// Default to collecting all txs when we see a valid proposal
|
|
125
|
-
// This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
|
|
126
|
-
// Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
127
|
-
// TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
|
|
128
|
-
// validator-client code into here so we can validate a proposal is reasonable.
|
|
129
|
-
this.registerBlockProposalHandler(async (block, sender) => {
|
|
130
|
-
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
131
|
-
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
132
|
-
const constants = this.txCollection.getConstants();
|
|
133
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
134
|
-
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
135
|
-
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
|
|
136
|
-
if (!parentBlock) {
|
|
137
|
-
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
141
|
-
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
142
|
-
return true;
|
|
143
|
-
});
|
|
144
|
-
|
|
145
113
|
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
146
114
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
147
115
|
}
|
|
@@ -289,7 +257,11 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
289
257
|
});
|
|
290
258
|
}
|
|
291
259
|
|
|
292
|
-
|
|
260
|
+
// Should never happen: all branches above call initBlockStream()
|
|
261
|
+
if (!this.blockStream) {
|
|
262
|
+
throw new Error('Block stream not initialized');
|
|
263
|
+
}
|
|
264
|
+
this.blockStream.start();
|
|
293
265
|
await this.txCollection.start();
|
|
294
266
|
this.txFileStore?.start();
|
|
295
267
|
|
|
@@ -351,7 +323,11 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
351
323
|
/** Triggers a sync to the archiver. Used for testing. */
|
|
352
324
|
public async sync() {
|
|
353
325
|
this.initBlockStream();
|
|
354
|
-
|
|
326
|
+
// Should never happen: initBlockStream() creates blockStream if absent
|
|
327
|
+
if (!this.blockStream) {
|
|
328
|
+
throw new Error('Block stream not initialized');
|
|
329
|
+
}
|
|
330
|
+
await this.blockStream.sync();
|
|
355
331
|
}
|
|
356
332
|
|
|
357
333
|
@trackSpan('p2pClient.broadcastProposal', async proposal => ({
|
|
@@ -389,6 +365,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
389
365
|
// Store our own last-block proposal so we can respond to req/resp requests for it.
|
|
390
366
|
await this.attestationPool.tryAddBlockProposal(blockProposal);
|
|
391
367
|
}
|
|
368
|
+
// Gossipsub doesn't deliver own messages, so fire the all-nodes handler locally
|
|
369
|
+
await this.p2pService.notifyOwnCheckpointProposal(proposal.toCore());
|
|
392
370
|
return this.p2pService.propagate(proposal);
|
|
393
371
|
}
|
|
394
372
|
|
|
@@ -420,8 +398,12 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
420
398
|
this.p2pService.registerBlockReceivedCallback(handler);
|
|
421
399
|
}
|
|
422
400
|
|
|
423
|
-
public
|
|
424
|
-
this.p2pService.
|
|
401
|
+
public registerValidatorCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
|
|
402
|
+
this.p2pService.registerValidatorCheckpointReceivedCallback(handler);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
public registerAllNodesCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
|
|
406
|
+
this.p2pService.registerAllNodesCheckpointReceivedCallback(handler);
|
|
425
407
|
}
|
|
426
408
|
|
|
427
409
|
public registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void {
|
|
@@ -701,31 +683,50 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
701
683
|
}
|
|
702
684
|
|
|
703
685
|
/**
|
|
704
|
-
* Returns true if the prune
|
|
705
|
-
* If the
|
|
706
|
-
* If they differ, the prune spans across checkpoints (epoch prune).
|
|
686
|
+
* Returns true if the prune is an epoch prune (new checkpoint number is less than old).
|
|
687
|
+
* If the checkpoint number stays the same or increases, the prune is within a checkpoint.
|
|
707
688
|
*/
|
|
708
689
|
private async isEpochPrune(newCheckpoint: CheckpointId): Promise<boolean> {
|
|
709
690
|
const tips = await this.l2Tips.getL2Tips();
|
|
710
691
|
const oldCheckpointNumber = tips.checkpointed.checkpoint.number;
|
|
711
|
-
if (oldCheckpointNumber <= CheckpointNumber.
|
|
692
|
+
if (oldCheckpointNumber <= CheckpointNumber.INITIAL) {
|
|
712
693
|
return false;
|
|
713
694
|
}
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
695
|
+
const newCheckpointNumber = newCheckpoint.number;
|
|
696
|
+
// We check that the new checkpoint number is less than the old checkpoint number in order to consider it an epoch prune.
|
|
697
|
+
// To be more certain that it is an epoch prune, we will check that at least 2 checkpoints were removed.
|
|
698
|
+
// This means we should avoid thinking checkpoints removed by L1 re-orgs are epoch prunes
|
|
699
|
+
const thresholdForEpochPrune = CheckpointNumber(oldCheckpointNumber - 2);
|
|
700
|
+
const isEpochPrune = newCheckpointNumber <= thresholdForEpochPrune;
|
|
701
|
+
if (isEpochPrune) {
|
|
702
|
+
this.log.info(`Detected epoch prune to ${newCheckpointNumber}`, {
|
|
703
|
+
oldCheckpointNumber,
|
|
704
|
+
newCheckpointNumber,
|
|
705
|
+
thresholdForEpochPrune,
|
|
706
|
+
});
|
|
707
|
+
}
|
|
718
708
|
return isEpochPrune;
|
|
719
709
|
}
|
|
720
710
|
|
|
721
711
|
/** Checks if the slot has changed and calls prepareForSlot if so. */
|
|
722
712
|
private async maybeCallPrepareForSlot(): Promise<void> {
|
|
723
|
-
|
|
724
|
-
|
|
713
|
+
// If we have a proposed checkpoint available, we want to prepare the target slot - otherwise we prepare the current slot
|
|
714
|
+
const l2Tips = await this.l2Tips.getL2Tips();
|
|
715
|
+
const hasProposedCheckpoint = l2Tips.proposedCheckpoint.checkpoint.number > l2Tips.checkpointed.checkpoint.number;
|
|
716
|
+
|
|
717
|
+
let slot;
|
|
718
|
+
if (this.epochCache.isProposerPipeliningEnabled() && hasProposedCheckpoint) {
|
|
719
|
+
const { targetSlot } = this.epochCache.getTargetAndNextSlot();
|
|
720
|
+
slot = targetSlot;
|
|
721
|
+
} else {
|
|
722
|
+
const { currentSlot } = this.epochCache.getCurrentAndNextSlot();
|
|
723
|
+
slot = currentSlot;
|
|
724
|
+
}
|
|
725
|
+
if (slot <= this.lastSlotProcessed) {
|
|
725
726
|
return;
|
|
726
727
|
}
|
|
727
|
-
this.lastSlotProcessed =
|
|
728
|
-
await this.txPool.prepareForSlot(
|
|
728
|
+
this.lastSlotProcessed = slot;
|
|
729
|
+
await this.txPool.prepareForSlot(slot);
|
|
729
730
|
}
|
|
730
731
|
|
|
731
732
|
private async startServiceIfSynched() {
|
|
@@ -3,12 +3,13 @@ import { SecretValue } from '@aztec/foundation/config';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
5
5
|
import { DateProvider, Timer, executeTimeout } from '@aztec/foundation/timer';
|
|
6
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
7
6
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
8
7
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
8
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
9
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
10
10
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import {
|
|
11
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
12
|
+
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
12
13
|
import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
|
|
13
14
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
15
|
|
|
@@ -19,7 +20,7 @@ import type { P2PConfig } from '../../../config.js';
|
|
|
19
20
|
import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../../../services/index.js';
|
|
20
21
|
import type { IBatchRequestTxValidator } from '../../../services/reqresp/batch-tx-requester/tx_validator.js';
|
|
21
22
|
import { RateLimitStatus } from '../../../services/reqresp/rate-limiter/rate_limiter.js';
|
|
22
|
-
import {
|
|
23
|
+
import { RequestTracker } from '../../../services/tx_collection/request_tracker.js';
|
|
23
24
|
import {
|
|
24
25
|
AlwaysTrueCircuitVerifier,
|
|
25
26
|
BENCHMARK_CONSTANTS,
|
|
@@ -114,12 +115,12 @@ async function startClient(config: P2PConfig, clientIndex: number) {
|
|
|
114
115
|
};
|
|
115
116
|
|
|
116
117
|
client = await createP2PClient(
|
|
117
|
-
P2PClientType.Full,
|
|
118
118
|
config as P2PConfig & DataStoreConfig,
|
|
119
119
|
l2BlockSource as L2BlockSource & ContractDataSource,
|
|
120
120
|
proofVerifier as ClientProtocolCircuitVerifier,
|
|
121
121
|
worldState,
|
|
122
122
|
epochCache,
|
|
123
|
+
{ getCurrentMinFees: () => Promise.resolve(GasFees.empty()) },
|
|
123
124
|
'proposal-tx-collector-bench-worker',
|
|
124
125
|
new DateProvider(),
|
|
125
126
|
telemetry as TelemetryClient,
|
|
@@ -214,10 +215,9 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
|
|
|
214
215
|
const fetched = await executeTimeout(
|
|
215
216
|
(_signal: AbortSignal) =>
|
|
216
217
|
collector.collectTxs(
|
|
217
|
-
|
|
218
|
+
RequestTracker.create(parsedTxHashes, new Date(Date.now() + internalTimeoutMs)),
|
|
218
219
|
parsedProposal,
|
|
219
220
|
pinnedPeer,
|
|
220
|
-
internalTimeoutMs,
|
|
221
221
|
),
|
|
222
222
|
timeoutMs,
|
|
223
223
|
() => new Error(`Collector timed out after ${timeoutMs}ms`),
|
|
@@ -232,10 +232,9 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
|
|
|
232
232
|
const fetched = await executeTimeout(
|
|
233
233
|
(_signal: AbortSignal) =>
|
|
234
234
|
collector.collectTxs(
|
|
235
|
-
|
|
235
|
+
RequestTracker.create(parsedTxHashes, new Date(Date.now() + internalTimeoutMs)),
|
|
236
236
|
parsedProposal,
|
|
237
237
|
pinnedPeer,
|
|
238
|
-
internalTimeoutMs,
|
|
239
238
|
),
|
|
240
239
|
timeoutMs,
|
|
241
240
|
() => new Error(`Collector timed out after ${timeoutMs}ms`),
|
|
@@ -262,9 +261,20 @@ async function stopClient() {
|
|
|
262
261
|
attestationPool = undefined;
|
|
263
262
|
}
|
|
264
263
|
|
|
264
|
+
function gracefulExit(code: number = 0) {
|
|
265
|
+
try {
|
|
266
|
+
if (process.connected) {
|
|
267
|
+
process.disconnect();
|
|
268
|
+
}
|
|
269
|
+
} catch {
|
|
270
|
+
// IPC channel already closed
|
|
271
|
+
}
|
|
272
|
+
setTimeout(() => process.exit(code), 5000).unref();
|
|
273
|
+
}
|
|
274
|
+
|
|
265
275
|
process.on('disconnect', () => {
|
|
266
276
|
ipcDisconnected = true;
|
|
267
|
-
void stopClient()
|
|
277
|
+
void stopClient();
|
|
268
278
|
});
|
|
269
279
|
|
|
270
280
|
process.on('error', err => {
|
|
@@ -328,7 +338,7 @@ process.on('message', (msg: WorkerCommand) => {
|
|
|
328
338
|
case 'STOP': {
|
|
329
339
|
await stopClient();
|
|
330
340
|
await sendMessage({ type: 'STOPPED', requestId });
|
|
331
|
-
|
|
341
|
+
gracefulExit(0);
|
|
332
342
|
break;
|
|
333
343
|
}
|
|
334
344
|
default: {
|
|
@@ -339,7 +349,8 @@ process.on('message', (msg: WorkerCommand) => {
|
|
|
339
349
|
} catch (err: any) {
|
|
340
350
|
await sendMessage({ type: 'ERROR', requestId, error: err?.message ?? String(err) });
|
|
341
351
|
if (msg.type === 'START') {
|
|
342
|
-
|
|
352
|
+
await stopClient();
|
|
353
|
+
gracefulExit(1);
|
|
343
354
|
}
|
|
344
355
|
}
|
|
345
356
|
})();
|