@aztec/p2p 0.0.1-commit.64b6bbb → 0.0.1-commit.684755437
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/factory.d.ts +7 -7
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +24 -30
- package/dest/client/interface.d.ts +14 -19
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +9 -18
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +52 -96
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
- package/dest/config.d.ts +31 -15
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +71 -37
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +4 -2
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +10 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- 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 +16 -14
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +30 -13
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +91 -20
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- 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 +5 -2
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
- 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 +12 -4
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
- 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 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +54 -5
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +14 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
- 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 +16 -4
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
- 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 +3 -3
- 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/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +22 -6
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +5 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +48 -14
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +100 -17
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
- 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 +50 -45
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +9 -4
- 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 +14 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +14 -5
- 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 +300 -142
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -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 +6 -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 +13 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +48 -36
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- 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/factory.d.ts +114 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +219 -58
- 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 +58 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +73 -36
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +44 -23
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/dummy_service.d.ts +4 -4
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +4 -4
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +9 -8
- package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +32 -10
- package/dest/services/libp2p/libp2p_service.d.ts +16 -13
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +84 -90
- 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 +1 -1
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +2 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -3
- 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 +19 -46
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -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 +10 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +17 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +49 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +2 -1
- package/dest/services/service.d.ts +5 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +13 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +30 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +39 -33
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +38 -29
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +126 -77
- package/dest/services/tx_collection/file_store_tx_source.d.ts +16 -6
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +49 -16
- 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 +2 -1
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -6
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
- package/dest/services/tx_collection/slow_tx_collection.d.ts +5 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +17 -12
- package/dest/services/tx_collection/tx_collection.d.ts +9 -6
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +26 -10
- package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +13 -22
- package/dest/services/tx_collection/tx_source.d.ts +8 -3
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +19 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts +3 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +9 -6
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +4 -4
- 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 +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +4 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +8 -2
- 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 +2 -2
- package/dest/test-helpers/testbench-utils.d.ts +8 -3
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +7 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +15 -14
- package/dest/testbench/worker_client_manager.d.ts +3 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +6 -2
- package/dest/util.d.ts +3 -3
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +41 -49
- package/src/client/interface.ts +17 -20
- package/src/client/p2p_client.ts +60 -126
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +20 -11
- package/src/config.ts +100 -43
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +13 -4
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/instrumentation.ts +17 -13
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/README.md +52 -28
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +109 -22
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +5 -2
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +59 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -9
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +33 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +4 -3
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +24 -6
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +145 -25
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +58 -45
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +21 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +333 -138
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +14 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +20 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +63 -40
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -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/factory.ts +353 -77
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +90 -27
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +51 -26
- package/src/msg_validators/tx_validator/timestamp_validator.ts +7 -7
- package/src/services/dummy_service.ts +6 -6
- package/src/services/encoding.ts +7 -7
- package/src/services/gossipsub/README.md +29 -14
- package/src/services/gossipsub/topic_score_params.ts +49 -13
- package/src/services/libp2p/libp2p_service.ts +95 -96
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +2 -1
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +20 -48
- package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +63 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/reqresp.ts +3 -1
- package/src/services/service.ts +11 -2
- package/src/services/tx_collection/config.ts +42 -0
- package/src/services/tx_collection/fast_tx_collection.ts +51 -30
- package/src/services/tx_collection/file_store_tx_collection.ts +143 -93
- package/src/services/tx_collection/file_store_tx_source.ts +64 -17
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -7
- package/src/services/tx_collection/slow_tx_collection.ts +17 -13
- package/src/services/tx_collection/tx_collection.ts +45 -14
- package/src/services/tx_collection/tx_collection_sink.ts +15 -29
- package/src/services/tx_collection/tx_source.ts +22 -3
- package/src/services/tx_file_store/tx_file_store.ts +6 -4
- package/src/services/tx_provider.ts +2 -2
- package/src/test-helpers/make-test-p2p-clients.ts +1 -3
- package/src/test-helpers/mock-pubsub.ts +13 -6
- package/src/test-helpers/reqresp-nodes.ts +3 -6
- package/src/test-helpers/testbench-utils.ts +11 -3
- package/src/testbench/p2p_client_testbench_worker.ts +24 -20
- package/src/testbench/worker_client_manager.ts +13 -5
- package/src/util.ts +8 -2
- 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/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
package/src/client/p2p_client.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
2
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
3
|
-
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { RunningPromise } from '@aztec/foundation/promise';
|
|
6
6
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
7
7
|
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
8
8
|
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
9
9
|
import {
|
|
10
|
+
type CheckpointId,
|
|
10
11
|
type EthAddress,
|
|
11
12
|
type L2Block,
|
|
12
13
|
type L2BlockId,
|
|
@@ -17,14 +18,8 @@ import {
|
|
|
17
18
|
type L2TipsStore,
|
|
18
19
|
} from '@aztec/stdlib/block';
|
|
19
20
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
20
|
-
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
21
21
|
import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
|
|
22
|
-
import {
|
|
23
|
-
type BlockProposal,
|
|
24
|
-
CheckpointAttestation,
|
|
25
|
-
type CheckpointProposal,
|
|
26
|
-
type P2PClientType,
|
|
27
|
-
} from '@aztec/stdlib/p2p';
|
|
22
|
+
import { type BlockProposal, CheckpointAttestation, type CheckpointProposal, type TopicType } from '@aztec/stdlib/p2p';
|
|
28
23
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
29
24
|
import { Attributes, type TelemetryClient, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
30
25
|
|
|
@@ -32,6 +27,7 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
32
27
|
import type { ENR } from '@nethermindeth/enr';
|
|
33
28
|
|
|
34
29
|
import { type P2PConfig, getP2PDefaultConfig } from '../config.js';
|
|
30
|
+
import { TxPoolError } from '../errors/tx-pool.error.js';
|
|
35
31
|
import type { AttestationPoolApi } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
36
32
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
37
33
|
import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
@@ -41,7 +37,6 @@ import {
|
|
|
41
37
|
type ReqRespSubProtocolHandler,
|
|
42
38
|
type ReqRespSubProtocolValidators,
|
|
43
39
|
} from '../services/reqresp/interface.js';
|
|
44
|
-
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
45
40
|
import type {
|
|
46
41
|
DuplicateAttestationInfo,
|
|
47
42
|
DuplicateProposalInfo,
|
|
@@ -57,10 +52,7 @@ import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
|
57
52
|
/**
|
|
58
53
|
* The P2P client implementation.
|
|
59
54
|
*/
|
|
60
|
-
export class P2PClient
|
|
61
|
-
extends WithTracer
|
|
62
|
-
implements P2P, P2P<P2PClientType.Prover>
|
|
63
|
-
{
|
|
55
|
+
export class P2PClient extends WithTracer implements P2P {
|
|
64
56
|
/** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */
|
|
65
57
|
private runningPromise!: Promise<void>;
|
|
66
58
|
|
|
@@ -92,7 +84,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
92
84
|
private slotMonitor: RunningPromise | undefined;
|
|
93
85
|
|
|
94
86
|
constructor(
|
|
95
|
-
_clientType: T,
|
|
96
87
|
private store: AztecAsyncKVStore,
|
|
97
88
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
98
89
|
mempools: MemPools,
|
|
@@ -119,27 +110,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
119
110
|
this.telemetry,
|
|
120
111
|
);
|
|
121
112
|
|
|
122
|
-
// Default to collecting all txs when we see a valid proposal
|
|
123
|
-
// This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
|
|
124
|
-
// Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
125
|
-
// TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
|
|
126
|
-
// validator-client code into here so we can validate a proposal is reasonable.
|
|
127
|
-
this.registerBlockProposalHandler(async (block, sender) => {
|
|
128
|
-
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
129
|
-
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
130
|
-
const constants = this.txCollection.getConstants();
|
|
131
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
132
|
-
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
133
|
-
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
|
|
134
|
-
if (!parentBlock) {
|
|
135
|
-
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
139
|
-
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
140
|
-
return true;
|
|
141
|
-
});
|
|
142
|
-
|
|
143
113
|
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
144
114
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
145
115
|
}
|
|
@@ -165,6 +135,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
165
135
|
return Promise.resolve(this.p2pService.getPeers(includePending));
|
|
166
136
|
}
|
|
167
137
|
|
|
138
|
+
public getGossipMeshPeerCount(topicType: TopicType): Promise<number> {
|
|
139
|
+
return Promise.resolve(this.p2pService.getGossipMeshPeerCount(topicType));
|
|
140
|
+
}
|
|
141
|
+
|
|
168
142
|
public getL2BlockHash(number: BlockNumber): Promise<string | undefined> {
|
|
169
143
|
return this.l2Tips.getL2BlockHash(number);
|
|
170
144
|
}
|
|
@@ -200,7 +174,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
200
174
|
break;
|
|
201
175
|
case 'chain-pruned':
|
|
202
176
|
this.txCollection.stopCollectingForBlocksAfter(event.block.number);
|
|
203
|
-
await this.handlePruneL2Blocks(event.block);
|
|
177
|
+
await this.handlePruneL2Blocks(event.block, event.checkpoint);
|
|
204
178
|
break;
|
|
205
179
|
case 'chain-checkpointed':
|
|
206
180
|
break;
|
|
@@ -404,6 +378,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
404
378
|
return this.attestationPool.addOwnCheckpointAttestations(attestations);
|
|
405
379
|
}
|
|
406
380
|
|
|
381
|
+
public hasBlockProposalsForSlot(slot: SlotNumber): Promise<boolean> {
|
|
382
|
+
return this.attestationPool.hasBlockProposalsForSlot(slot);
|
|
383
|
+
}
|
|
384
|
+
|
|
407
385
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
408
386
|
// ^ This pattern is not my favorite (md)
|
|
409
387
|
public registerBlockProposalHandler(handler: P2PBlockReceivedCallback): void {
|
|
@@ -422,36 +400,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
422
400
|
this.p2pService.registerDuplicateAttestationCallback(callback);
|
|
423
401
|
}
|
|
424
402
|
|
|
425
|
-
/**
|
|
426
|
-
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
427
|
-
*/
|
|
428
|
-
private async requestTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<Tx[]> {
|
|
429
|
-
const timeoutMs = 8000; // Longer timeout for now
|
|
430
|
-
const maxRetryAttempts = 10; // Keep retrying within the timeout
|
|
431
|
-
const requests = chunkTxHashesRequest(txHashes);
|
|
432
|
-
const maxPeers = Math.min(Math.ceil(requests.length / 3), 10);
|
|
433
|
-
|
|
434
|
-
const txBatches = await this.p2pService.sendBatchRequest(
|
|
435
|
-
ReqRespSubProtocol.TX,
|
|
436
|
-
requests,
|
|
437
|
-
pinnedPeerId,
|
|
438
|
-
timeoutMs,
|
|
439
|
-
maxPeers,
|
|
440
|
-
maxRetryAttempts,
|
|
441
|
-
);
|
|
442
|
-
|
|
443
|
-
const txs = txBatches.flat();
|
|
444
|
-
if (txs.length > 0) {
|
|
445
|
-
await this.txPool.addPendingTxs(txs);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
const txHashesStr = txHashes.map(tx => tx.toString()).join(', ');
|
|
449
|
-
this.log.debug(`Requested txs ${txHashesStr} (${txs.length} / ${txHashes.length}) from peers`);
|
|
450
|
-
|
|
451
|
-
// We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
|
|
452
|
-
return txs;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
403
|
public async getPendingTxs(limit?: number, after?: TxHash): Promise<Tx[]> {
|
|
456
404
|
if (limit !== undefined && limit <= 0) {
|
|
457
405
|
throw new TypeError('limit must be greater than 0');
|
|
@@ -488,6 +436,15 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
488
436
|
}
|
|
489
437
|
}
|
|
490
438
|
|
|
439
|
+
public async *iterateEligiblePendingTxs(): AsyncIterableIterator<Tx> {
|
|
440
|
+
for (const txHash of await this.txPool.getEligiblePendingTxHashes()) {
|
|
441
|
+
const tx = await this.txPool.getTxByHash(txHash);
|
|
442
|
+
if (tx) {
|
|
443
|
+
yield tx;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
491
448
|
/**
|
|
492
449
|
* Returns a transaction in the transaction pool by its hash.
|
|
493
450
|
* @param txHash - Hash of the transaction to look for in the pool.
|
|
@@ -510,49 +467,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
510
467
|
return this.txPool.hasTxs(txHashes);
|
|
511
468
|
}
|
|
512
469
|
|
|
513
|
-
/**
|
|
514
|
-
* Returns transactions in the transaction pool by hash.
|
|
515
|
-
* If a transaction is not in the pool, it will be requested from the network.
|
|
516
|
-
* @param txHashes - Hashes of the transactions to look for.
|
|
517
|
-
* @returns The txs found, or undefined if not found in the order requested.
|
|
518
|
-
*/
|
|
519
|
-
async getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]> {
|
|
520
|
-
const txs = await Promise.all(txHashes.map(txHash => this.txPool.getTxByHash(txHash)));
|
|
521
|
-
const missingTxHashes = txs
|
|
522
|
-
.map((tx, index) => [tx, index] as const)
|
|
523
|
-
.filter(([tx, _index]) => !tx)
|
|
524
|
-
.map(([_tx, index]) => txHashes[index]);
|
|
525
|
-
|
|
526
|
-
if (missingTxHashes.length === 0) {
|
|
527
|
-
return txs as Tx[];
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
const missingTxs = await this.requestTxsByHash(missingTxHashes, pinnedPeerId);
|
|
531
|
-
// TODO: optimize
|
|
532
|
-
// Merge the found txs in order
|
|
533
|
-
const mergingTxs = txHashes.map(txHash => {
|
|
534
|
-
// Is it in the txs list from the mempool?
|
|
535
|
-
for (const tx of txs) {
|
|
536
|
-
if (tx !== undefined && tx.getTxHash().equals(txHash)) {
|
|
537
|
-
return tx;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// Is it in the fetched missing txs?
|
|
542
|
-
// Note: this is an O(n^2) operation, but we expect the number of missing txs to be small.
|
|
543
|
-
for (const tx of missingTxs) {
|
|
544
|
-
if (tx.getTxHash().equals(txHash)) {
|
|
545
|
-
return tx;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// Otherwise return undefined
|
|
550
|
-
return undefined;
|
|
551
|
-
});
|
|
552
|
-
|
|
553
|
-
return mergingTxs;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
470
|
/**
|
|
557
471
|
* Returns an archived transaction in the transaction pool by its hash.
|
|
558
472
|
* @param txHash - Hash of the archived transaction to look for.
|
|
@@ -569,23 +483,22 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
569
483
|
**/
|
|
570
484
|
public async sendTx(tx: Tx): Promise<void> {
|
|
571
485
|
this.#assertIsReady();
|
|
572
|
-
const result = await this.txPool.addPendingTxs([tx]);
|
|
486
|
+
const result = await this.txPool.addPendingTxs([tx], { feeComparisonOnly: true });
|
|
573
487
|
if (result.accepted.length === 1) {
|
|
574
488
|
await this.p2pService.propagate(tx);
|
|
575
|
-
|
|
576
|
-
this.log.warn(
|
|
577
|
-
`Tx ${tx.getTxHash()} not propagated: accepted=${result.accepted.length} ignored=${result.ignored.length} rejected=${result.rejected.length}`,
|
|
578
|
-
);
|
|
489
|
+
return;
|
|
579
490
|
}
|
|
580
|
-
}
|
|
581
491
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
492
|
+
const txHashStr = tx.getTxHash().toString();
|
|
493
|
+
const reason = result.errors?.get(txHashStr);
|
|
494
|
+
if (reason) {
|
|
495
|
+
this.log.warn(`Tx ${txHashStr} not added to pool: ${reason.message}`);
|
|
496
|
+
throw new TxPoolError(reason);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
this.log.warn(
|
|
500
|
+
`Tx ${txHashStr} not propagated: accepted=${result.accepted.length} ignored=${result.ignored.length} rejected=${result.rejected.length}`,
|
|
501
|
+
);
|
|
589
502
|
}
|
|
590
503
|
|
|
591
504
|
/**
|
|
@@ -746,10 +659,31 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
746
659
|
|
|
747
660
|
/**
|
|
748
661
|
* Updates the tx pool after a chain prune.
|
|
662
|
+
* Detects epoch prunes (checkpoint number changed) and deletes all txs in that case.
|
|
749
663
|
* @param latestBlock - The block ID the chain was pruned to.
|
|
664
|
+
* @param newCheckpoint - The checkpoint ID after the prune.
|
|
750
665
|
*/
|
|
751
|
-
private async handlePruneL2Blocks(latestBlock: L2BlockId): Promise<void> {
|
|
752
|
-
|
|
666
|
+
private async handlePruneL2Blocks(latestBlock: L2BlockId, newCheckpoint: CheckpointId): Promise<void> {
|
|
667
|
+
const deleteAllTxs = this.config.txPoolDeleteTxsAfterReorg && (await this.isEpochPrune(newCheckpoint));
|
|
668
|
+
await this.txPool.handlePrunedBlocks(latestBlock, { deleteAllTxs });
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Returns true if the prune crossed a checkpoint boundary.
|
|
673
|
+
* If the old and new checkpoint numbers are the same, the prune is within a single checkpoint.
|
|
674
|
+
* If they differ, the prune spans across checkpoints (epoch prune).
|
|
675
|
+
*/
|
|
676
|
+
private async isEpochPrune(newCheckpoint: CheckpointId): Promise<boolean> {
|
|
677
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
678
|
+
const oldCheckpointNumber = tips.checkpointed.checkpoint.number;
|
|
679
|
+
if (oldCheckpointNumber <= CheckpointNumber.ZERO) {
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
const isEpochPrune = oldCheckpointNumber !== newCheckpoint.number;
|
|
683
|
+
this.log.info(
|
|
684
|
+
`Detected epoch prune: ${isEpochPrune}. Old checkpoint: ${oldCheckpointNumber}, new checkpoint: ${newCheckpoint.number}`,
|
|
685
|
+
);
|
|
686
|
+
return isEpochPrune;
|
|
753
687
|
}
|
|
754
688
|
|
|
755
689
|
/** Checks if the slot has changed and calls prepareForSlot if so. */
|
|
@@ -799,8 +733,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
799
733
|
this.log.debug(`Moved from state ${P2PClientState[oldState]} to ${P2PClientState[this.currentState]}`);
|
|
800
734
|
}
|
|
801
735
|
|
|
802
|
-
public
|
|
803
|
-
return this.p2pService.
|
|
736
|
+
public validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void> {
|
|
737
|
+
return this.p2pService.validateTxsReceivedInBlockProposal(txs);
|
|
804
738
|
}
|
|
805
739
|
|
|
806
740
|
/**
|
|
@@ -3,12 +3,12 @@ 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';
|
|
10
9
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import {
|
|
10
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
11
|
+
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
12
12
|
import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
|
|
13
13
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
14
|
|
|
@@ -16,14 +16,12 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
16
16
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
17
17
|
|
|
18
18
|
import type { P2PConfig } from '../../../config.js';
|
|
19
|
+
import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../../../services/index.js';
|
|
19
20
|
import type { IBatchRequestTxValidator } from '../../../services/reqresp/batch-tx-requester/tx_validator.js';
|
|
20
21
|
import { RateLimitStatus } from '../../../services/reqresp/rate-limiter/rate_limiter.js';
|
|
22
|
+
import { MissingTxsTracker } from '../../../services/tx_collection/missing_txs_tracker.js';
|
|
21
23
|
import {
|
|
22
|
-
|
|
23
|
-
SendBatchRequestCollector,
|
|
24
|
-
} from '../../../services/tx_collection/proposal_tx_collector.js';
|
|
25
|
-
import { AlwaysTrueCircuitVerifier } from '../../../test-helpers/reqresp-nodes.js';
|
|
26
|
-
import {
|
|
24
|
+
AlwaysTrueCircuitVerifier,
|
|
27
25
|
BENCHMARK_CONSTANTS,
|
|
28
26
|
InMemoryAttestationPool,
|
|
29
27
|
InMemoryTxPool,
|
|
@@ -31,7 +29,7 @@ import {
|
|
|
31
29
|
calculateInternalTimeout,
|
|
32
30
|
createMockEpochCache,
|
|
33
31
|
createMockWorldStateSynchronizer,
|
|
34
|
-
} from '../../../test-helpers/
|
|
32
|
+
} from '../../../test-helpers/index.js';
|
|
35
33
|
import { createP2PClient } from '../../index.js';
|
|
36
34
|
import type { P2PClient } from '../../p2p_client.js';
|
|
37
35
|
import {
|
|
@@ -116,7 +114,6 @@ async function startClient(config: P2PConfig, clientIndex: number) {
|
|
|
116
114
|
};
|
|
117
115
|
|
|
118
116
|
client = await createP2PClient(
|
|
119
|
-
P2PClientType.Full,
|
|
120
117
|
config as P2PConfig & DataStoreConfig,
|
|
121
118
|
l2BlockSource as L2BlockSource & ContractDataSource,
|
|
122
119
|
proofVerifier as ClientProtocolCircuitVerifier,
|
|
@@ -214,7 +211,13 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
|
|
|
214
211
|
if (collectorType === 'batch-requester') {
|
|
215
212
|
const collector = new BatchTxRequesterCollector(p2pService, logger, new DateProvider(), noopTxValidator);
|
|
216
213
|
const fetched = await executeTimeout(
|
|
217
|
-
(_signal: AbortSignal) =>
|
|
214
|
+
(_signal: AbortSignal) =>
|
|
215
|
+
collector.collectTxs(
|
|
216
|
+
MissingTxsTracker.fromArray(parsedTxHashes),
|
|
217
|
+
parsedProposal,
|
|
218
|
+
pinnedPeer,
|
|
219
|
+
internalTimeoutMs,
|
|
220
|
+
),
|
|
218
221
|
timeoutMs,
|
|
219
222
|
() => new Error(`Collector timed out after ${timeoutMs}ms`),
|
|
220
223
|
);
|
|
@@ -226,7 +229,13 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
|
|
|
226
229
|
BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS,
|
|
227
230
|
);
|
|
228
231
|
const fetched = await executeTimeout(
|
|
229
|
-
(_signal: AbortSignal) =>
|
|
232
|
+
(_signal: AbortSignal) =>
|
|
233
|
+
collector.collectTxs(
|
|
234
|
+
MissingTxsTracker.fromArray(parsedTxHashes),
|
|
235
|
+
parsedProposal,
|
|
236
|
+
pinnedPeer,
|
|
237
|
+
internalTimeoutMs,
|
|
238
|
+
),
|
|
230
239
|
timeoutMs,
|
|
231
240
|
() => new Error(`Collector timed out after ${timeoutMs}ms`),
|
|
232
241
|
);
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
SecretValue,
|
|
4
|
+
bigintConfigHelper,
|
|
4
5
|
booleanConfigHelper,
|
|
5
6
|
getConfigFromMappings,
|
|
6
7
|
getDefaultConfig,
|
|
@@ -10,7 +11,6 @@ import {
|
|
|
10
11
|
secretStringConfigHelper,
|
|
11
12
|
} from '@aztec/foundation/config';
|
|
12
13
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
14
14
|
import { FunctionSelector } from '@aztec/stdlib/abi/function-selector';
|
|
15
15
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
16
16
|
import {
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
chainConfigMappings,
|
|
21
21
|
sharedSequencerConfigMappings,
|
|
22
22
|
} from '@aztec/stdlib/config';
|
|
23
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
23
24
|
|
|
24
25
|
import {
|
|
25
26
|
type BatchTxRequesterConfig,
|
|
@@ -38,7 +39,10 @@ export interface P2PConfig
|
|
|
38
39
|
ChainConfig,
|
|
39
40
|
TxCollectionConfig,
|
|
40
41
|
TxFileStoreConfig,
|
|
41
|
-
Pick<SequencerConfig, 'blockDurationMs'> {
|
|
42
|
+
Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock'> {
|
|
43
|
+
/** Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set. */
|
|
44
|
+
validateMaxTxsPerBlock?: number;
|
|
45
|
+
|
|
42
46
|
/** A flag dictating whether the P2P subsystem should be enabled. */
|
|
43
47
|
p2pEnabled: boolean;
|
|
44
48
|
|
|
@@ -150,8 +154,8 @@ export interface P2PConfig
|
|
|
150
154
|
/** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
|
|
151
155
|
p2pStoreMapSizeKb?: number;
|
|
152
156
|
|
|
153
|
-
/**
|
|
154
|
-
|
|
157
|
+
/** Additional entries to extend the default setup allow list. */
|
|
158
|
+
txPublicSetupAllowListExtend: AllowedElement[];
|
|
155
159
|
|
|
156
160
|
/** The maximum number of pending txs before evicting lower priority txs. */
|
|
157
161
|
maxPendingTxCount: number;
|
|
@@ -173,10 +177,7 @@ export interface P2PConfig
|
|
|
173
177
|
/** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
|
|
174
178
|
disableTransactions: boolean;
|
|
175
179
|
|
|
176
|
-
/**
|
|
177
|
-
dropTransactions: boolean;
|
|
178
|
-
|
|
179
|
-
/** The probability that a transaction is discarded. - For testing purposes only */
|
|
180
|
+
/** The probability that a transaction is discarded (0 = disabled). - For testing purposes only */
|
|
180
181
|
dropTransactionsProbability: number;
|
|
181
182
|
|
|
182
183
|
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
@@ -190,11 +191,23 @@ export interface P2PConfig
|
|
|
190
191
|
|
|
191
192
|
/** Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only). */
|
|
192
193
|
broadcastEquivocatedProposals?: boolean;
|
|
194
|
+
|
|
195
|
+
/** Minimum age (ms) a transaction must have been in the pool before it's eligible for block building. */
|
|
196
|
+
minTxPoolAgeMs: number;
|
|
197
|
+
|
|
198
|
+
/** Minimum percentage fee increase required to replace an existing tx via RPC (0 = no bump). */
|
|
199
|
+
priceBumpPercentage: bigint;
|
|
193
200
|
}
|
|
194
201
|
|
|
195
202
|
export const DEFAULT_P2P_PORT = 40400;
|
|
196
203
|
|
|
197
204
|
export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
205
|
+
validateMaxTxsPerBlock: {
|
|
206
|
+
env: 'VALIDATOR_MAX_TX_PER_BLOCK',
|
|
207
|
+
description:
|
|
208
|
+
'Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set.',
|
|
209
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
210
|
+
},
|
|
198
211
|
p2pEnabled: {
|
|
199
212
|
env: 'P2P_ENABLED',
|
|
200
213
|
description: 'A flag dictating whether the P2P subsystem should be enabled.',
|
|
@@ -393,12 +406,13 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
393
406
|
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
394
407
|
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
395
408
|
},
|
|
396
|
-
|
|
409
|
+
txPublicSetupAllowListExtend: {
|
|
397
410
|
env: 'TX_PUBLIC_SETUP_ALLOWLIST',
|
|
398
411
|
parseEnv: (val: string) => parseAllowList(val),
|
|
399
|
-
description:
|
|
412
|
+
description:
|
|
413
|
+
'Additional entries to extend the default setup allow list. Format: I:address:selector[:flags],C:classId:selector[:flags]. Flags: os (onlySelf), rn (rejectNullMsgSender), cl=N (calldataLength), joined with +.',
|
|
400
414
|
printDefault: () =>
|
|
401
|
-
'AuthRegistry
|
|
415
|
+
'Default: AuthRegistry._set_authorized, AuthRegistry.set_authorized, FeeJuice._increase_public_balance',
|
|
402
416
|
},
|
|
403
417
|
maxPendingTxCount: {
|
|
404
418
|
env: 'P2P_MAX_PENDING_TX_COUNT',
|
|
@@ -427,11 +441,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
427
441
|
description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
|
|
428
442
|
...numberConfigHelper(3),
|
|
429
443
|
},
|
|
430
|
-
dropTransactions: {
|
|
431
|
-
env: 'P2P_DROP_TX',
|
|
432
|
-
description: 'True to simulate discarding transactions. - For testing purposes only',
|
|
433
|
-
...booleanConfigHelper(false),
|
|
434
|
-
},
|
|
435
444
|
dropTransactionsProbability: {
|
|
436
445
|
env: 'P2P_DROP_TX_CHANCE',
|
|
437
446
|
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
@@ -464,6 +473,17 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
464
473
|
'Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only).',
|
|
465
474
|
...booleanConfigHelper(false),
|
|
466
475
|
},
|
|
476
|
+
minTxPoolAgeMs: {
|
|
477
|
+
env: 'P2P_MIN_TX_POOL_AGE_MS',
|
|
478
|
+
description: 'Minimum age (ms) a transaction must have been in the pool before it is eligible for block building.',
|
|
479
|
+
...numberConfigHelper(2_000),
|
|
480
|
+
},
|
|
481
|
+
priceBumpPercentage: {
|
|
482
|
+
env: 'P2P_RPC_PRICE_BUMP_PERCENTAGE',
|
|
483
|
+
description:
|
|
484
|
+
'Minimum percentage fee increase required to replace an existing tx via RPC. Even at 0%, replacement still requires paying at least 1 unit more.',
|
|
485
|
+
...bigintConfigHelper(10n),
|
|
486
|
+
},
|
|
467
487
|
...sharedSequencerConfigMappings,
|
|
468
488
|
...p2pReqRespConfigMappings,
|
|
469
489
|
...batchTxRequesterConfigMappings,
|
|
@@ -521,13 +541,44 @@ export const bootnodeConfigMappings = pickConfigMappings(
|
|
|
521
541
|
bootnodeConfigKeys,
|
|
522
542
|
);
|
|
523
543
|
|
|
544
|
+
/**
|
|
545
|
+
* Parses a `+`-separated flags string into validation properties for an allow list entry.
|
|
546
|
+
* Supported flags: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
|
|
547
|
+
*/
|
|
548
|
+
function parseFlags(
|
|
549
|
+
flags: string,
|
|
550
|
+
entry: string,
|
|
551
|
+
): { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } {
|
|
552
|
+
const result: { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } = {};
|
|
553
|
+
for (const flag of flags.split('+')) {
|
|
554
|
+
if (flag === 'os') {
|
|
555
|
+
result.onlySelf = true;
|
|
556
|
+
} else if (flag === 'rn') {
|
|
557
|
+
result.rejectNullMsgSender = true;
|
|
558
|
+
} else if (flag.startsWith('cl=')) {
|
|
559
|
+
const n = parseInt(flag.slice(3), 10);
|
|
560
|
+
if (isNaN(n) || n < 0) {
|
|
561
|
+
throw new Error(
|
|
562
|
+
`Invalid allow list entry "${entry}": invalid calldataLength in flag "${flag}". Expected a non-negative integer.`,
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
result.calldataLength = n;
|
|
566
|
+
} else {
|
|
567
|
+
throw new Error(`Invalid allow list entry "${entry}": unknown flag "${flag}". Supported flags: os, rn, cl=N.`);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return result;
|
|
571
|
+
}
|
|
572
|
+
|
|
524
573
|
/**
|
|
525
574
|
* Parses a string to a list of allowed elements.
|
|
526
|
-
* Each
|
|
527
|
-
* `I:${address}`
|
|
528
|
-
* `
|
|
529
|
-
*
|
|
530
|
-
*
|
|
575
|
+
* Each entry is expected to be of one of the following formats:
|
|
576
|
+
* `I:${address}:${selector}` — instance (contract address) with function selector
|
|
577
|
+
* `C:${classId}:${selector}` — class with function selector
|
|
578
|
+
*
|
|
579
|
+
* An optional flags segment can be appended after the selector:
|
|
580
|
+
* `I:${address}:${selector}:${flags}` or `C:${classId}:${selector}:${flags}`
|
|
581
|
+
* where flags is a `+`-separated list of: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
|
|
531
582
|
*
|
|
532
583
|
* @param value The string to parse
|
|
533
584
|
* @returns A list of allowed elements
|
|
@@ -540,31 +591,37 @@ export function parseAllowList(value: string): AllowedElement[] {
|
|
|
540
591
|
}
|
|
541
592
|
|
|
542
593
|
for (const val of value.split(',')) {
|
|
543
|
-
const
|
|
544
|
-
|
|
594
|
+
const trimmed = val.trim();
|
|
595
|
+
if (!trimmed) {
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
const [typeString, identifierString, selectorString, flagsString] = trimmed.split(':');
|
|
599
|
+
|
|
600
|
+
if (!selectorString) {
|
|
601
|
+
throw new Error(
|
|
602
|
+
`Invalid allow list entry "${trimmed}": selector is required. Expected format: I:address:selector or C:classId:selector`,
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const selector = FunctionSelector.fromString(selectorString);
|
|
607
|
+
const flags = flagsString ? parseFlags(flagsString, trimmed) : {};
|
|
545
608
|
|
|
546
609
|
if (typeString === 'I') {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
} else {
|
|
553
|
-
entries.push({
|
|
554
|
-
address: AztecAddress.fromString(identifierString),
|
|
555
|
-
});
|
|
556
|
-
}
|
|
610
|
+
entries.push({
|
|
611
|
+
address: AztecAddress.fromString(identifierString),
|
|
612
|
+
selector,
|
|
613
|
+
...flags,
|
|
614
|
+
});
|
|
557
615
|
} else if (typeString === 'C') {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
616
|
+
entries.push({
|
|
617
|
+
classId: Fr.fromHexString(identifierString),
|
|
618
|
+
selector,
|
|
619
|
+
...flags,
|
|
620
|
+
});
|
|
621
|
+
} else {
|
|
622
|
+
throw new Error(
|
|
623
|
+
`Invalid allow list entry "${trimmed}": unknown type "${typeString}". Expected "I" (instance) or "C" (class).`,
|
|
624
|
+
);
|
|
568
625
|
}
|
|
569
626
|
}
|
|
570
627
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TxPoolRejectionError } from '../mem_pools/tx_pool_v2/eviction/interfaces.js';
|
|
2
|
+
|
|
3
|
+
/** Error thrown when a transaction is not added to the mempool. */
|
|
4
|
+
export class TxPoolError extends Error {
|
|
5
|
+
public readonly data: TxPoolRejectionError;
|
|
6
|
+
|
|
7
|
+
constructor(public readonly reason: TxPoolRejectionError) {
|
|
8
|
+
super(reason.message);
|
|
9
|
+
this.name = 'TxPoolError';
|
|
10
|
+
this.data = reason;
|
|
11
|
+
}
|
|
12
|
+
}
|