@aztec/p2p 0.0.1-commit.6d63667d → 0.0.1-commit.858058eac

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.
Files changed (198) hide show
  1. package/dest/client/factory.d.ts +5 -5
  2. package/dest/client/factory.d.ts.map +1 -1
  3. package/dest/client/factory.js +40 -9
  4. package/dest/client/interface.d.ts +33 -15
  5. package/dest/client/interface.d.ts.map +1 -1
  6. package/dest/client/p2p_client.d.ts +33 -36
  7. package/dest/client/p2p_client.d.ts.map +1 -1
  8. package/dest/client/p2p_client.js +104 -139
  9. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +1 -1
  10. package/dest/config.d.ts +13 -4
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +11 -1
  13. package/dest/index.d.ts +2 -1
  14. package/dest/index.d.ts.map +1 -1
  15. package/dest/index.js +1 -0
  16. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +102 -88
  17. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  18. package/dest/mem_pools/attestation_pool/attestation_pool.js +436 -3
  19. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  20. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  21. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
  22. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  23. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  24. package/dest/mem_pools/attestation_pool/index.js +1 -2
  25. package/dest/mem_pools/index.d.ts +3 -2
  26. package/dest/mem_pools/index.d.ts.map +1 -1
  27. package/dest/mem_pools/index.js +1 -1
  28. package/dest/mem_pools/interface.d.ts +5 -5
  29. package/dest/mem_pools/interface.d.ts.map +1 -1
  30. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +87 -0
  31. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  32. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +180 -0
  33. package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -1
  34. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
  35. package/dest/mem_pools/tx_pool_v2/index.js +1 -0
  36. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +3 -3
  37. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  38. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +25 -3
  39. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  40. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +36 -4
  41. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -1
  42. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  43. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +77 -74
  44. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
  45. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  46. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
  47. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  48. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
  49. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  50. package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
  51. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
  52. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  53. package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
  54. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
  55. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  56. package/dest/msg_validators/tx_validator/timestamp_validator.js +2 -2
  57. package/dest/services/dummy_service.d.ts +10 -2
  58. package/dest/services/dummy_service.d.ts.map +1 -1
  59. package/dest/services/dummy_service.js +6 -0
  60. package/dest/services/encoding.d.ts +2 -2
  61. package/dest/services/encoding.d.ts.map +1 -1
  62. package/dest/services/encoding.js +2 -2
  63. package/dest/services/gossipsub/index.d.ts +3 -0
  64. package/dest/services/gossipsub/index.d.ts.map +1 -0
  65. package/dest/services/gossipsub/index.js +2 -0
  66. package/dest/services/gossipsub/scoring.d.ts +21 -3
  67. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  68. package/dest/services/gossipsub/scoring.js +24 -7
  69. package/dest/services/gossipsub/topic_score_params.d.ts +161 -0
  70. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  71. package/dest/services/gossipsub/topic_score_params.js +324 -0
  72. package/dest/services/libp2p/libp2p_service.d.ts +84 -35
  73. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  74. package/dest/services/libp2p/libp2p_service.js +364 -265
  75. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  76. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  77. package/dest/services/peer-manager/peer_scoring.js +25 -2
  78. package/dest/services/reqresp/interface.d.ts +10 -1
  79. package/dest/services/reqresp/interface.d.ts.map +1 -1
  80. package/dest/services/reqresp/interface.js +15 -1
  81. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +4 -3
  82. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  83. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +7 -1
  84. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  85. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +15 -0
  86. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  87. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  88. package/dest/services/reqresp/protocols/tx.js +20 -0
  89. package/dest/services/reqresp/reqresp.d.ts +1 -1
  90. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  91. package/dest/services/reqresp/reqresp.js +11 -4
  92. package/dest/services/service.d.ts +35 -1
  93. package/dest/services/service.d.ts.map +1 -1
  94. package/dest/services/tx_collection/config.d.ts +7 -1
  95. package/dest/services/tx_collection/config.d.ts.map +1 -1
  96. package/dest/services/tx_collection/config.js +16 -0
  97. package/dest/services/tx_collection/fast_tx_collection.d.ts +3 -1
  98. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  99. package/dest/services/tx_collection/fast_tx_collection.js +17 -3
  100. package/dest/services/tx_collection/file_store_tx_collection.d.ts +44 -0
  101. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  102. package/dest/services/tx_collection/file_store_tx_collection.js +118 -0
  103. package/dest/services/tx_collection/file_store_tx_source.d.ts +27 -0
  104. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  105. package/dest/services/tx_collection/file_store_tx_source.js +57 -0
  106. package/dest/services/tx_collection/index.d.ts +2 -1
  107. package/dest/services/tx_collection/index.d.ts.map +1 -1
  108. package/dest/services/tx_collection/index.js +1 -0
  109. package/dest/services/tx_collection/slow_tx_collection.d.ts +3 -1
  110. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  111. package/dest/services/tx_collection/slow_tx_collection.js +48 -19
  112. package/dest/services/tx_collection/tx_collection.d.ts +17 -7
  113. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  114. package/dest/services/tx_collection/tx_collection.js +58 -2
  115. package/dest/services/tx_collection/tx_collection_sink.d.ts +15 -6
  116. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  117. package/dest/services/tx_collection/tx_collection_sink.js +13 -7
  118. package/dest/services/tx_file_store/config.d.ts +1 -3
  119. package/dest/services/tx_file_store/config.d.ts.map +1 -1
  120. package/dest/services/tx_file_store/config.js +0 -4
  121. package/dest/services/tx_file_store/tx_file_store.d.ts +3 -3
  122. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  123. package/dest/services/tx_provider.d.ts +3 -3
  124. package/dest/services/tx_provider.d.ts.map +1 -1
  125. package/dest/services/tx_provider.js +5 -4
  126. package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
  127. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  128. package/dest/test-helpers/mock-pubsub.d.ts +27 -1
  129. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  130. package/dest/test-helpers/mock-pubsub.js +97 -2
  131. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  132. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  133. package/dest/test-helpers/reqresp-nodes.js +2 -1
  134. package/dest/test-helpers/testbench-utils.d.ts +38 -38
  135. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  136. package/dest/test-helpers/testbench-utils.js +124 -61
  137. package/dest/testbench/p2p_client_testbench_worker.js +2 -2
  138. package/package.json +14 -14
  139. package/src/client/factory.ts +68 -12
  140. package/src/client/interface.ts +39 -14
  141. package/src/client/p2p_client.ts +139 -162
  142. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +1 -1
  143. package/src/config.ts +26 -2
  144. package/src/index.ts +1 -0
  145. package/src/mem_pools/attestation_pool/attestation_pool.ts +488 -91
  146. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
  147. package/src/mem_pools/attestation_pool/index.ts +9 -2
  148. package/src/mem_pools/index.ts +4 -1
  149. package/src/mem_pools/interface.ts +4 -4
  150. package/src/mem_pools/tx_pool_v2/README.md +59 -9
  151. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +234 -0
  152. package/src/mem_pools/tx_pool_v2/index.ts +1 -0
  153. package/src/mem_pools/tx_pool_v2/interfaces.ts +2 -2
  154. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +51 -5
  155. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +90 -77
  156. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
  157. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
  158. package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
  159. package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
  160. package/src/msg_validators/tx_validator/timestamp_validator.ts +19 -14
  161. package/src/services/dummy_service.ts +12 -0
  162. package/src/services/encoding.ts +2 -2
  163. package/src/services/gossipsub/README.md +626 -0
  164. package/src/services/gossipsub/index.ts +2 -0
  165. package/src/services/gossipsub/scoring.ts +29 -5
  166. package/src/services/gossipsub/topic_score_params.ts +451 -0
  167. package/src/services/libp2p/libp2p_service.ts +360 -269
  168. package/src/services/peer-manager/peer_scoring.ts +25 -0
  169. package/src/services/reqresp/interface.ts +26 -1
  170. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +4 -3
  171. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +17 -0
  172. package/src/services/reqresp/protocols/tx.ts +22 -0
  173. package/src/services/reqresp/reqresp.ts +13 -3
  174. package/src/services/service.ts +40 -0
  175. package/src/services/tx_collection/config.ts +26 -0
  176. package/src/services/tx_collection/fast_tx_collection.ts +14 -2
  177. package/src/services/tx_collection/file_store_tx_collection.ts +152 -0
  178. package/src/services/tx_collection/file_store_tx_source.ts +70 -0
  179. package/src/services/tx_collection/index.ts +1 -0
  180. package/src/services/tx_collection/slow_tx_collection.ts +55 -26
  181. package/src/services/tx_collection/tx_collection.ts +78 -12
  182. package/src/services/tx_collection/tx_collection_sink.ts +17 -7
  183. package/src/services/tx_file_store/config.ts +0 -6
  184. package/src/services/tx_file_store/tx_file_store.ts +4 -4
  185. package/src/services/tx_provider.ts +8 -7
  186. package/src/test-helpers/make-test-p2p-clients.ts +3 -3
  187. package/src/test-helpers/mock-pubsub.ts +133 -3
  188. package/src/test-helpers/reqresp-nodes.ts +2 -1
  189. package/src/test-helpers/testbench-utils.ts +122 -74
  190. package/src/testbench/p2p_client_testbench_worker.ts +2 -2
  191. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  192. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  193. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  194. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  195. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  196. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  197. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  198. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/p2p",
