@aztec/p2p 0.0.1-commit.0c875d939 → 0.0.1-commit.10bd49492
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 -28
- package/dest/client/interface.d.ts +10 -19
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +7 -18
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +47 -96
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
- package/dest/config.d.ts +28 -15
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +76 -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 +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +5 -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 +16 -14
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- package/dest/mem_pools/tx_pool/priority.d.ts +2 -2
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +4 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +3 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +9 -0
- 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.js +3 -3
- 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 +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +5 -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 +12 -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 +18 -6
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +4 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +46 -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 +99 -17
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +5 -2
- 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 +38 -46
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +6 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +9 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +12 -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 +285 -149
- 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 +125 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +226 -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 +67 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +104 -37
- 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 +111 -93
- 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/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 +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +4 -2
- package/dest/services/tx_collection/file_store_tx_source.d.ts +15 -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 +47 -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 +2 -2
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +10 -8
- package/dest/services/tx_collection/tx_collection.d.ts +5 -4
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- 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.js +1 -1
- 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 +6 -3
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +3 -2
- 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 +35 -49
- package/src/client/interface.ts +11 -20
- package/src/client/p2p_client.ts +48 -126
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +20 -11
- package/src/config.ts +108 -43
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +5 -4
- 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/priority.ts +6 -3
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +3 -1
- package/src/mem_pools/tx_pool_v2/README.md +10 -2
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +11 -0
- 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 +3 -3
- 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 +4 -4
- 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 +12 -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 +18 -6
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +141 -25
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +43 -46
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +15 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +318 -145
- 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 +366 -77
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +123 -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 +122 -101
- 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/fast_tx_collection.ts +51 -30
- package/src/services/tx_collection/file_store_tx_collection.ts +7 -3
- package/src/services/tx_collection/file_store_tx_source.ts +61 -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 +8 -9
- package/src/services/tx_collection/tx_collection.ts +4 -3
- 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 +1 -1
- 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 +4 -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;
|
|
@@ -426,36 +400,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
426
400
|
this.p2pService.registerDuplicateAttestationCallback(callback);
|
|
427
401
|
}
|
|
428
402
|
|
|
429
|
-
/**
|
|
430
|
-
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
431
|
-
*/
|
|
432
|
-
private async requestTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<Tx[]> {
|
|
433
|
-
const timeoutMs = 8000; // Longer timeout for now
|
|
434
|
-
const maxRetryAttempts = 10; // Keep retrying within the timeout
|
|
435
|
-
const requests = chunkTxHashesRequest(txHashes);
|
|
436
|
-
const maxPeers = Math.min(Math.ceil(requests.length / 3), 10);
|
|
437
|
-
|
|
438
|
-
const txBatches = await this.p2pService.sendBatchRequest(
|
|
439
|
-
ReqRespSubProtocol.TX,
|
|
440
|
-
requests,
|
|
441
|
-
pinnedPeerId,
|
|
442
|
-
timeoutMs,
|
|
443
|
-
maxPeers,
|
|
444
|
-
maxRetryAttempts,
|
|
445
|
-
);
|
|
446
|
-
|
|
447
|
-
const txs = txBatches.flat();
|
|
448
|
-
if (txs.length > 0) {
|
|
449
|
-
await this.txPool.addPendingTxs(txs);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
const txHashesStr = txHashes.map(tx => tx.toString()).join(', ');
|
|
453
|
-
this.log.debug(`Requested txs ${txHashesStr} (${txs.length} / ${txHashes.length}) from peers`);
|
|
454
|
-
|
|
455
|
-
// We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
|
|
456
|
-
return txs;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
403
|
public async getPendingTxs(limit?: number, after?: TxHash): Promise<Tx[]> {
|
|
460
404
|
if (limit !== undefined && limit <= 0) {
|
|
461
405
|
throw new TypeError('limit must be greater than 0');
|
|
@@ -523,49 +467,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
523
467
|
return this.txPool.hasTxs(txHashes);
|
|
524
468
|
}
|
|
525
469
|
|
|
526
|
-
/**
|
|
527
|
-
* Returns transactions in the transaction pool by hash.
|
|
528
|
-
* If a transaction is not in the pool, it will be requested from the network.
|
|
529
|
-
* @param txHashes - Hashes of the transactions to look for.
|
|
530
|
-
* @returns The txs found, or undefined if not found in the order requested.
|
|
531
|
-
*/
|
|
532
|
-
async getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]> {
|
|
533
|
-
const txs = await Promise.all(txHashes.map(txHash => this.txPool.getTxByHash(txHash)));
|
|
534
|
-
const missingTxHashes = txs
|
|
535
|
-
.map((tx, index) => [tx, index] as const)
|
|
536
|
-
.filter(([tx, _index]) => !tx)
|
|
537
|
-
.map(([_tx, index]) => txHashes[index]);
|
|
538
|
-
|
|
539
|
-
if (missingTxHashes.length === 0) {
|
|
540
|
-
return txs as Tx[];
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
const missingTxs = await this.requestTxsByHash(missingTxHashes, pinnedPeerId);
|
|
544
|
-
// TODO: optimize
|
|
545
|
-
// Merge the found txs in order
|
|
546
|
-
const mergingTxs = txHashes.map(txHash => {
|
|
547
|
-
// Is it in the txs list from the mempool?
|
|
548
|
-
for (const tx of txs) {
|
|
549
|
-
if (tx !== undefined && tx.getTxHash().equals(txHash)) {
|
|
550
|
-
return tx;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
// Is it in the fetched missing txs?
|
|
555
|
-
// Note: this is an O(n^2) operation, but we expect the number of missing txs to be small.
|
|
556
|
-
for (const tx of missingTxs) {
|
|
557
|
-
if (tx.getTxHash().equals(txHash)) {
|
|
558
|
-
return tx;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
// Otherwise return undefined
|
|
563
|
-
return undefined;
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
return mergingTxs;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
470
|
/**
|
|
570
471
|
* Returns an archived transaction in the transaction pool by its hash.
|
|
571
472
|
* @param txHash - Hash of the archived transaction to look for.
|
|
@@ -582,23 +483,22 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
582
483
|
**/
|
|
583
484
|
public async sendTx(tx: Tx): Promise<void> {
|
|
584
485
|
this.#assertIsReady();
|
|
585
|
-
const result = await this.txPool.addPendingTxs([tx]);
|
|
486
|
+
const result = await this.txPool.addPendingTxs([tx], { feeComparisonOnly: true });
|
|
586
487
|
if (result.accepted.length === 1) {
|
|
587
488
|
await this.p2pService.propagate(tx);
|
|
588
|
-
|
|
589
|
-
this.log.warn(
|
|
590
|
-
`Tx ${tx.getTxHash()} not propagated: accepted=${result.accepted.length} ignored=${result.ignored.length} rejected=${result.rejected.length}`,
|
|
591
|
-
);
|
|
489
|
+
return;
|
|
592
490
|
}
|
|
593
|
-
}
|
|
594
491
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
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
|
+
);
|
|
602
502
|
}
|
|
603
503
|
|
|
604
504
|
/**
|
|
@@ -759,10 +659,32 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
759
659
|
|
|
760
660
|
/**
|
|
761
661
|
* Updates the tx pool after a chain prune.
|
|
662
|
+
* Detects epoch prunes (checkpoint number changed) and deletes all txs in that case.
|
|
762
663
|
* @param latestBlock - The block ID the chain was pruned to.
|
|
664
|
+
* @param newCheckpoint - The checkpoint ID after the prune.
|
|
763
665
|
*/
|
|
764
|
-
private async handlePruneL2Blocks(latestBlock: L2BlockId): Promise<void> {
|
|
765
|
-
|
|
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 newCheckpointNumber = newCheckpoint.number;
|
|
683
|
+
const isEpochPrune = oldCheckpointNumber !== newCheckpointNumber;
|
|
684
|
+
if (isEpochPrune) {
|
|
685
|
+
this.log.info(`Detected epoch prune to ${newCheckpointNumber}`, { oldCheckpointNumber, newCheckpointNumber });
|
|
686
|
+
}
|
|
687
|
+
return isEpochPrune;
|
|
766
688
|
}
|
|
767
689
|
|
|
768
690
|
/** Checks if the slot has changed and calls prepareForSlot if so. */
|
|
@@ -812,8 +734,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
812
734
|
this.log.debug(`Moved from state ${P2PClientState[oldState]} to ${P2PClientState[this.currentState]}`);
|
|
813
735
|
}
|
|
814
736
|
|
|
815
|
-
public
|
|
816
|
-
return this.p2pService.
|
|
737
|
+
public validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void> {
|
|
738
|
+
return this.p2pService.validateTxsReceivedInBlockProposal(txs);
|
|
817
739
|
}
|
|
818
740
|
|
|
819
741
|
/**
|
|
@@ -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,16 @@ 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
|
+
|
|
46
|
+
/** Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected. */
|
|
47
|
+
validateMaxL2BlockGas?: number;
|
|
48
|
+
|
|
49
|
+
/** Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected. */
|
|
50
|
+
validateMaxDABlockGas?: number;
|
|
51
|
+
|
|
42
52
|
/** A flag dictating whether the P2P subsystem should be enabled. */
|
|
43
53
|
p2pEnabled: boolean;
|
|
44
54
|
|
|
@@ -150,8 +160,8 @@ export interface P2PConfig
|
|
|
150
160
|
/** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
|
|
151
161
|
p2pStoreMapSizeKb?: number;
|
|
152
162
|
|
|
153
|
-
/**
|
|
154
|
-
|
|
163
|
+
/** Additional entries to extend the default setup allow list. */
|
|
164
|
+
txPublicSetupAllowListExtend: AllowedElement[];
|
|
155
165
|
|
|
156
166
|
/** The maximum number of pending txs before evicting lower priority txs. */
|
|
157
167
|
maxPendingTxCount: number;
|
|
@@ -173,10 +183,7 @@ export interface P2PConfig
|
|
|
173
183
|
/** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
|
|
174
184
|
disableTransactions: boolean;
|
|
175
185
|
|
|
176
|
-
/**
|
|
177
|
-
dropTransactions: boolean;
|
|
178
|
-
|
|
179
|
-
/** The probability that a transaction is discarded. - For testing purposes only */
|
|
186
|
+
/** The probability that a transaction is discarded (0 = disabled). - For testing purposes only */
|
|
180
187
|
dropTransactionsProbability: number;
|
|
181
188
|
|
|
182
189
|
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
@@ -193,11 +200,30 @@ export interface P2PConfig
|
|
|
193
200
|
|
|
194
201
|
/** Minimum age (ms) a transaction must have been in the pool before it's eligible for block building. */
|
|
195
202
|
minTxPoolAgeMs: number;
|
|
203
|
+
|
|
204
|
+
/** Minimum percentage fee increase required to replace an existing tx via RPC (0 = no bump). */
|
|
205
|
+
priceBumpPercentage: bigint;
|
|
196
206
|
}
|
|
197
207
|
|
|
198
208
|
export const DEFAULT_P2P_PORT = 40400;
|
|
199
209
|
|
|
200
210
|
export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
211
|
+
validateMaxTxsPerBlock: {
|
|
212
|
+
env: 'VALIDATOR_MAX_TX_PER_BLOCK',
|
|
213
|
+
description:
|
|
214
|
+
'Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set.',
|
|
215
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
216
|
+
},
|
|
217
|
+
validateMaxL2BlockGas: {
|
|
218
|
+
env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
|
|
219
|
+
description: 'Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected.',
|
|
220
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
221
|
+
},
|
|
222
|
+
validateMaxDABlockGas: {
|
|
223
|
+
env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
|
|
224
|
+
description: 'Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected.',
|
|
225
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
226
|
+
},
|
|
201
227
|
p2pEnabled: {
|
|
202
228
|
env: 'P2P_ENABLED',
|
|
203
229
|
description: 'A flag dictating whether the P2P subsystem should be enabled.',
|
|
@@ -396,12 +422,13 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
396
422
|
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
397
423
|
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
398
424
|
},
|
|
399
|
-
|
|
425
|
+
txPublicSetupAllowListExtend: {
|
|
400
426
|
env: 'TX_PUBLIC_SETUP_ALLOWLIST',
|
|
401
427
|
parseEnv: (val: string) => parseAllowList(val),
|
|
402
|
-
description:
|
|
428
|
+
description:
|
|
429
|
+
'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 +.',
|
|
403
430
|
printDefault: () =>
|
|
404
|
-
'AuthRegistry
|
|
431
|
+
'Default: AuthRegistry._set_authorized, AuthRegistry.set_authorized, FeeJuice._increase_public_balance',
|
|
405
432
|
},
|
|
406
433
|
maxPendingTxCount: {
|
|
407
434
|
env: 'P2P_MAX_PENDING_TX_COUNT',
|
|
@@ -430,11 +457,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
430
457
|
description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
|
|
431
458
|
...numberConfigHelper(3),
|
|
432
459
|
},
|
|
433
|
-
dropTransactions: {
|
|
434
|
-
env: 'P2P_DROP_TX',
|
|
435
|
-
description: 'True to simulate discarding transactions. - For testing purposes only',
|
|
436
|
-
...booleanConfigHelper(false),
|
|
437
|
-
},
|
|
438
460
|
dropTransactionsProbability: {
|
|
439
461
|
env: 'P2P_DROP_TX_CHANCE',
|
|
440
462
|
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
@@ -472,6 +494,12 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
472
494
|
description: 'Minimum age (ms) a transaction must have been in the pool before it is eligible for block building.',
|
|
473
495
|
...numberConfigHelper(2_000),
|
|
474
496
|
},
|
|
497
|
+
priceBumpPercentage: {
|
|
498
|
+
env: 'P2P_RPC_PRICE_BUMP_PERCENTAGE',
|
|
499
|
+
description:
|
|
500
|
+
'Minimum percentage fee increase required to replace an existing tx via RPC. Even at 0%, replacement still requires paying at least 1 unit more.',
|
|
501
|
+
...bigintConfigHelper(10n),
|
|
502
|
+
},
|
|
475
503
|
...sharedSequencerConfigMappings,
|
|
476
504
|
...p2pReqRespConfigMappings,
|
|
477
505
|
...batchTxRequesterConfigMappings,
|
|
@@ -529,13 +557,44 @@ export const bootnodeConfigMappings = pickConfigMappings(
|
|
|
529
557
|
bootnodeConfigKeys,
|
|
530
558
|
);
|
|
531
559
|
|
|
560
|
+
/**
|
|
561
|
+
* Parses a `+`-separated flags string into validation properties for an allow list entry.
|
|
562
|
+
* Supported flags: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
|
|
563
|
+
*/
|
|
564
|
+
function parseFlags(
|
|
565
|
+
flags: string,
|
|
566
|
+
entry: string,
|
|
567
|
+
): { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } {
|
|
568
|
+
const result: { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } = {};
|
|
569
|
+
for (const flag of flags.split('+')) {
|
|
570
|
+
if (flag === 'os') {
|
|
571
|
+
result.onlySelf = true;
|
|
572
|
+
} else if (flag === 'rn') {
|
|
573
|
+
result.rejectNullMsgSender = true;
|
|
574
|
+
} else if (flag.startsWith('cl=')) {
|
|
575
|
+
const n = parseInt(flag.slice(3), 10);
|
|
576
|
+
if (isNaN(n) || n < 0) {
|
|
577
|
+
throw new Error(
|
|
578
|
+
`Invalid allow list entry "${entry}": invalid calldataLength in flag "${flag}". Expected a non-negative integer.`,
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
result.calldataLength = n;
|
|
582
|
+
} else {
|
|
583
|
+
throw new Error(`Invalid allow list entry "${entry}": unknown flag "${flag}". Supported flags: os, rn, cl=N.`);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return result;
|
|
587
|
+
}
|
|
588
|
+
|
|
532
589
|
/**
|
|
533
590
|
* Parses a string to a list of allowed elements.
|
|
534
|
-
* Each
|
|
535
|
-
* `I:${address}`
|
|
536
|
-
* `
|
|
537
|
-
*
|
|
538
|
-
*
|
|
591
|
+
* Each entry is expected to be of one of the following formats:
|
|
592
|
+
* `I:${address}:${selector}` — instance (contract address) with function selector
|
|
593
|
+
* `C:${classId}:${selector}` — class with function selector
|
|
594
|
+
*
|
|
595
|
+
* An optional flags segment can be appended after the selector:
|
|
596
|
+
* `I:${address}:${selector}:${flags}` or `C:${classId}:${selector}:${flags}`
|
|
597
|
+
* where flags is a `+`-separated list of: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
|
|
539
598
|
*
|
|
540
599
|
* @param value The string to parse
|
|
541
600
|
* @returns A list of allowed elements
|
|
@@ -548,31 +607,37 @@ export function parseAllowList(value: string): AllowedElement[] {
|
|
|
548
607
|
}
|
|
549
608
|
|
|
550
609
|
for (const val of value.split(',')) {
|
|
551
|
-
const
|
|
552
|
-
|
|
610
|
+
const trimmed = val.trim();
|
|
611
|
+
if (!trimmed) {
|
|
612
|
+
continue;
|
|
613
|
+
}
|
|
614
|
+
const [typeString, identifierString, selectorString, flagsString] = trimmed.split(':');
|
|
615
|
+
|
|
616
|
+
if (!selectorString) {
|
|
617
|
+
throw new Error(
|
|
618
|
+
`Invalid allow list entry "${trimmed}": selector is required. Expected format: I:address:selector or C:classId:selector`,
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
const selector = FunctionSelector.fromString(selectorString);
|
|
623
|
+
const flags = flagsString ? parseFlags(flagsString, trimmed) : {};
|
|
553
624
|
|
|
554
625
|
if (typeString === 'I') {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
} else {
|
|
561
|
-
entries.push({
|
|
562
|
-
address: AztecAddress.fromString(identifierString),
|
|
563
|
-
});
|
|
564
|
-
}
|
|
626
|
+
entries.push({
|
|
627
|
+
address: AztecAddress.fromString(identifierString),
|
|
628
|
+
selector,
|
|
629
|
+
...flags,
|
|
630
|
+
});
|
|
565
631
|
} else if (typeString === 'C') {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
632
|
+
entries.push({
|
|
633
|
+
classId: Fr.fromHexString(identifierString),
|
|
634
|
+
selector,
|
|
635
|
+
...flags,
|
|
636
|
+
});
|
|
637
|
+
} else {
|
|
638
|
+
throw new Error(
|
|
639
|
+
`Invalid allow list entry "${trimmed}": unknown type "${typeString}". Expected "I" (instance) or "C" (class).`,
|
|
640
|
+
);
|
|
576
641
|
}
|
|
577
642
|
}
|
|
578
643
|
|
|
@@ -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
|
+
}
|
|
@@ -359,11 +359,10 @@ export class AttestationPool {
|
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
const address = sender.toString();
|
|
362
|
+
const ownKey = this.getAttestationKey(slotNumber, proposalId, address);
|
|
362
363
|
|
|
363
|
-
await this.checkpointAttestations.set(
|
|
364
|
-
|
|
365
|
-
attestation.toBuffer(),
|
|
366
|
-
);
|
|
364
|
+
await this.checkpointAttestations.set(ownKey, attestation.toBuffer());
|
|
365
|
+
this.metrics.trackMempoolItemAdded(ownKey);
|
|
367
366
|
|
|
368
367
|
this.log.debug(`Added own checkpoint attestation for slot ${slotNumber} from ${address}`, {
|
|
369
368
|
signature: attestation.signature.toString(),
|
|
@@ -429,6 +428,7 @@ export class AttestationPool {
|
|
|
429
428
|
const attestationEndKey = new Fr(oldestSlot).toString();
|
|
430
429
|
for await (const key of this.checkpointAttestations.keysAsync({ end: attestationEndKey })) {
|
|
431
430
|
await this.checkpointAttestations.delete(key);
|
|
431
|
+
this.metrics.trackMempoolItemRemoved(key);
|
|
432
432
|
numberOfAttestations++;
|
|
433
433
|
}
|
|
434
434
|
|
|
@@ -526,6 +526,7 @@ export class AttestationPool {
|
|
|
526
526
|
|
|
527
527
|
// Add the attestation
|
|
528
528
|
await this.checkpointAttestations.set(key, attestation.toBuffer());
|
|
529
|
+
this.metrics.trackMempoolItemAdded(key);
|
|
529
530
|
|
|
530
531
|
// Track this attestation in the per-signer-per-slot index for duplicate detection
|
|
531
532
|
const slotSignerKey = this.getSlotSignerKey(slotNumber, signerAddress);
|