@aztec/p2p 0.0.1-commit.cd76b27 → 0.0.1-commit.ce4f8c4f2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -3
- package/dest/client/factory.d.ts +5 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +28 -26
- package/dest/client/interface.d.ts +6 -13
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +5 -13
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +25 -92
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +4 -5
- package/dest/config.d.ts +33 -15
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +86 -37
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +4 -4
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +8 -4
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
- 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/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +2 -1
- 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 -4
- 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/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +3 -2
- 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 +15 -9
- 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 +48 -11
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +81 -17
- 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 +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +3 -2
- 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 +196 -151
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +5 -4
- package/dest/msg_validators/clock_tolerance.d.ts +1 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +4 -3
- 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 +53 -41
- 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/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +35 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +133 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +247 -60
- 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 +22 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
- package/dest/services/discv5/discV5_service.d.ts +1 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +4 -2
- package/dest/services/dummy_service.d.ts +2 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +1 -4
- package/dest/services/encoding.d.ts +6 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +14 -8
- package/dest/services/libp2p/libp2p_service.d.ts +20 -20
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +221 -143
- 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 +6 -3
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +82 -101
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +3 -2
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +5 -4
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +13 -7
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -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 +52 -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 +19 -10
- package/dest/services/service.d.ts +8 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +57 -73
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +6 -7
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +4 -4
- package/dest/services/tx_collection/request_tracker.d.ts +53 -0
- package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/request_tracker.js +84 -0
- package/dest/services/tx_collection/slow_tx_collection.js +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +3 -6
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_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 +7 -3
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +11 -3
- 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 +2 -2
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +22 -3
- package/dest/testbench/p2p_client_testbench_worker.js +10 -9
- 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 +9 -4
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +2 -9
- package/package.json +14 -14
- package/src/client/factory.ts +45 -45
- package/src/client/interface.ts +5 -19
- package/src/client/p2p_client.ts +26 -122
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +5 -8
- package/src/config.ts +125 -43
- package/src/mem_pools/attestation_pool/attestation_pool.ts +8 -7
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
- package/src/mem_pools/instrumentation.ts +17 -13
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool/priority.ts +4 -4
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +3 -1
- 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 +3 -2
- 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 +16 -8
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +115 -20
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +29 -43
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +17 -2
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +207 -154
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +5 -4
- package/src/msg_validators/clock_tolerance.ts +4 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- 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 +69 -45
- package/src/msg_validators/tx_validator/README.md +119 -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/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/factory.ts +394 -78
- 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 +82 -27
- package/src/services/discv5/discV5_service.ts +4 -2
- package/src/services/dummy_service.ts +1 -5
- package/src/services/encoding.ts +14 -7
- package/src/services/libp2p/libp2p_service.ts +235 -166
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +7 -3
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +78 -111
- package/src/services/reqresp/batch-tx-requester/interface.ts +2 -1
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +13 -6
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/reqresp.ts +22 -12
- package/src/services/service.ts +8 -1
- package/src/services/tx_collection/fast_tx_collection.ts +57 -83
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -13
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +1 -1
- package/src/services/tx_collection/tx_collection.ts +3 -5
- package/src/services/tx_provider.ts +2 -2
- package/src/test-helpers/make-test-p2p-clients.ts +1 -3
- package/src/test-helpers/mock-pubsub.ts +12 -6
- package/src/test-helpers/reqresp-nodes.ts +3 -6
- package/src/test-helpers/testbench-utils.ts +30 -4
- package/src/testbench/p2p_client_testbench_worker.ts +7 -12
- package/src/testbench/worker_client_manager.ts +13 -5
- package/src/util.ts +9 -13
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
- package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
- package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
package/dest/util.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SecretValue } from '@aztec/foundation/config';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
|
-
import type { DataStoreConfig } from '@aztec/kv-store
|
|
4
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
5
5
|
import type { GossipSub } from '@chainsafe/libp2p-gossipsub';
|
|
6
6
|
import type { Identify } from '@libp2p/identify';
|
|
7
7
|
import type { PeerId } from '@libp2p/interface';
|
|
8
|
-
import type { ConnectionManager } from '@libp2p/interface-internal';
|
|
8
|
+
import type { AddressManager, ConnectionManager } from '@libp2p/interface-internal';
|
|
9
9
|
import type { Libp2p } from 'libp2p';
|
|
10
10
|
import type { P2PConfig } from './config.js';
|
|
11
11
|
export interface PubSubLibp2p extends Pick<Libp2p, 'status' | 'start' | 'stop' | 'peerId'> {
|
|
@@ -13,6 +13,10 @@ export interface PubSubLibp2p extends Pick<Libp2p, 'status' | 'start' | 'stop' |
|
|
|
13
13
|
pubsub: Pick<GossipSub, 'addEventListener' | 'removeEventListener' | 'publish' | 'subscribe' | 'reportMessageValidationResult' | 'direct' | 'getMeshPeers'> & {
|
|
14
14
|
score: Pick<GossipSub['score'], 'score'>;
|
|
15
15
|
};
|
|
16
|
+
components: {
|
|
17
|
+
connectionManager: ConnectionManager;
|
|
18
|
+
addressManager: AddressManager;
|
|
19
|
+
};
|
|
16
20
|
};
|
|
17
21
|
}
|
|
18
22
|
export type FullLibp2p = Libp2p<{
|
|
@@ -20,6 +24,7 @@ export type FullLibp2p = Libp2p<{
|
|
|
20
24
|
pubsub: GossipSub;
|
|
21
25
|
components: {
|
|
22
26
|
connectionManager: ConnectionManager;
|
|
27
|
+
addressManager: AddressManager;
|
|
23
28
|
};
|
|
24
29
|
}>;
|
|
25
30
|
/**
|
|
@@ -37,7 +42,7 @@ export declare function convertToMultiaddr(address: string, port: number, protoc
|
|
|
37
42
|
export declare function getPublicIp(): Promise<string>;
|
|
38
43
|
export declare function isValidIpAddress(address: string): boolean;
|
|
39
44
|
export declare function resolveAddressIfNecessary(address: string, port: string): Promise<string>;
|
|
40
|
-
export declare function configureP2PClientAddresses(_config: P2PConfig & DataStoreConfig):
|
|
45
|
+
export declare function configureP2PClientAddresses(_config: P2PConfig & DataStoreConfig): P2PConfig & DataStoreConfig;
|
|
41
46
|
/**
|
|
42
47
|
* Get the peer id private key
|
|
43
48
|
*
|
|
@@ -58,4 +63,4 @@ export declare function getPeerIdPrivateKey(config: {
|
|
|
58
63
|
* @returns The peer ID.
|
|
59
64
|
*/
|
|
60
65
|
export declare function createLibP2PPeerIdFromPrivateKey(privateKey: string): Promise<PeerId>;
|
|
61
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
66
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3V0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQ3ZELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUF1QixNQUFNLGlCQUFpQixDQUFDO0FBQzlFLE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRTlELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRTdELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBYyxNQUFNLG1CQUFtQixDQUFDO0FBQzVELE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxpQkFBaUIsRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBSXBGLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLFFBQVEsQ0FBQztBQUlyQyxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFJN0MsTUFBTSxXQUFXLFlBQWEsU0FBUSxJQUFJLENBQUMsTUFBTSxFQUFFLFFBQVEsR0FBRyxPQUFPLEdBQUcsTUFBTSx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AAM,UAAU,GAAG,MAAM,CAAC;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE;QACV,iBAAiB,EAAE,iBAAiB,CAAC;QACrC,cAAc,EAAE,cAAc,CAAC;KAChC,CAAC;CACH,CAAC,CAAC;AAEH;;;;;;;6CAO6C;AAC7C,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAOjG;AAED;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAQnD;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGzD;AAED,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAW9F;AAcD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS,GAAG,eAAe,CAY7G;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE;IAAE,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,EACzG,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CA2D9B;AAED;;;;GAIG;AACH,wBAAsB,gCAAgC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS1F"}
|
package/dest/util.js
CHANGED
|
@@ -58,22 +58,15 @@ function addressToMultiAddressType(address) {
|
|
|
58
58
|
return 'dns';
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
export
|
|
61
|
+
export function configureP2PClientAddresses(_config) {
|
|
62
62
|
const config = {
|
|
63
63
|
..._config
|
|
64
64
|
};
|
|
65
|
-
const {
|
|
65
|
+
const { p2pBroadcastPort, p2pPort } = config;
|
|
66
66
|
// If no broadcast port is provided, use the given p2p port as the broadcast port
|
|
67
67
|
if (!p2pBroadcastPort) {
|
|
68
68
|
config.p2pBroadcastPort = p2pPort;
|
|
69
69
|
}
|
|
70
|
-
// check if no announce IP was provided
|
|
71
|
-
if (!p2pIp) {
|
|
72
|
-
if (queryForIp) {
|
|
73
|
-
const publicIp = await getPublicIp();
|
|
74
|
-
config.p2pIp = publicIp;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
70
|
// TODO(md): guard against setting a local ip address as the announce ip
|
|
78
71
|
return config;
|
|
79
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.ce4f8c4f2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "0.0.1-commit.
|
|
71
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
72
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
73
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
74
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
75
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
77
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
78
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
80
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
70
|
+
"@aztec/constants": "0.0.1-commit.ce4f8c4f2",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.ce4f8c4f2",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.ce4f8c4f2",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.ce4f8c4f2",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.ce4f8c4f2",
|
|
75
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.ce4f8c4f2",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.ce4f8c4f2",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.ce4f8c4f2",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.ce4f8c4f2",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.ce4f8c4f2",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.ce4f8c4f2",
|
|
81
81
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
82
82
|
"@chainsafe/libp2p-noise": "^15.0.0",
|
|
83
83
|
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"xxhash-wasm": "^1.1.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
108
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
107
|
+
"@aztec/archiver": "0.0.1-commit.ce4f8c4f2",
|
|
108
|
+
"@aztec/world-state": "0.0.1-commit.ce4f8c4f2",
|
|
109
109
|
"@jest/globals": "^30.0.0",
|
|
110
110
|
"@types/jest": "^30.0.0",
|
|
111
111
|
"@types/node": "^22.15.17",
|
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,12 @@ 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
|
-
|
|
24
|
-
|
|
20
|
+
import {
|
|
21
|
+
createCheckAllowedSetupCalls,
|
|
22
|
+
createTxValidatorForTransactionsEnteringPendingTxPool,
|
|
23
|
+
getDefaultAllowedSetupFunctions,
|
|
24
|
+
} from '../msg_validators/index.js';
|
|
25
25
|
import { DummyP2PService } from '../services/dummy_service.js';
|
|
26
26
|
import { LibP2PService } from '../services/index.js';
|
|
27
27
|
import { createFileStoreTxSources } from '../services/tx_collection/file_store_tx_source.js';
|
|
@@ -30,14 +30,14 @@ import { NodeRpcTxSource, type TxSource, createNodeRpcTxSources } from '../servi
|
|
|
30
30
|
import { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
|
|
31
31
|
import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
|
|
32
32
|
|
|
33
|
-
export type P2PClientDeps
|
|
33
|
+
export type P2PClientDeps = {
|
|
34
34
|
txPool?: TxPoolV2;
|
|
35
35
|
store?: AztecAsyncKVStore;
|
|
36
36
|
attestationPool?: AttestationPoolApi;
|
|
37
37
|
logger?: Logger;
|
|
38
38
|
txCollectionNodeSources?: TxSource[];
|
|
39
39
|
rpcTxProviders?: AztecNode[];
|
|
40
|
-
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService
|
|
40
|
+
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService>;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
export const P2P_STORE_NAME = 'p2p';
|
|
@@ -45,8 +45,7 @@ export const P2P_ARCHIVE_STORE_NAME = 'p2p-archive';
|
|
|
45
45
|
export const P2P_PEER_STORE_NAME = 'p2p-peers';
|
|
46
46
|
export const P2P_ATTESTATION_STORE_NAME = 'p2p-attestation';
|
|
47
47
|
|
|
48
|
-
export async function createP2PClient
|
|
49
|
-
clientType: T,
|
|
48
|
+
export async function createP2PClient(
|
|
50
49
|
inputConfig: P2PConfig & DataStoreConfig & ChainConfig,
|
|
51
50
|
archiver: L2BlockSource & ContractDataSource,
|
|
52
51
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
@@ -55,9 +54,9 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
55
54
|
packageVersion: string,
|
|
56
55
|
dateProvider: DateProvider = new DateProvider(),
|
|
57
56
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
58
|
-
deps: P2PClientDeps
|
|
57
|
+
deps: P2PClientDeps = {},
|
|
59
58
|
) {
|
|
60
|
-
const config =
|
|
59
|
+
const config = configureP2PClientAddresses({
|
|
61
60
|
...inputConfig,
|
|
62
61
|
dataStoreMapSizeKb: inputConfig.p2pStoreMapSizeKb ?? inputConfig.dataStoreMapSizeKb,
|
|
63
62
|
});
|
|
@@ -80,29 +79,30 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
80
79
|
const rollupAddress = inputConfig.l1Contracts.rollupAddress.toString().toLowerCase().replace(/^0x/, '');
|
|
81
80
|
const txFileStoreBasePath = `aztec-${inputConfig.l1ChainId}-${inputConfig.rollupVersion}-0x${rollupAddress}`;
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
82
|
+
const allowedInSetup = [
|
|
83
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
84
|
+
...(inputConfig.txPublicSetupAllowListExtend ?? []),
|
|
85
|
+
];
|
|
86
|
+
const checkAllowedSetupCalls = createCheckAllowedSetupCalls(
|
|
87
|
+
archiver,
|
|
88
|
+
allowedInSetup,
|
|
89
|
+
() => epochCache.getEpochAndSlotInNextL1Slot().ts,
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const createTxValidator = async () => {
|
|
93
|
+
// We accept transactions if they are not expired by the next slot and block number (checked based on the ExpirationTimestamp field)
|
|
94
|
+
const currentBlockNumber = await archiver.getBlockNumber();
|
|
95
|
+
const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
|
|
96
|
+
const l1Constants = await archiver.getL1Constants();
|
|
97
|
+
return createTxValidatorForTransactionsEnteringPendingTxPool(
|
|
98
|
+
worldStateSynchronizer,
|
|
99
|
+
nextSlotTimestamp,
|
|
100
|
+
BlockNumber(currentBlockNumber + 1),
|
|
101
|
+
{
|
|
102
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
103
|
+
maxBlockL2Gas: config.validateMaxL2BlockGas,
|
|
104
|
+
maxBlockDAGas: config.validateMaxDABlockGas,
|
|
105
|
+
},
|
|
106
106
|
);
|
|
107
107
|
};
|
|
108
108
|
|
|
@@ -114,13 +114,16 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
114
114
|
{
|
|
115
115
|
l2BlockSource: archiver,
|
|
116
116
|
worldStateSynchronizer,
|
|
117
|
-
|
|
117
|
+
checkAllowedSetupCalls,
|
|
118
|
+
createTxValidator,
|
|
118
119
|
},
|
|
119
120
|
telemetry,
|
|
120
121
|
{
|
|
121
122
|
maxPendingTxCount: config.maxPendingTxCount,
|
|
122
123
|
archivedTxLimit: config.archivedTxLimit,
|
|
123
124
|
minTxPoolAgeMs: config.minTxPoolAgeMs,
|
|
125
|
+
dropTransactionsProbability: config.dropTransactionsProbability,
|
|
126
|
+
priceBumpPercentage: config.priceBumpPercentage,
|
|
124
127
|
},
|
|
125
128
|
dateProvider,
|
|
126
129
|
);
|
|
@@ -130,9 +133,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
130
133
|
attestationPool: deps.attestationPool ?? new AttestationPool(attestationStore, telemetry),
|
|
131
134
|
};
|
|
132
135
|
|
|
133
|
-
const p2pService = await createP2PService
|
|
136
|
+
const p2pService = await createP2PService(
|
|
134
137
|
config,
|
|
135
|
-
clientType,
|
|
136
138
|
archiver,
|
|
137
139
|
proofVerifier,
|
|
138
140
|
worldStateSynchronizer,
|
|
@@ -190,7 +192,6 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
190
192
|
);
|
|
191
193
|
|
|
192
194
|
return new P2PClient(
|
|
193
|
-
clientType,
|
|
194
195
|
store,
|
|
195
196
|
archiver,
|
|
196
197
|
mempools,
|
|
@@ -204,9 +205,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
204
205
|
);
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
async function createP2PService
|
|
208
|
+
async function createP2PService(
|
|
208
209
|
config: P2PConfig & DataStoreConfig,
|
|
209
|
-
clientType: T,
|
|
210
210
|
archiver: L2BlockSource & ContractDataSource,
|
|
211
211
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
212
212
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
@@ -214,7 +214,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
214
214
|
store: AztecAsyncKVStore,
|
|
215
215
|
peerStore: AztecLMDBStoreV2,
|
|
216
216
|
mempools: MemPools,
|
|
217
|
-
p2pServiceFactory: P2PClientDeps
|
|
217
|
+
p2pServiceFactory: P2PClientDeps['p2pServiceFactory'],
|
|
218
218
|
packageVersion: string,
|
|
219
219
|
logger: Logger,
|
|
220
220
|
telemetry: TelemetryClient,
|
|
@@ -230,7 +230,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
230
230
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
|
|
231
231
|
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey.getValue());
|
|
232
232
|
|
|
233
|
-
const p2pService = await (p2pServiceFactory ?? LibP2PService.new
|
|
233
|
+
const p2pService = await (p2pServiceFactory ?? LibP2PService.new)(config, peerId, {
|
|
234
234
|
packageVersion,
|
|
235
235
|
mempools,
|
|
236
236
|
l2BlockSource: archiver,
|
package/src/client/interface.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
|
|
3
|
-
import type { ITxProvider,
|
|
4
|
-
import type {
|
|
5
|
-
BlockProposal,
|
|
6
|
-
CheckpointAttestation,
|
|
7
|
-
CheckpointProposal,
|
|
8
|
-
P2PClientType,
|
|
9
|
-
TopicType,
|
|
10
|
-
} from '@aztec/stdlib/p2p';
|
|
3
|
+
import type { ITxProvider, P2PClient } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
|
|
11
5
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
12
6
|
|
|
13
7
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -54,7 +48,7 @@ export interface P2PSyncState {
|
|
|
54
48
|
/**
|
|
55
49
|
* Interface of a P2P client.
|
|
56
50
|
**/
|
|
57
|
-
export type P2P
|
|
51
|
+
export type P2P = P2PClient & {
|
|
58
52
|
/**
|
|
59
53
|
* Broadcasts a block proposal to other peers.
|
|
60
54
|
*
|
|
@@ -140,14 +134,6 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
140
134
|
*/
|
|
141
135
|
hasTxsInPool(txHashes: TxHash[]): Promise<boolean[]>;
|
|
142
136
|
|
|
143
|
-
/**
|
|
144
|
-
* Returns transactions in the transaction pool by hash, requesting from the network if not found.
|
|
145
|
-
* @param txHashes - Hashes of tx to return.
|
|
146
|
-
* @param pinnedPeerId - An optional peer id that will be used to request the tx from (in addition to other random peers).
|
|
147
|
-
* @returns An array of tx or undefined.
|
|
148
|
-
*/
|
|
149
|
-
getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]>;
|
|
150
|
-
|
|
151
137
|
/**
|
|
152
138
|
* Returns an archived transaction from the transaction pool by its hash.
|
|
153
139
|
* @param txHash - Hash of tx to return.
|
|
@@ -224,8 +210,8 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
224
210
|
|
|
225
211
|
updateP2PConfig(config: Partial<P2PConfig>): Promise<void>;
|
|
226
212
|
|
|
227
|
-
/** Validates a set of txs. */
|
|
228
|
-
|
|
213
|
+
/** Validates a set of txs received in a block proposal. */
|
|
214
|
+
validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void>;
|
|
229
215
|
|
|
230
216
|
/** Clears the db. */
|
|
231
217
|
clear(): Promise<void>;
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -18,15 +18,8 @@ import {
|
|
|
18
18
|
type L2TipsStore,
|
|
19
19
|
} from '@aztec/stdlib/block';
|
|
20
20
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
21
|
-
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
22
21
|
import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
|
|
23
|
-
import {
|
|
24
|
-
type BlockProposal,
|
|
25
|
-
CheckpointAttestation,
|
|
26
|
-
type CheckpointProposal,
|
|
27
|
-
type P2PClientType,
|
|
28
|
-
type TopicType,
|
|
29
|
-
} from '@aztec/stdlib/p2p';
|
|
22
|
+
import { type BlockProposal, CheckpointAttestation, type CheckpointProposal, type TopicType } from '@aztec/stdlib/p2p';
|
|
30
23
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
31
24
|
import { Attributes, type TelemetryClient, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
32
25
|
|
|
@@ -44,7 +37,6 @@ import {
|
|
|
44
37
|
type ReqRespSubProtocolHandler,
|
|
45
38
|
type ReqRespSubProtocolValidators,
|
|
46
39
|
} from '../services/reqresp/interface.js';
|
|
47
|
-
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
48
40
|
import type {
|
|
49
41
|
DuplicateAttestationInfo,
|
|
50
42
|
DuplicateProposalInfo,
|
|
@@ -60,10 +52,7 @@ import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
|
60
52
|
/**
|
|
61
53
|
* The P2P client implementation.
|
|
62
54
|
*/
|
|
63
|
-
export class P2PClient
|
|
64
|
-
extends WithTracer
|
|
65
|
-
implements P2P, P2P<P2PClientType.Prover>
|
|
66
|
-
{
|
|
55
|
+
export class P2PClient extends WithTracer implements P2P {
|
|
67
56
|
/** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */
|
|
68
57
|
private runningPromise!: Promise<void>;
|
|
69
58
|
|
|
@@ -95,7 +84,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
95
84
|
private slotMonitor: RunningPromise | undefined;
|
|
96
85
|
|
|
97
86
|
constructor(
|
|
98
|
-
_clientType: T,
|
|
99
87
|
private store: AztecAsyncKVStore,
|
|
100
88
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
101
89
|
mempools: MemPools,
|
|
@@ -122,27 +110,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
122
110
|
this.telemetry,
|
|
123
111
|
);
|
|
124
112
|
|
|
125
|
-
// Default to collecting all txs when we see a valid proposal
|
|
126
|
-
// This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
|
|
127
|
-
// Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
128
|
-
// TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
|
|
129
|
-
// validator-client code into here so we can validate a proposal is reasonable.
|
|
130
|
-
this.registerBlockProposalHandler(async (block, sender) => {
|
|
131
|
-
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
132
|
-
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
133
|
-
const constants = this.txCollection.getConstants();
|
|
134
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
135
|
-
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
136
|
-
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
|
|
137
|
-
if (!parentBlock) {
|
|
138
|
-
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
142
|
-
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
143
|
-
return true;
|
|
144
|
-
});
|
|
145
|
-
|
|
146
113
|
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
147
114
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
148
115
|
}
|
|
@@ -433,36 +400,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
433
400
|
this.p2pService.registerDuplicateAttestationCallback(callback);
|
|
434
401
|
}
|
|
435
402
|
|
|
436
|
-
/**
|
|
437
|
-
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
438
|
-
*/
|
|
439
|
-
private async requestTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<Tx[]> {
|
|
440
|
-
const timeoutMs = 8000; // Longer timeout for now
|
|
441
|
-
const maxRetryAttempts = 10; // Keep retrying within the timeout
|
|
442
|
-
const requests = chunkTxHashesRequest(txHashes);
|
|
443
|
-
const maxPeers = Math.min(Math.ceil(requests.length / 3), 10);
|
|
444
|
-
|
|
445
|
-
const txBatches = await this.p2pService.sendBatchRequest(
|
|
446
|
-
ReqRespSubProtocol.TX,
|
|
447
|
-
requests,
|
|
448
|
-
pinnedPeerId,
|
|
449
|
-
timeoutMs,
|
|
450
|
-
maxPeers,
|
|
451
|
-
maxRetryAttempts,
|
|
452
|
-
);
|
|
453
|
-
|
|
454
|
-
const txs = txBatches.flat();
|
|
455
|
-
if (txs.length > 0) {
|
|
456
|
-
await this.txPool.addPendingTxs(txs);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
const txHashesStr = txHashes.map(tx => tx.toString()).join(', ');
|
|
460
|
-
this.log.debug(`Requested txs ${txHashesStr} (${txs.length} / ${txHashes.length}) from peers`);
|
|
461
|
-
|
|
462
|
-
// We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
|
|
463
|
-
return txs;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
403
|
public async getPendingTxs(limit?: number, after?: TxHash): Promise<Tx[]> {
|
|
467
404
|
if (limit !== undefined && limit <= 0) {
|
|
468
405
|
throw new TypeError('limit must be greater than 0');
|
|
@@ -530,49 +467,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
530
467
|
return this.txPool.hasTxs(txHashes);
|
|
531
468
|
}
|
|
532
469
|
|
|
533
|
-
/**
|
|
534
|
-
* Returns transactions in the transaction pool by hash.
|
|
535
|
-
* If a transaction is not in the pool, it will be requested from the network.
|
|
536
|
-
* @param txHashes - Hashes of the transactions to look for.
|
|
537
|
-
* @returns The txs found, or undefined if not found in the order requested.
|
|
538
|
-
*/
|
|
539
|
-
async getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]> {
|
|
540
|
-
const txs = await Promise.all(txHashes.map(txHash => this.txPool.getTxByHash(txHash)));
|
|
541
|
-
const missingTxHashes = txs
|
|
542
|
-
.map((tx, index) => [tx, index] as const)
|
|
543
|
-
.filter(([tx, _index]) => !tx)
|
|
544
|
-
.map(([_tx, index]) => txHashes[index]);
|
|
545
|
-
|
|
546
|
-
if (missingTxHashes.length === 0) {
|
|
547
|
-
return txs as Tx[];
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
const missingTxs = await this.requestTxsByHash(missingTxHashes, pinnedPeerId);
|
|
551
|
-
// TODO: optimize
|
|
552
|
-
// Merge the found txs in order
|
|
553
|
-
const mergingTxs = txHashes.map(txHash => {
|
|
554
|
-
// Is it in the txs list from the mempool?
|
|
555
|
-
for (const tx of txs) {
|
|
556
|
-
if (tx !== undefined && tx.getTxHash().equals(txHash)) {
|
|
557
|
-
return tx;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// Is it in the fetched missing txs?
|
|
562
|
-
// Note: this is an O(n^2) operation, but we expect the number of missing txs to be small.
|
|
563
|
-
for (const tx of missingTxs) {
|
|
564
|
-
if (tx.getTxHash().equals(txHash)) {
|
|
565
|
-
return tx;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// Otherwise return undefined
|
|
570
|
-
return undefined;
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
return mergingTxs;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
470
|
/**
|
|
577
471
|
* Returns an archived transaction in the transaction pool by its hash.
|
|
578
472
|
* @param txHash - Hash of the archived transaction to look for.
|
|
@@ -775,31 +669,41 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
775
669
|
}
|
|
776
670
|
|
|
777
671
|
/**
|
|
778
|
-
* Returns true if the prune
|
|
779
|
-
* If the
|
|
780
|
-
* If they differ, the prune spans across checkpoints (epoch prune).
|
|
672
|
+
* Returns true if the prune is an epoch prune (new checkpoint number is less than old).
|
|
673
|
+
* If the checkpoint number stays the same or increases, the prune is within a checkpoint.
|
|
781
674
|
*/
|
|
782
675
|
private async isEpochPrune(newCheckpoint: CheckpointId): Promise<boolean> {
|
|
783
676
|
const tips = await this.l2Tips.getL2Tips();
|
|
784
677
|
const oldCheckpointNumber = tips.checkpointed.checkpoint.number;
|
|
785
|
-
if (oldCheckpointNumber <= CheckpointNumber.
|
|
678
|
+
if (oldCheckpointNumber <= CheckpointNumber.INITIAL) {
|
|
786
679
|
return false;
|
|
787
680
|
}
|
|
788
|
-
const
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
681
|
+
const newCheckpointNumber = newCheckpoint.number;
|
|
682
|
+
// We check that the new checkpoint number is less than the old checkpoint number in order to consider it an epoch prune.
|
|
683
|
+
// To be more certain that it is an epoch prune, we will check that at least 2 checkpoints were removed.
|
|
684
|
+
// This means we should avoid thinking checkpoints removed by L1 re-orgs are epoch prunes
|
|
685
|
+
const thresholdForEpochPrune = CheckpointNumber(oldCheckpointNumber - 2);
|
|
686
|
+
const isEpochPrune = newCheckpointNumber <= thresholdForEpochPrune;
|
|
687
|
+
if (isEpochPrune) {
|
|
688
|
+
this.log.info(`Detected epoch prune to ${newCheckpointNumber}`, {
|
|
689
|
+
oldCheckpointNumber,
|
|
690
|
+
newCheckpointNumber,
|
|
691
|
+
thresholdForEpochPrune,
|
|
692
|
+
});
|
|
693
|
+
}
|
|
792
694
|
return isEpochPrune;
|
|
793
695
|
}
|
|
794
696
|
|
|
795
697
|
/** Checks if the slot has changed and calls prepareForSlot if so. */
|
|
796
698
|
private async maybeCallPrepareForSlot(): Promise<void> {
|
|
797
|
-
|
|
798
|
-
|
|
699
|
+
// If we have a pending checkpoint available, we want to prepare the target slot - otherwise we prepare the current slot
|
|
700
|
+
// Knowledege of pending checkpoints is in the PR above
|
|
701
|
+
const { targetSlot } = this.epochCache.getTargetAndNextSlot();
|
|
702
|
+
if (targetSlot <= this.lastSlotProcessed) {
|
|
799
703
|
return;
|
|
800
704
|
}
|
|
801
|
-
this.lastSlotProcessed =
|
|
802
|
-
await this.txPool.prepareForSlot(
|
|
705
|
+
this.lastSlotProcessed = targetSlot;
|
|
706
|
+
await this.txPool.prepareForSlot(targetSlot);
|
|
803
707
|
}
|
|
804
708
|
|
|
805
709
|
private async startServiceIfSynched() {
|
|
@@ -839,8 +743,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
839
743
|
this.log.debug(`Moved from state ${P2PClientState[oldState]} to ${P2PClientState[this.currentState]}`);
|
|
840
744
|
}
|
|
841
745
|
|
|
842
|
-
public
|
|
843
|
-
return this.p2pService.
|
|
746
|
+
public validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void> {
|
|
747
|
+
return this.p2pService.validateTxsReceivedInBlockProposal(txs);
|
|
844
748
|
}
|
|
845
749
|
|
|
846
750
|
/**
|