3
- "version": "0.0.1-commit.6d63667d",
3
+ "version": "0.0.1-commit.858058eac",
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.6d63667d",
71
- "@aztec/epoch-cache": "0.0.1-commit.6d63667d",
72
- "@aztec/ethereum": "0.0.1-commit.6d63667d",
73
- "@aztec/foundation": "0.0.1-commit.6d63667d",
74
- "@aztec/kv-store": "0.0.1-commit.6d63667d",
75
- "@aztec/noir-contracts.js": "0.0.1-commit.6d63667d",
76
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.6d63667d",
77
- "@aztec/protocol-contracts": "0.0.1-commit.6d63667d",
78
- "@aztec/simulator": "0.0.1-commit.6d63667d",
79
- "@aztec/stdlib": "0.0.1-commit.6d63667d",
80
- "@aztec/telemetry-client": "0.0.1-commit.6d63667d",
70
+ "@aztec/constants": "0.0.1-commit.858058eac",
71
+ "@aztec/epoch-cache": "0.0.1-commit.858058eac",
72
+ "@aztec/ethereum": "0.0.1-commit.858058eac",
73
+ "@aztec/foundation": "0.0.1-commit.858058eac",
74
+ "@aztec/kv-store": "0.0.1-commit.858058eac",
75
+ "@aztec/noir-contracts.js": "0.0.1-commit.858058eac",
76
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.858058eac",
77
+ "@aztec/protocol-contracts": "0.0.1-commit.858058eac",
78
+ "@aztec/simulator": "0.0.1-commit.858058eac",
79
+ "@aztec/stdlib": "0.0.1-commit.858058eac",
80
+ "@aztec/telemetry-client": "0.0.1-commit.858058eac",
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.6d63667d",
108
- "@aztec/world-state": "0.0.1-commit.6d63667d",
107
+ "@aztec/archiver": "0.0.1-commit.858058eac",
108
+ "@aztec/world-state": "0.0.1-commit.858058eac",
109
109
  "@jest/globals": "^30.0.0",
