@aztec/p2p 0.0.1-commit.cf93bcc56 → 0.0.1-commit.d1cd2107c
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 +5 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +16 -26
- package/dest/client/interface.d.ts +8 -13
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +7 -13
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +29 -86
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
- package/dest/config.d.ts +22 -15
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +66 -37
- 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_v2/eviction/fee_payer_balance_eviction_rule.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +2 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +7 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_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 +10 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +8 -6
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +12 -6
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +3 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +40 -10
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +74 -16
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +26 -44
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +5 -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 +5 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +6 -3
- 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 +178 -140
- 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/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 +7 -7
- 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/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 +4 -4
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +27 -16
- 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_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 +5 -3
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +1 -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 +13 -12
- 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 +24 -47
- package/src/client/interface.ts +8 -13
- package/src/client/p2p_client.ts +34 -113
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +20 -11
- package/src/config.ts +92 -43
- 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_v2/README.md +9 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +1 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +3 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +11 -1
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +2 -2
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +10 -6
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +15 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +11 -5
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +104 -19
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +29 -43
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +6 -3
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +189 -141
- 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/services/dummy_service.ts +6 -6
- package/src/services/encoding.ts +5 -6
- 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/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 +32 -19
- 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_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 +2 -2
- package/src/testbench/p2p_client_testbench_worker.ts +22 -18
- 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/factory.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
5
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
5
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
6
6
|
import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
|
|
7
|
-
import type {
|
|
7
|
+
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
8
8
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
9
9
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
10
|
import type { AztecNode, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import {
|
|
12
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
11
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
13
12
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
13
|
|
|
15
14
|
import { P2PClient } from '../client/p2p_client.js';
|
|
@@ -17,11 +16,8 @@ import type { P2PConfig } from '../config.js';
|
|
|
17
16
|
import { AttestationPool, type AttestationPoolApi } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
18
17
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
19
18
|
import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
20
|
-
import type { TxMetaData } from '../mem_pools/tx_pool_v2/tx_metadata.js';
|
|
21
19
|
import { AztecKVTxPoolV2 } from '../mem_pools/tx_pool_v2/tx_pool_v2.js';
|
|
22
|
-
import {
|
|
23
|
-
import { BlockHeaderTxValidator } from '../msg_validators/tx_validator/block_header_validator.js';
|
|
24
|
-
import { DoubleSpendTxValidator } from '../msg_validators/tx_validator/double_spend_validator.js';
|
|
20
|
+
import { createTxValidatorForTransactionsEnteringPendingTxPool } from '../msg_validators/index.js';
|
|
25
21
|
import { DummyP2PService } from '../services/dummy_service.js';
|
|
26
22
|
import { LibP2PService } from '../services/index.js';
|
|
27
23
|
import { createFileStoreTxSources } from '../services/tx_collection/file_store_tx_source.js';
|
|
@@ -30,14 +26,14 @@ import { NodeRpcTxSource, type TxSource, createNodeRpcTxSources } from '../servi
|
|
|
30
26
|
import { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
|
|
31
27
|
import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
|
|
32
28
|
|
|
33
|
-
export type P2PClientDeps
|
|
29
|
+
export type P2PClientDeps = {
|
|
34
30
|
txPool?: TxPoolV2;
|
|
35
31
|
store?: AztecAsyncKVStore;
|
|
36
32
|
attestationPool?: AttestationPoolApi;
|
|
37
33
|
logger?: Logger;
|
|
38
34
|
txCollectionNodeSources?: TxSource[];
|
|
39
35
|
rpcTxProviders?: AztecNode[];
|
|
40
|
-
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService
|
|
36
|
+
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService>;
|
|
41
37
|
};
|
|
42
38
|
|
|
43
39
|
export const P2P_STORE_NAME = 'p2p';
|
|
@@ -45,8 +41,7 @@ export const P2P_ARCHIVE_STORE_NAME = 'p2p-archive';
|
|
|
45
41
|
export const P2P_PEER_STORE_NAME = 'p2p-peers';
|
|
46
42
|
export const P2P_ATTESTATION_STORE_NAME = 'p2p-attestation';
|
|
47
43
|
|
|
48
|
-
export async function createP2PClient
|
|
49
|
-
clientType: T,
|
|
44
|
+
export async function createP2PClient(
|
|
50
45
|
inputConfig: P2PConfig & DataStoreConfig & ChainConfig,
|
|
51
46
|
archiver: L2BlockSource & ContractDataSource,
|
|
52
47
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
@@ -55,7 +50,7 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
55
50
|
packageVersion: string,
|
|
56
51
|
dateProvider: DateProvider = new DateProvider(),
|
|
57
52
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
58
|
-
deps: P2PClientDeps
|
|
53
|
+
deps: P2PClientDeps = {},
|
|
59
54
|
) {
|
|
60
55
|
const config = await configureP2PClientAddresses({
|
|
61
56
|
...inputConfig,
|
|
@@ -80,32 +75,6 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
80
75
|
const rollupAddress = inputConfig.l1Contracts.rollupAddress.toString().toLowerCase().replace(/^0x/, '');
|
|
81
76
|
const txFileStoreBasePath = `aztec-${inputConfig.l1ChainId}-${inputConfig.rollupVersion}-0x${rollupAddress}`;
|
|
82
77
|
|
|
83
|
-
/** Validator factory for pool re-validation (double-spend + block header only). */
|
|
84
|
-
const createPoolTxValidator = async () => {
|
|
85
|
-
await worldStateSynchronizer.syncImmediate();
|
|
86
|
-
return new AggregateTxValidator<TxMetaData>(
|
|
87
|
-
new DoubleSpendTxValidator<TxMetaData>(
|
|
88
|
-
{
|
|
89
|
-
nullifiersExist: async (nullifiers: Buffer[]) => {
|
|
90
|
-
const merkleTree = worldStateSynchronizer.getCommitted();
|
|
91
|
-
const indices = await merkleTree.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers);
|
|
92
|
-
return indices.map(index => index !== undefined);
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
bindings,
|
|
96
|
-
),
|
|
97
|
-
new BlockHeaderTxValidator<TxMetaData>(
|
|
98
|
-
{
|
|
99
|
-
getArchiveIndices: (archives: BlockHash[]) => {
|
|
100
|
-
const merkleTree = worldStateSynchronizer.getCommitted();
|
|
101
|
-
return merkleTree.findLeafIndices(MerkleTreeId.ARCHIVE, archives);
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
bindings,
|
|
105
|
-
),
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
78
|
const txPool =
|
|
110
79
|
deps.txPool ??
|
|
111
80
|
new AztecKVTxPoolV2(
|
|
@@ -114,13 +83,24 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
114
83
|
{
|
|
115
84
|
l2BlockSource: archiver,
|
|
116
85
|
worldStateSynchronizer,
|
|
117
|
-
createTxValidator:
|
|
86
|
+
createTxValidator: async () => {
|
|
87
|
+
// We accept transactions if they are not expired by the next slot and block number (checked based on the ExpirationTimestamp field)
|
|
88
|
+
const currentBlockNumber = await archiver.getBlockNumber();
|
|
89
|
+
const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
|
|
90
|
+
return createTxValidatorForTransactionsEnteringPendingTxPool(
|
|
91
|
+
worldStateSynchronizer,
|
|
92
|
+
nextSlotTimestamp,
|
|
93
|
+
BlockNumber(currentBlockNumber + 1),
|
|
94
|
+
);
|
|
95
|
+
},
|
|
118
96
|
},
|
|
119
97
|
telemetry,
|
|
120
98
|
{
|
|
121
99
|
maxPendingTxCount: config.maxPendingTxCount,
|
|
122
100
|
archivedTxLimit: config.archivedTxLimit,
|
|
123
101
|
minTxPoolAgeMs: config.minTxPoolAgeMs,
|
|
102
|
+
dropTransactionsProbability: config.dropTransactionsProbability,
|
|
103
|
+
priceBumpPercentage: config.priceBumpPercentage,
|
|
124
104
|
},
|
|
125
105
|
dateProvider,
|
|
126
106
|
);
|
|
@@ -130,9 +110,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
130
110
|
attestationPool: deps.attestationPool ?? new AttestationPool(attestationStore, telemetry),
|
|
131
111
|
};
|
|
132
112
|
|
|
133
|
-
const p2pService = await createP2PService
|
|
113
|
+
const p2pService = await createP2PService(
|
|
134
114
|
config,
|
|
135
|
-
clientType,
|
|
136
115
|
archiver,
|
|
137
116
|
proofVerifier,
|
|
138
117
|
worldStateSynchronizer,
|
|
@@ -190,7 +169,6 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
190
169
|
);
|
|
191
170
|
|
|
192
171
|
return new P2PClient(
|
|
193
|
-
clientType,
|
|
194
172
|
store,
|
|
195
173
|
archiver,
|
|
196
174
|
mempools,
|
|
@@ -204,9 +182,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
204
182
|
);
|
|
205
183
|
}
|
|
206
184
|
|
|
207
|
-
async function createP2PService
|
|
185
|
+
async function createP2PService(
|
|
208
186
|
config: P2PConfig & DataStoreConfig,
|
|
209
|
-
clientType: T,
|
|
210
187
|
archiver: L2BlockSource & ContractDataSource,
|
|
211
188
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
212
189
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
@@ -214,7 +191,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
214
191
|
store: AztecAsyncKVStore,
|
|
215
192
|
peerStore: AztecLMDBStoreV2,
|
|
216
193
|
mempools: MemPools,
|
|
217
|
-
p2pServiceFactory: P2PClientDeps
|
|
194
|
+
p2pServiceFactory: P2PClientDeps['p2pServiceFactory'],
|
|
218
195
|
packageVersion: string,
|
|
219
196
|
logger: Logger,
|
|
220
197
|
telemetry: TelemetryClient,
|
|
@@ -230,7 +207,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
230
207
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
|
|
231
208
|
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey.getValue());
|
|
232
209
|
|
|
233
|
-
const p2pService = await (p2pServiceFactory ?? LibP2PService.new
|
|
210
|
+
const p2pService = await (p2pServiceFactory ?? LibP2PService.new)(config, peerId, {
|
|
234
211
|
packageVersion,
|
|
235
212
|
mempools,
|
|
236
213
|
l2BlockSource: archiver,
|
package/src/client/interface.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
|
|
3
|
-
import type { ITxProvider,
|
|
4
|
-
import type { BlockProposal, CheckpointAttestation, CheckpointProposal,
|
|
3
|
+
import type { ITxProvider, P2PClient } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
|
|
5
5
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -48,7 +48,7 @@ export interface P2PSyncState {
|
|
|
48
48
|
/**
|
|
49
49
|
* Interface of a P2P client.
|
|
50
50
|
**/
|
|
51
|
-
export type P2P
|
|
51
|
+
export type P2P = P2PClient & {
|
|
52
52
|
/**
|
|
53
53
|
* Broadcasts a block proposal to other peers.
|
|
54
54
|
*
|
|
@@ -134,14 +134,6 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
134
134
|
*/
|
|
135
135
|
hasTxsInPool(txHashes: TxHash[]): Promise<boolean[]>;
|
|
136
136
|
|
|
137
|
-
/**
|
|
138
|
-
* Returns transactions in the transaction pool by hash, requesting from the network if not found.
|
|
139
|
-
* @param txHashes - Hashes of tx to return.
|
|
140
|
-
* @param pinnedPeerId - An optional peer id that will be used to request the tx from (in addition to other random peers).
|
|
141
|
-
* @returns An array of tx or undefined.
|
|
142
|
-
*/
|
|
143
|
-
getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]>;
|
|
144
|
-
|
|
145
137
|
/**
|
|
146
138
|
* Returns an archived transaction from the transaction pool by its hash.
|
|
147
139
|
* @param txHash - Hash of tx to return.
|
|
@@ -218,8 +210,8 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
218
210
|
|
|
219
211
|
updateP2PConfig(config: Partial<P2PConfig>): Promise<void>;
|
|
220
212
|
|
|
221
|
-
/** Validates a set of txs. */
|
|
222
|
-
|
|
213
|
+
/** Validates a set of txs received in a block proposal. */
|
|
214
|
+
validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void>;
|
|
223
215
|
|
|
224
216
|
/** Clears the db. */
|
|
225
217
|
clear(): Promise<void>;
|
|
@@ -237,4 +229,7 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
237
229
|
|
|
238
230
|
/** If node running this P2P stack is validator, passes in validator address to P2P layer */
|
|
239
231
|
registerThisValidatorAddresses(address: EthAddress[]): void;
|
|
232
|
+
|
|
233
|
+
/** Returns the number of peers in the GossipSub mesh for a given topic type. */
|
|
234
|
+
getGossipMeshPeerCount(topicType: TopicType): Promise<number>;
|
|
240
235
|
};
|
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
|
|
|
@@ -42,7 +37,6 @@ import {
|
|
|
42
37
|
type ReqRespSubProtocolHandler,
|
|
43
38
|
type ReqRespSubProtocolValidators,
|
|
44
39
|
} from '../services/reqresp/interface.js';
|
|
45
|
-
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
46
40
|
import type {
|
|
47
41
|
DuplicateAttestationInfo,
|
|
48
42
|
DuplicateProposalInfo,
|
|
@@ -58,10 +52,7 @@ import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
|
58
52
|
/**
|
|
59
53
|
* The P2P client implementation.
|
|
60
54
|
*/
|
|
61
|
-
export class P2PClient
|
|
62
|
-
extends WithTracer
|
|
63
|
-
implements P2P, P2P<P2PClientType.Prover>
|
|
64
|
-
{
|
|
55
|
+
export class P2PClient extends WithTracer implements P2P {
|
|
65
56
|
/** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */
|
|
66
57
|
private runningPromise!: Promise<void>;
|
|
67
58
|
|
|
@@ -93,7 +84,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
93
84
|
private slotMonitor: RunningPromise | undefined;
|
|
94
85
|
|
|
95
86
|
constructor(
|
|
96
|
-
_clientType: T,
|
|
97
87
|
private store: AztecAsyncKVStore,
|
|
98
88
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
99
89
|
mempools: MemPools,
|
|
@@ -120,27 +110,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
120
110
|
this.telemetry,
|
|
121
111
|
);
|
|
122
112
|
|
|
123
|
-
// Default to collecting all txs when we see a valid proposal
|
|
124
|
-
// This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
|
|
125
|
-
// Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
126
|
-
// TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
|
|
127
|
-
// validator-client code into here so we can validate a proposal is reasonable.
|
|
128
|
-
this.registerBlockProposalHandler(async (block, sender) => {
|
|
129
|
-
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
130
|
-
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
131
|
-
const constants = this.txCollection.getConstants();
|
|
132
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
133
|
-
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
134
|
-
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
|
|
135
|
-
if (!parentBlock) {
|
|
136
|
-
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
140
|
-
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
141
|
-
return true;
|
|
142
|
-
});
|
|
143
|
-
|
|
144
113
|
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
145
114
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
146
115
|
}
|
|
@@ -166,6 +135,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
166
135
|
return Promise.resolve(this.p2pService.getPeers(includePending));
|
|
167
136
|
}
|
|
168
137
|
|
|
138
|
+
public getGossipMeshPeerCount(topicType: TopicType): Promise<number> {
|
|
139
|
+
return Promise.resolve(this.p2pService.getGossipMeshPeerCount(topicType));
|
|
140
|
+
}
|
|
141
|
+
|
|
169
142
|
public getL2BlockHash(number: BlockNumber): Promise<string | undefined> {
|
|
170
143
|
return this.l2Tips.getL2BlockHash(number);
|
|
171
144
|
}
|
|
@@ -201,7 +174,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
201
174
|
break;
|
|
202
175
|
case 'chain-pruned':
|
|
203
176
|
this.txCollection.stopCollectingForBlocksAfter(event.block.number);
|
|
204
|
-
await this.handlePruneL2Blocks(event.block);
|
|
177
|
+
await this.handlePruneL2Blocks(event.block, event.checkpoint);
|
|
205
178
|
break;
|
|
206
179
|
case 'chain-checkpointed':
|
|
207
180
|
break;
|
|
@@ -427,36 +400,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
427
400
|
this.p2pService.registerDuplicateAttestationCallback(callback);
|
|
428
401
|
}
|
|
429
402
|
|
|
430
|
-
/**
|
|
431
|
-
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
432
|
-
*/
|
|
433
|
-
private async requestTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<Tx[]> {
|
|
434
|
-
const timeoutMs = 8000; // Longer timeout for now
|
|
435
|
-
const maxRetryAttempts = 10; // Keep retrying within the timeout
|
|
436
|
-
const requests = chunkTxHashesRequest(txHashes);
|
|
437
|
-
const maxPeers = Math.min(Math.ceil(requests.length / 3), 10);
|
|
438
|
-
|
|
439
|
-
const txBatches = await this.p2pService.sendBatchRequest(
|
|
440
|
-
ReqRespSubProtocol.TX,
|
|
441
|
-
requests,
|
|
442
|
-
pinnedPeerId,
|
|
443
|
-
timeoutMs,
|
|
444
|
-
maxPeers,
|
|
445
|
-
maxRetryAttempts,
|
|
446
|
-
);
|
|
447
|
-
|
|
448
|
-
const txs = txBatches.flat();
|
|
449
|
-
if (txs.length > 0) {
|
|
450
|
-
await this.txPool.addPendingTxs(txs);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
const txHashesStr = txHashes.map(tx => tx.toString()).join(', ');
|
|
454
|
-
this.log.debug(`Requested txs ${txHashesStr} (${txs.length} / ${txHashes.length}) from peers`);
|
|
455
|
-
|
|
456
|
-
// We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
|
|
457
|
-
return txs;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
403
|
public async getPendingTxs(limit?: number, after?: TxHash): Promise<Tx[]> {
|
|
461
404
|
if (limit !== undefined && limit <= 0) {
|
|
462
405
|
throw new TypeError('limit must be greater than 0');
|
|
@@ -524,49 +467,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
524
467
|
return this.txPool.hasTxs(txHashes);
|
|
525
468
|
}
|
|
526
469
|
|
|
527
|
-
/**
|
|
528
|
-
* Returns transactions in the transaction pool by hash.
|
|
529
|
-
* If a transaction is not in the pool, it will be requested from the network.
|
|
530
|
-
* @param txHashes - Hashes of the transactions to look for.
|
|
531
|
-
* @returns The txs found, or undefined if not found in the order requested.
|
|
532
|
-
*/
|
|
533
|
-
async getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]> {
|
|
534
|
-
const txs = await Promise.all(txHashes.map(txHash => this.txPool.getTxByHash(txHash)));
|
|
535
|
-
const missingTxHashes = txs
|
|
536
|
-
.map((tx, index) => [tx, index] as const)
|
|
537
|
-
.filter(([tx, _index]) => !tx)
|
|
538
|
-
.map(([_tx, index]) => txHashes[index]);
|
|
539
|
-
|
|
540
|
-
if (missingTxHashes.length === 0) {
|
|
541
|
-
return txs as Tx[];
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
const missingTxs = await this.requestTxsByHash(missingTxHashes, pinnedPeerId);
|
|
545
|
-
// TODO: optimize
|
|
546
|
-
// Merge the found txs in order
|
|
547
|
-
const mergingTxs = txHashes.map(txHash => {
|
|
548
|
-
// Is it in the txs list from the mempool?
|
|
549
|
-
for (const tx of txs) {
|
|
550
|
-
if (tx !== undefined && tx.getTxHash().equals(txHash)) {
|
|
551
|
-
return tx;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// Is it in the fetched missing txs?
|
|
556
|
-
// Note: this is an O(n^2) operation, but we expect the number of missing txs to be small.
|
|
557
|
-
for (const tx of missingTxs) {
|
|
558
|
-
if (tx.getTxHash().equals(txHash)) {
|
|
559
|
-
return tx;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// Otherwise return undefined
|
|
564
|
-
return undefined;
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
return mergingTxs;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
470
|
/**
|
|
571
471
|
* Returns an archived transaction in the transaction pool by its hash.
|
|
572
472
|
* @param txHash - Hash of the archived transaction to look for.
|
|
@@ -759,10 +659,31 @@ 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 isEpochPrune = oldCheckpointNumber !== newCheckpoint.number;
|
|
683
|
+
this.log.info(
|
|
684
|
+
`Detected epoch prune: ${isEpochPrune}. Old checkpoint: ${oldCheckpointNumber}, new checkpoint: ${newCheckpoint.number}`,
|
|
685
|
+
);
|
|
686
|
+
return isEpochPrune;
|
|
766
687
|
}
|
|
767
688
|
|
|
768
689
|
/** Checks if the slot has changed and calls prepareForSlot if so. */
|
|
@@ -812,8 +733,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
812
733
|
this.log.debug(`Moved from state ${P2PClientState[oldState]} to ${P2PClientState[this.currentState]}`);
|
|
813
734
|
}
|
|
814
735
|
|
|
815
|
-
public
|
|
816
|
-
return this.p2pService.
|
|
736
|
+
public validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void> {
|
|
737
|
+
return this.p2pService.validateTxsReceivedInBlockProposal(txs);
|
|
817
738
|
}
|
|
818
739
|
|
|
819
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
|
);
|