@aztec/p2p 0.0.1-commit.cf93bcc56 → 0.0.1-commit.d0fcfb7f
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 +4 -5
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +20 -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 +35 -86
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
- package/dest/config.d.ts +29 -10
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +80 -31
- 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.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 +10 -6
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +38 -7
- 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 +9 -10
- 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 +2 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +5 -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 +169 -141
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +48 -36
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/factory.d.ts +125 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +226 -58
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +67 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +104 -37
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/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 +92 -93
- 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 +5 -9
- 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/tx_validator.js +2 -2
- 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 +3 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +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 +4 -1
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +28 -46
- package/src/client/interface.ts +8 -13
- package/src/client/p2p_client.ts +35 -113
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -10
- package/src/config.ts +115 -33
- 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 +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 +8 -5
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +102 -17
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +11 -11
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +3 -3
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +178 -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 +366 -77
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +123 -27
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/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 +106 -101
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +6 -6
- 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/tx_validator.ts +2 -2
- 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 +0 -2
- package/src/test-helpers/mock-pubsub.ts +13 -6
- package/src/test-helpers/reqresp-nodes.ts +2 -5
- package/src/test-helpers/testbench-utils.ts +3 -2
- package/src/testbench/p2p_client_testbench_worker.ts +21 -17
- package/src/testbench/worker_client_manager.ts +11 -4
- package/src/util.ts +7 -1
- 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/dest/util.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ 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'> {
|
|
12
12
|
services: {
|
|
13
|
-
pubsub: Pick<GossipSub, 'addEventListener' | 'removeEventListener' | 'publish' | 'subscribe' | 'reportMessageValidationResult' | 'direct'> & {
|
|
13
|
+
pubsub: Pick<GossipSub, 'addEventListener' | 'removeEventListener' | 'publish' | 'subscribe' | 'reportMessageValidationResult' | 'direct' | 'getMeshPeers'> & {
|
|
14
14
|
score: Pick<GossipSub['score'], 'score'>;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
@@ -58,4 +58,4 @@ export declare function getPeerIdPrivateKey(config: {
|
|
|
58
58
|
* @returns The peer ID.
|
|
59
59
|
*/
|
|
60
60
|
export declare function createLibP2PPeerIdFromPrivateKey(privateKey: string): Promise<PeerId>;
|
|
61
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
61
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid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,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,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,SAAS,GAAG,eAAe,GACnC,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC,CAmBtC;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/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.d0fcfb7f",
|
|
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.d0fcfb7f",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.d0fcfb7f",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.d0fcfb7f",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.d0fcfb7f",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.d0fcfb7f",
|
|
75
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.d0fcfb7f",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.d0fcfb7f",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.d0fcfb7f",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.d0fcfb7f",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.d0fcfb7f",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.d0fcfb7f",
|
|
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.d0fcfb7f",
|
|
108
|
+
"@aztec/world-state": "0.0.1-commit.d0fcfb7f",
|
|
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
6
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
6
7
|
import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
|
|
7
|
-
import type {
|
|
8
|
+
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
8
9
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
9
10
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
11
|
import type { AztecNode, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
12
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
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,29 @@ 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
|
+
const l1Constants = await archiver.getL1Constants();
|
|
91
|
+
return createTxValidatorForTransactionsEnteringPendingTxPool(
|
|
92
|
+
worldStateSynchronizer,
|
|
93
|
+
nextSlotTimestamp,
|
|
94
|
+
BlockNumber(currentBlockNumber + 1),
|
|
95
|
+
{
|
|
96
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
97
|
+
maxBlockL2Gas: config.validateMaxL2BlockGas,
|
|
98
|
+
maxBlockDAGas: config.validateMaxDABlockGas,
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
},
|
|
118
102
|
},
|
|
119
103
|
telemetry,
|
|
120
104
|
{
|
|
121
105
|
maxPendingTxCount: config.maxPendingTxCount,
|
|
122
106
|
archivedTxLimit: config.archivedTxLimit,
|
|
123
107
|
minTxPoolAgeMs: config.minTxPoolAgeMs,
|
|
108
|
+
priceBumpPercentage: config.priceBumpPercentage,
|
|
124
109
|
},
|
|
125
110
|
dateProvider,
|
|
126
111
|
);
|
|
@@ -130,9 +115,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
130
115
|
attestationPool: deps.attestationPool ?? new AttestationPool(attestationStore, telemetry),
|
|
131
116
|
};
|
|
132
117
|
|
|
133
|
-
const p2pService = await createP2PService
|
|
118
|
+
const p2pService = await createP2PService(
|
|
134
119
|
config,
|
|
135
|
-
clientType,
|
|
136
120
|
archiver,
|
|
137
121
|
proofVerifier,
|
|
138
122
|
worldStateSynchronizer,
|
|
@@ -190,7 +174,6 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
190
174
|
);
|
|
191
175
|
|
|
192
176
|
return new P2PClient(
|
|
193
|
-
clientType,
|
|
194
177
|
store,
|
|
195
178
|
archiver,
|
|
196
179
|
mempools,
|
|
@@ -204,9 +187,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
204
187
|
);
|
|
205
188
|
}
|
|
206
189
|
|
|
207
|
-
async function createP2PService
|
|
190
|
+
async function createP2PService(
|
|
208
191
|
config: P2PConfig & DataStoreConfig,
|
|
209
|
-
clientType: T,
|
|
210
192
|
archiver: L2BlockSource & ContractDataSource,
|
|
211
193
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
212
194
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
@@ -214,7 +196,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
214
196
|
store: AztecAsyncKVStore,
|
|
215
197
|
peerStore: AztecLMDBStoreV2,
|
|
216
198
|
mempools: MemPools,
|
|
217
|
-
p2pServiceFactory: P2PClientDeps
|
|
199
|
+
p2pServiceFactory: P2PClientDeps['p2pServiceFactory'],
|
|
218
200
|
packageVersion: string,
|
|
219
201
|
logger: Logger,
|
|
220
202
|
telemetry: TelemetryClient,
|
|
@@ -230,7 +212,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
230
212
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
|
|
231
213
|
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey.getValue());
|
|
232
214
|
|
|
233
|
-
const p2pService = await (p2pServiceFactory ?? LibP2PService.new
|
|
215
|
+
const p2pService = await (p2pServiceFactory ?? LibP2PService.new)(config, peerId, {
|
|
234
216
|
packageVersion,
|
|
235
217
|
mempools,
|
|
236
218
|
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,32 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
759
659
|
|
|
760
660
|
/**
|
|
761
661
|
* Updates the tx pool after a chain prune.
|
|
662
|
+
* Detects epoch prunes (checkpoint number changed) and deletes all txs in that case.
|
|
762
663
|
* @param latestBlock - The block ID the chain was pruned to.
|
|
664
|
+
* @param newCheckpoint - The checkpoint ID after the prune.
|
|
763
665
|
*/
|
|
764
|
-
private async handlePruneL2Blocks(latestBlock: L2BlockId): Promise<void> {
|
|
765
|
-
|
|
666
|
+
private async handlePruneL2Blocks(latestBlock: L2BlockId, newCheckpoint: CheckpointId): Promise<void> {
|
|
667
|
+
const deleteAllTxs = this.config.txPoolDeleteTxsAfterReorg && (await this.isEpochPrune(newCheckpoint));
|
|
668
|
+
await this.txPool.handlePrunedBlocks(latestBlock, { deleteAllTxs });
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Returns true if the prune crossed a checkpoint boundary.
|
|
673
|
+
* If the old and new checkpoint numbers are the same, the prune is within a single checkpoint.
|
|
674
|
+
* If they differ, the prune spans across checkpoints (epoch prune).
|
|
675
|
+
*/
|
|
676
|
+
private async isEpochPrune(newCheckpoint: CheckpointId): Promise<boolean> {
|
|
677
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
678
|
+
const oldCheckpointNumber = tips.checkpointed.checkpoint.number;
|
|
679
|
+
if (oldCheckpointNumber <= CheckpointNumber.ZERO) {
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
const newCheckpointNumber = newCheckpoint.number;
|
|
683
|
+
const isEpochPrune = oldCheckpointNumber !== newCheckpointNumber;
|
|
684
|
+
if (isEpochPrune) {
|
|
685
|
+
this.log.info(`Detected epoch prune to ${newCheckpointNumber}`, { oldCheckpointNumber, newCheckpointNumber });
|
|
686
|
+
}
|
|
687
|
+
return isEpochPrune;
|
|
766
688
|
}
|
|
767
689
|
|
|
768
690
|
/** Checks if the slot has changed and calls prepareForSlot if so. */
|
|
@@ -812,8 +734,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
812
734
|
this.log.debug(`Moved from state ${P2PClientState[oldState]} to ${P2PClientState[this.currentState]}`);
|
|
813
735
|
}
|
|
814
736
|
|
|
815
|
-
public
|
|
816
|
-
return this.p2pService.
|
|
737
|
+
public validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void> {
|
|
738
|
+
return this.p2pService.validateTxsReceivedInBlockProposal(txs);
|
|
817
739
|
}
|
|
818
740
|
|
|
819
741
|
/**
|
|
@@ -8,7 +8,7 @@ import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
|
8
8
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
9
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
10
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import {
|
|
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
|
);
|