110
110
  "@types/jest": "^30.0.0",
111
111
  "@types/node": "^22.15.17",
@@ -4,30 +4,36 @@ import { DateProvider } from '@aztec/foundation/timer';
4
4
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
5
5
  import type { DataStoreConfig } from '@aztec/kv-store/config';
6
6
  import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
7
- import type { L2BlockSource } from '@aztec/stdlib/block';
7
+ import type { BlockHash, 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 { ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
11
11
  import { P2PClientType } from '@aztec/stdlib/p2p';
12
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
12
13
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
13
14
 
14
15
  import { P2PClient } from '../client/p2p_client.js';
15
16
  import type { P2PConfig } from '../config.js';
16
- import type { AttestationPool } from '../mem_pools/attestation_pool/attestation_pool.js';
17
- import { KvAttestationPool } from '../mem_pools/attestation_pool/kv_attestation_pool.js';
17
+ import { AttestationPool, type AttestationPoolApi } from '../mem_pools/attestation_pool/attestation_pool.js';
18
18
  import type { MemPools } from '../mem_pools/interface.js';
19
- import { AztecKVTxPool, type TxPool } from '../mem_pools/tx_pool/index.js';
19
+ 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
+ import { AztecKVTxPoolV2 } from '../mem_pools/tx_pool_v2/tx_pool_v2.js';
22
+ import { AggregateTxValidator } from '../msg_validators/tx_validator/aggregate_tx_validator.js';
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
25
  import { DummyP2PService } from '../services/dummy_service.js';
21
26
  import { LibP2PService } from '../services/index.js';
27
+ import { createFileStoreTxSources } from '../services/tx_collection/file_store_tx_source.js';
22
28
  import { TxCollection } from '../services/tx_collection/tx_collection.js';
23
29
  import { type TxSource, createNodeRpcTxSources } from '../services/tx_collection/tx_source.js';
24
30
  import { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
25
31
  import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
26
32
 
27
33
  export type P2PClientDeps<T extends P2PClientType> = {
28
- txPool?: TxPool;
34
+ txPool?: TxPoolV2;
29
35
  store?: AztecAsyncKVStore;
30
- attestationPool?: AttestationPool;
36
+ attestationPool?: AttestationPoolApi;
31
37
  logger?: Logger;
32
38
  txCollectionNodeSources?: TxSource[];
33
39
  p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService<T>>;
@@ -70,14 +76,52 @@ export async function createP2PClient<T extends P2PClientType>(
70
76
  const attestationStore = await createStore(P2P_ATTESTATION_STORE_NAME, 1, config, bindings);
71
77
  const l1Constants = await archiver.getL1Constants();
72
78
 
73
- const mempools: MemPools = {
74
- txPool:
75
- deps.txPool ??
76
- new AztecKVTxPool(store, archive, worldStateSynchronizer, telemetry, {
79
+ /** Validator factory for pool re-validation (double-spend + block header only). */
80
+ const createPoolTxValidator = async () => {
81
+ await worldStateSynchronizer.syncImmediate();
82
+ return new AggregateTxValidator<TxMetaData>(
83
+ new DoubleSpendTxValidator<TxMetaData>(
84
+ {
85
+ nullifiersExist: async (nullifiers: Buffer[]) => {
86
+ const merkleTree = worldStateSynchronizer.getCommitted();
87
+ const indices = await merkleTree.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers);
88
+ return indices.map(index => index !== undefined);
89
+ },
90
+ },
91
+ bindings,
92
+ ),
93
+ new BlockHeaderTxValidator<TxMetaData>(
94
+ {
95
+ getArchiveIndices: (archives: BlockHash[]) => {
96
+ const merkleTree = worldStateSynchronizer.getCommitted();
97
+ return merkleTree.findLeafIndices(MerkleTreeId.ARCHIVE, archives);
98
+ },
99
+ },
100
+ bindings,
101
+ ),
102
+ );
103
+ };
104
+
105
+ const txPool =
106
+ deps.txPool ??
107
+ new AztecKVTxPoolV2(
108
+ store,
109
+ archive,
110
+ {
111
+ l2BlockSource: archiver,
112
+ worldStateSynchronizer,
113
+ createTxValidator: createPoolTxValidator,
114
+ },
115
+ telemetry,
116
+ {
77
117
  maxPendingTxCount: config.maxPendingTxCount,
78
118
  archivedTxLimit: config.archivedTxLimit,
79
- }),
80
- attestationPool: deps.attestationPool ?? new KvAttestationPool(attestationStore, telemetry),
119
+ },
120
+ );
121
+
122
+ const mempools: MemPools = {
123
+ txPool,
124
+ attestationPool: deps.attestationPool ?? new AttestationPool(attestationStore, telemetry),
81
125
  };
82
126
 
83
127
  const p2pService = await createP2PService<T>(
@@ -106,12 +150,23 @@ export async function createP2PClient<T extends P2PClientType>(
106
150
  });
107
151
  }
108
152
 
153
+ const fileStoreSources = await createFileStoreTxSources(
154
+ config.txCollectionFileStoreUrls,
155
+ logger.createChild('file-store-tx-source'),
156
+ );
157
+ if (fileStoreSources.length > 0) {
158
+ logger.info(`Using ${fileStoreSources.length} file store sources for tx collection.`, {
159
+ stores: fileStoreSources.map(s => s.getInfo()),
160
+ });
161
+ }
162
+
109
163
  const txCollection = new TxCollection(
110
164
  p2pService.getBatchTxRequesterService(),
111
165
  nodeSources,
112
166
  l1Constants,
113
167
  mempools.txPool,
114
168
  config,
169
+ fileStoreSources,
115
170
  dateProvider,
116
171
  telemetry,
117
172
  logger.createChild('tx-collection'),
@@ -127,6 +182,7 @@ export async function createP2PClient<T extends P2PClientType>(
127
182
  p2pService,
128
183
  txCollection,
129
184
  txFileStore,
185
+ epochCache,
130
186
  config,
131
187
  dateProvider,
132
188
  telemetry,
@@ -1,7 +1,8 @@
1
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
2
3
  import type { P2PApiFull } from '@aztec/stdlib/interfaces/server';
3
4
  import type { BlockProposal, CheckpointAttestation, CheckpointProposal, P2PClientType } from '@aztec/stdlib/p2p';
4
- import type { Tx, TxHash } from '@aztec/stdlib/tx';
5
+ import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
5
6
 
6
7
  import type { PeerId } from '@libp2p/interface';
7
8
  import type { ENR } from '@nethermindeth/enr';
@@ -13,7 +14,12 @@ import type {
13
14
  ReqRespSubProtocolHandler,
14
15
  ReqRespSubProtocolValidators,
15
16
  } from '../services/reqresp/interface.js';
16
- import type { P2PBlockReceivedCallback, P2PCheckpointReceivedCallback } from '../services/service.js';
17
+ import type {
18
+ DuplicateAttestationInfo,
19
+ DuplicateProposalInfo,
20
+ P2PBlockReceivedCallback,
21
+ P2PCheckpointReceivedCallback,
22
+ } from '../services/service.js';
17
23
 
18
24
  /**
19
25
  * Enum defining the possible states of the p2p client.
@@ -79,12 +85,21 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
79
85
  registerCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
80
86
 
81
87
  /**
82
- * Request a list of transactions from another peer by their tx hashes.
83
- * @param txHashes - Hashes of the txs to query.
84
- * @param pinnedPeerId - An optional peer id that will be used to request the tx from (in addition to other random peers).
85
- * @returns A list of transactions or undefined if the transactions are not found.
88
+ * Registers a callback invoked when a duplicate proposal is detected (equivocation).
89
+ * The callback is triggered on the first duplicate (when count goes from 1 to 2).
90
+ *
91
+ * @param callback - Function called with info about the duplicate proposal
92
+ */
93
+ registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void;
94
+
95
+ /**
96
+ * Registers a callback invoked when a duplicate attestation is detected (equivocation).
97
+ * A validator signing attestations for different proposals at the same slot.
98
+ * The callback is triggered on the first duplicate (when count goes from 1 to 2).
99
+ *
100
+ * @param callback - Function called with info about the duplicate attestation
86
101
  */
87
- requestTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId): Promise<Tx[]>;
102
+ registerDuplicateAttestationCallback(callback: (info: DuplicateAttestationInfo) => void): void;
88
103
 
89
104
  /**
90
105
  * Verifies the 'tx' and, if valid, adds it to local tx pool and forwards it to other peers.
@@ -100,11 +115,10 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
100
115
  addTxsToPool(txs: Tx[]): Promise<number>;
101
116
 
102
117
  /**
103
- * Deletes 'txs' from the pool, given hashes.
104
- * NOT used if we use sendTx as reconcileTxPool will handle this.
105
- * @param txHashes - Hashes to check.
118
+ * Handles failed transaction execution by removing txs from the pool.
119
+ * @param txHashes - Hashes of the transactions that failed execution.
106
120
  **/
107
- deleteTxs(txHashes: TxHash[]): Promise<void>;
121
+ handleFailedExecution(txHashes: TxHash[]): Promise<void>;
108
122
 
109
123
  /**
110
124
  * Returns a transaction in the transaction pool by its hash.
@@ -156,10 +170,21 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
156
170
  getPendingTxCount(): Promise<number>;
157
171
 
158
172
  /**
159
- * Marks transactions as non-evictable in the pool.
160
- * @param txHashes - Hashes of the transactions to mark as non-evictable.
173
+ * Protects existing transactions by hash for a given slot.
174
+ * Returns hashes of transactions that weren't found in the pool.
175
+ * @param txHashes - Hashes of the transactions to protect.
176
+ * @param blockHeader - The block header providing slot context.
177
+ * @returns Hashes of transactions not found in the pool.
178
+ */
179
+ protectTxs(txHashes: TxHash[], blockHeader: BlockHeader): Promise<TxHash[]>;
180
+
181
+ /**
182
+ * Prepares the pool for a new slot.
183
+ * Unprotects transactions from earlier slots and validates them before
184
+ * returning to pending state.
185
+ * @param slotNumber - The slot number to prepare for
161
186
  */
162
- markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void>;
187
+ prepareForSlot(slotNumber: SlotNumber): Promise<void>;
163
188
 
164
189
  /**
165
190
  * Starts the p2p client.