@aztec/p2p 0.85.0 → 0.86.0

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 (90) hide show
  1. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  2. package/dest/bootstrap/bootstrap.js +6 -3
  3. package/dest/client/p2p_client.d.ts +41 -3
  4. package/dest/client/p2p_client.d.ts.map +1 -1
  5. package/dest/client/p2p_client.js +58 -18
  6. package/dest/config.d.ts +13 -2
  7. package/dest/config.d.ts.map +1 -1
  8. package/dest/config.js +15 -3
  9. package/dest/enr/generate-enr.d.ts +1 -1
  10. package/dest/enr/generate-enr.d.ts.map +1 -1
  11. package/dest/enr/generate-enr.js +2 -2
  12. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  13. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +11 -11
  14. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +2 -2
  15. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
  16. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +4 -4
  17. package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
  18. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  19. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  20. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +3 -0
  21. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  22. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +18 -0
  23. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +3 -0
  24. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
  25. package/dest/mem_pools/tx_pool/memory_tx_pool.js +9 -0
  26. package/dest/mem_pools/tx_pool/tx_pool.d.ts +17 -0
  27. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
  28. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  29. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +57 -0
  30. package/dest/msg_validators/attestation_validator/attestation_validator.js +1 -1
  31. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +1 -0
  32. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
  33. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +6 -1
  34. package/dest/services/discv5/discV5_service.d.ts +2 -1
  35. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  36. package/dest/services/discv5/discV5_service.js +22 -7
  37. package/dest/services/dummy_service.d.ts +2 -2
  38. package/dest/services/dummy_service.d.ts.map +1 -1
  39. package/dest/services/dummy_service.js +2 -2
  40. package/dest/services/libp2p/libp2p_service.d.ts +3 -1
  41. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  42. package/dest/services/libp2p/libp2p_service.js +28 -12
  43. package/dest/services/peer-manager/peer_manager.d.ts +21 -2
  44. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  45. package/dest/services/peer-manager/peer_manager.js +63 -18
  46. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +2 -2
  47. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +17 -1
  48. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  49. package/dest/services/reqresp/connection-sampler/connection_sampler.js +84 -36
  50. package/dest/services/reqresp/reqresp.d.ts +2 -2
  51. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  52. package/dest/services/reqresp/reqresp.js +7 -2
  53. package/dest/services/reqresp/status.d.ts +2 -1
  54. package/dest/services/reqresp/status.d.ts.map +1 -1
  55. package/dest/services/reqresp/status.js +3 -0
  56. package/dest/services/service.d.ts +4 -4
  57. package/dest/services/service.d.ts.map +1 -1
  58. package/dest/test-helpers/make-test-p2p-clients.d.ts +6 -1
  59. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  60. package/dest/test-helpers/make-test-p2p-clients.js +19 -2
  61. package/dest/testbench/p2p_client_testbench_worker.js +4 -1
  62. package/dest/util.d.ts.map +1 -1
  63. package/dest/util.js +5 -1
  64. package/package.json +12 -14
  65. package/src/bootstrap/bootstrap.ts +8 -4
  66. package/src/client/p2p_client.ts +212 -131
  67. package/src/config.ts +34 -4
  68. package/src/enr/generate-enr.ts +2 -2
  69. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +11 -15
  70. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +2 -2
  71. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +4 -4
  72. package/src/mem_pools/attestation_pool/mocks.ts +3 -3
  73. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +21 -0
  74. package/src/mem_pools/tx_pool/memory_tx_pool.ts +11 -0
  75. package/src/mem_pools/tx_pool/tx_pool.ts +20 -0
  76. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +43 -0
  77. package/src/msg_validators/attestation_validator/attestation_validator.ts +1 -1
  78. package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +10 -1
  79. package/src/services/discv5/discV5_service.ts +32 -6
  80. package/src/services/dummy_service.ts +2 -2
  81. package/src/services/libp2p/libp2p_service.ts +37 -12
  82. package/src/services/peer-manager/peer_manager.ts +79 -22
  83. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +2 -2
  84. package/src/services/reqresp/connection-sampler/connection_sampler.ts +82 -41
  85. package/src/services/reqresp/reqresp.ts +12 -6
  86. package/src/services/reqresp/status.ts +3 -0
  87. package/src/services/service.ts +4 -4
  88. package/src/test-helpers/make-test-p2p-clients.ts +20 -2
  89. package/src/testbench/p2p_client_testbench_worker.ts +3 -0
  90. package/src/util.ts +6 -1
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iB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AAO,CAAC,MAAM,CAAC,CAAS;gBAGd,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,eAAe,EAC1B,MAAM,yCAAgC;IAGhD;;;;OAIG;IACU,KAAK,CAAC,MAAM,EAAE,cAAc;IAwEzC;;;OAGG;IACU,IAAI;IAOjB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,YAAY;IAMpB;;;OAGG;IACI,SAAS;IAKT,MAAM;IAKN,aAAa;IAKb,eAAe;CAIvB"}
@@ -24,13 +24,16 @@ import { convertToMultiaddr, getPeerIdPrivateKey } from '../util.js';
24
24
  * @param config - A partial P2P configuration. No need for TCP values as well as aztec node specific values.
25
25
  * @returns An empty promise.
26
26
  */ async start(config) {
27
- const { p2pIp, p2pPort, listenAddress } = config;
28
- const listenAddrUdp = multiaddr(convertToMultiaddr(listenAddress, p2pPort, 'udp'));
27
+ const { p2pIp, p2pPort, listenAddress, p2pBroadcastPort } = config;
29
28
  if (!p2pIp) {
30
29
  throw new Error('You need to provide a P2P IP address.');
31
30
  }
31
+ if (!p2pBroadcastPort) {
32
+ config.p2pBroadcastPort = p2pPort;
33
+ }
34
+ const listenAddrUdp = multiaddr(convertToMultiaddr(listenAddress, config.p2pBroadcastPort, 'udp'));
32
35
  const peerIdPrivateKey = await getPeerIdPrivateKey(config, this.store, this.logger);
33
- const { enr: ourEnr, peerId } = await createBootnodeENRandPeerId(peerIdPrivateKey, p2pIp, p2pPort, config.l1ChainId);
36
+ const { enr: ourEnr, peerId } = await createBootnodeENRandPeerId(peerIdPrivateKey, p2pIp, config.p2pBroadcastPort, config.l1ChainId);
34
37
  this.peerId = peerId;
35
38
  this.logger.debug(`Starting bootstrap node ${peerId} listening on ${listenAddrUdp.toString()}`);
36
39
  const metricsRegistry = new OtelMetricsAdapter(this.telemetry);
@@ -1,7 +1,7 @@
1
1
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
2
2
  import type { L2BlockId, L2BlockSource, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
3
3
  import type { ContractDataSource } from '@aztec/stdlib/contract';
4
- import type { P2PApi, PeerInfo, ProverCoordination } from '@aztec/stdlib/interfaces/server';
4
+ import type { P2PApi, PeerInfo } from '@aztec/stdlib/interfaces/server';
5
5
  import { BlockAttestation, type BlockProposal, type P2PClientType } from '@aztec/stdlib/p2p';
6
6
  import type { Tx, TxHash } from '@aztec/stdlib/tx';
7
7
  import { type TelemetryClient, WithTracer } from '@aztec/telemetry-client';
@@ -34,7 +34,7 @@ export interface P2PSyncState {
34
34
  /**
35
35
  * Interface of a P2P client.
36
36
  **/
37
- export type P2P<T extends P2PClientType = P2PClientType.Full> = ProverCoordination & P2PApi<T> & {
37
+ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApi<T> & {
38
38
  /**
39
39
  * Broadcasts a block proposal to other peers.
40
40
  *
@@ -64,6 +64,11 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = ProverCoordinati
64
64
  * @param tx - The transaction.
65
65
  **/
66
66
  sendTx(tx: Tx): Promise<void>;
67
+ /**
68
+ * Adds transactions to the pool. Does not send to peers or validate the tx.
69
+ * @param txs - The transactions.
70
+ **/
71
+ addTxs(txs: Tx[]): Promise<void>;
67
72
  /**
68
73
  * Deletes 'txs' from the pool, given hashes.
69
74
  * NOT used if we use sendTx as reconcileTxPool will handle this.
@@ -76,12 +81,30 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = ProverCoordinati
76
81
  * @returns A single tx or undefined.
77
82
  */
78
83
  getTxByHashFromPool(txHash: TxHash): Promise<Tx | undefined>;
84
+ /**
85
+ * Returns transactions in the transaction pool by hash.
86
+ * @param txHashes - Hashes of txs to return.
87
+ * @returns An array of txs or undefined.
88
+ */
89
+ getTxsByHashFromPool(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
90
+ /**
91
+ * Checks if transactions exist in the pool
92
+ * @param txHashes - The hashes of the transactions to check for
93
+ * @returns True or False for each hash
94
+ */
95
+ hasTxsInPool(txHashes: TxHash[]): Promise<boolean[]>;
79
96
  /**
80
97
  * Returns a transaction in the transaction pool by its hash, requesting it from the network if it is not found.
81
98
  * @param txHash - Hash of tx to return.
82
99
  * @returns A single tx or undefined.
83
100
  */
84
101
  getTxByHash(txHash: TxHash): Promise<Tx | undefined>;
102
+ /**
103
+ * Returns transactions in the transaction pool by hash, requesting from the network if not found.
104
+ * @param txHashes - Hashes of tx to return.
105
+ * @returns An array of tx or undefined.
106
+ */
107
+ getTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
85
108
  /**
86
109
  * Returns an archived transaction from the transaction pool by its hash.
87
110
  * @param txHash - Hash of tx to return.
@@ -123,6 +146,7 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = ProverCoordinati
123
146
  getEnr(): ENR | undefined;
124
147
  /** Identifies a p2p client. */
125
148
  isP2PClient(): true;
149
+ updateP2PConfig(config: Partial<P2PConfig>): Promise<void>;
126
150
  };
127
151
  /**
128
152
  * The P2P client implementation.
@@ -150,6 +174,7 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
150
174
  /** How many slots to keep proven txs for. */
151
175
  private keepProvenTxsFor;
152
176
  private blockStream;
177
+ private config;
153
178
  /**
154
179
  * In-memory P2P client constructor.
155
180
  * @param store - The client's instance of the KV store.
@@ -163,6 +188,7 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
163
188
  isP2PClient(): true;
164
189
  getPeers(includePending?: boolean): Promise<PeerInfo[]>;
165
190
  getL2BlockHash(number: number): Promise<string | undefined>;
191
+ updateP2PConfig(config: Partial<P2PConfig>): Promise<void>;
166
192
  getL2Tips(): Promise<L2Tips>;
167
193
  handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void>;
168
194
  /**
@@ -204,7 +230,7 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
204
230
  /**
205
231
  * Uses the batched Request Response protocol to request a set of transactions from the network.
206
232
  */
207
- requestTxsByHash(txHashes: TxHash[]): Promise<Tx[]>;
233
+ requestTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
208
234
  getPendingTxs(): Promise<Tx[]>;
209
235
  getPendingTxCount(): Promise<number>;
210
236
  iteratePendingTxs(): AsyncIterableIterator<Tx>;
@@ -219,6 +245,13 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
219
245
  * @returns A single tx or undefined.
220
246
  */
221
247
  getTxByHashFromPool(txHash: TxHash): Promise<Tx | undefined>;
248
+ /**
249
+ * Returns transactions in the transaction pool by hash.
250
+ * @param txHashes - Hashes of the transactions to look for.
251
+ * @returns The txs found, not necessarily on the same order as the hashes.
252
+ */
253
+ getTxsByHashFromPool(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
254
+ hasTxsInPool(txHashes: TxHash[]): Promise<boolean[]>;
222
255
  /**
223
256
  * Returns a transaction in the transaction pool by its hash.
224
257
  * If the transaction is not in the pool, it will be requested from the network.
@@ -245,6 +278,11 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
245
278
  * @returns Empty promise.
246
279
  **/
247
280
  sendTx(tx: Tx): Promise<void>;
281
+ /**
282
+ * Adds transactions to the pool. Does not send to peers or validate the txs.
283
+ * @param txs - The transactions.
284
+ **/
285
+ addTxs(txs: Tx[]): Promise<void>;
248
286
  /**
249
287
  * Returns whether the given tx hash is flagged as pending or mined.
250
288
  * @param txHash - Hash of the tx to query.
@@ -1 +1 @@
1
- {"version":3,"file":"p2p_client.d.ts","sourceRoot":"","sources":["../../src/client/p2p_client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAsC,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAEV,SAAS,EACT,aAAa,EACb,kBAAkB,EAClB,MAAM,EAEP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAA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AE,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C;;;QAGI;IACS,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7C;;;;OAIG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAIrE,MAAM,IAAI,GAAG,GAAG,SAAS;IAIzB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAInD;;;;;QAKI;IACS,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzD;;;OAGG;IACI,OAAO;IAId;;;OAGG;IACU,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvD;;;OAGG;IACU,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvD,iEAAiE;IACpD,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInD;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;IAgB/C;;;;OAIG;YACW,wBAAwB;YAOxB,qBAAqB;IAUnC;;;;OAIG;YACW,mBAAmB;IAQjC;;;;OAIG;YACW,oBAAoB;IAiBlC;;;;OAIG;YACW,oBAAoB;IAgClC;;;OAGG;YACW,mBAAmB;YAkDnB,qBAAqB;IAenC;;;OAGG;IACH,OAAO,CAAC,eAAe;CAKxB"}
@@ -40,6 +40,7 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
40
40
  /** How many slots to keep attestations for. */ keepAttestationsInPoolFor;
41
41
  /** How many slots to keep proven txs for. */ keepProvenTxsFor;
42
42
  blockStream;
43
+ config;
43
44
  /**
44
45
  * In-memory P2P client constructor.
45
46
  * @param store - The client's instance of the KV store.
@@ -50,10 +51,11 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
50
51
  * @param log - A logger.
51
52
  */ constructor(_clientType, store, l2BlockSource, mempools, p2pService, config = {}, telemetry = getTelemetryClient(), log = createLogger('p2p')){
52
53
  super(telemetry, 'P2PClient'), this.l2BlockSource = l2BlockSource, this.p2pService = p2pService, this.log = log, this.currentState = 0, this.syncPromise = Promise.resolve(), this.syncResolve = undefined, this.latestBlockNumberAtStart = -1, this.provenBlockNumberAtStart = -1;
53
- const { keepProvenTxsInPoolFor, blockCheckIntervalMS, blockRequestBatchSize, keepAttestationsInPoolFor } = {
54
+ this.config = {
54
55
  ...getP2PDefaultConfig(),
55
56
  ...config
56
57
  };
58
+ const { keepProvenTxsInPoolFor, blockCheckIntervalMS, blockRequestBatchSize, keepAttestationsInPoolFor } = this.config;
57
59
  this.keepProvenTxsFor = keepProvenTxsInPoolFor;
58
60
  this.keepAttestationsInPoolFor = keepAttestationsInPoolFor;
59
61
  const tracer = telemetry.getTracer('P2PL2BlockStream');
@@ -78,6 +80,12 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
78
80
  getL2BlockHash(number) {
79
81
  return this.synchedBlockHashes.getAsync(number);
80
82
  }
83
+ async updateP2PConfig(config) {
84
+ if (typeof config.maxTxPoolSize === 'number' && this.config.maxTxPoolSize !== config.maxTxPoolSize) {
85
+ await this.txPool.setMaxTxPoolSize(config.maxTxPoolSize);
86
+ this.config.maxTxPoolSize = config.maxTxPoolSize;
87
+ }
88
+ }
81
89
  async getL2Tips() {
82
90
  const latestBlockNumber = await this.getSyncedLatestBlockNum();
83
91
  let latestBlockHash;
@@ -244,10 +252,13 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
244
252
  /**
245
253
  * Uses the batched Request Response protocol to request a set of transactions from the network.
246
254
  */ async requestTxsByHash(txHashes) {
247
- const txs = await this.p2pService.sendBatchRequest(ReqRespSubProtocol.TX, txHashes) ?? [];
248
- await this.txPool.addTxs(txs);
255
+ const txs = await this.p2pService.sendBatchRequest(ReqRespSubProtocol.TX, txHashes);
256
+ // Some transactions may return undefined, so we filter them out
257
+ const filteredTxs = txs.filter((tx)=>!!tx);
258
+ await this.txPool.addTxs(filteredTxs);
249
259
  const txHashesStr = txHashes.map((tx)=>tx.toString()).join(', ');
250
260
  this.log.debug(`Received batched txs ${txHashesStr} (${txs.length} / ${txHashes.length}}) from peers`);
261
+ // We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
251
262
  return txs;
252
263
  }
253
264
  getPendingTxs() {
@@ -292,6 +303,16 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
292
303
  return this.txPool.getTxByHash(txHash);
293
304
  }
294
305
  /**
306
+ * Returns transactions in the transaction pool by hash.
307
+ * @param txHashes - Hashes of the transactions to look for.
308
+ * @returns The txs found, not necessarily on the same order as the hashes.
309
+ */ getTxsByHashFromPool(txHashes) {
310
+ return this.txPool.getTxsByHash(txHashes);
311
+ }
312
+ hasTxsInPool(txHashes) {
313
+ return this.txPool.hasTxs(txHashes);
314
+ }
315
+ /**
295
316
  * Returns a transaction in the transaction pool by its hash.
296
317
  * If the transaction is not in the pool, it will be requested from the network.
297
318
  * @param txHash - Hash of the transaction to look for in the pool.
@@ -318,7 +339,8 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
318
339
  return txs;
319
340
  }
320
341
  const missingTxs = await this.requestTxsByHash(missingTxHashes);
321
- return txs.filter((tx)=>!!tx).concat(missingTxs);
342
+ const fetchedMissingTxs = missingTxs.filter((tx)=>!!tx);
343
+ return txs.filter((tx)=>!!tx).concat(fetchedMissingTxs);
322
344
  }
323
345
  /**
324
346
  * Returns an archived transaction in the transaction pool by its hash.
@@ -332,13 +354,19 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
332
354
  * @param tx - The tx to verify.
333
355
  * @returns Empty promise.
334
356
  **/ async sendTx(tx) {
335
- this.#assertIsReady();
336
- await this.txPool.addTxs([
357
+ await this.addTxs([
337
358
  tx
338
359
  ]);
339
360
  this.p2pService.propagate(tx);
340
361
  }
341
362
  /**
363
+ * Adds transactions to the pool. Does not send to peers or validate the txs.
364
+ * @param txs - The transactions.
365
+ **/ async addTxs(txs) {
366
+ this.#assertIsReady();
367
+ await this.txPool.addTxs(txs);
368
+ }
369
+ /**
342
370
  * Returns whether the given tx hash is flagged as pending or mined.
343
371
  * @param txHash - Hash of the tx to query.
344
372
  * @returns Pending or mined depending on its status, or undefined if not found.
@@ -476,28 +504,40 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
476
504
  * Updates the tx pool after a chain prune.
477
505
  * @param latestBlock - The block number the chain was pruned to.
478
506
  */ async handlePruneL2Blocks(latestBlock) {
479
- const txsToDelete = [];
507
+ // NOTE: temporary fix for alphanet, deleting ALL txs that were in the epoch from the pool #13723
508
+ // TODO: undo once fixed: #13770
509
+ const txsToDelete = new Set();
510
+ const minedTxs = await this.txPool.getMinedTxHashes();
511
+ for (const [txHash, blockNumber] of minedTxs){
512
+ if (blockNumber > latestBlock) {
513
+ txsToDelete.add(txHash);
514
+ }
515
+ }
516
+ // Find transactions that reference pruned blocks in their historical header
480
517
  for (const tx of (await this.txPool.getAllTxs())){
481
518
  // every tx that's been generated against a block that has now been pruned is no longer valid
482
519
  if (tx.data.constants.historicalHeader.globalVariables.blockNumber.toNumber() > latestBlock) {
483
- txsToDelete.push(await tx.getTxHash());
520
+ const txHash = await tx.getTxHash();
521
+ txsToDelete.add(txHash);
484
522
  }
485
523
  }
486
- this.log.info(`Detected chain prune. Removing invalid txs count=${txsToDelete.length} newLatestBlock=${latestBlock} previousLatestBlock=${await this.getSyncedLatestBlockNum()}`);
524
+ this.log.info(`Detected chain prune. Removing invalid txs count=${txsToDelete.size} newLatestBlock=${latestBlock} previousLatestBlock=${await this.getSyncedLatestBlockNum()}`);
487
525
  // delete invalid txs (both pending and mined)
488
- await this.txPool.deleteTxs(txsToDelete);
526
+ await this.txPool.deleteTxs(Array.from(txsToDelete));
489
527
  // everything left in the mined set was built against a block on the proven chain so its still valid
490
528
  // move back to pending the txs that were reorged out of the chain
491
529
  // NOTE: we can't move _all_ txs back to pending because the tx pool could keep hold of mined txs for longer
492
530
  // (see this.keepProvenTxsFor)
493
- const txsToMoveToPending = [];
494
- for (const [txHash, blockNumber] of (await this.txPool.getMinedTxHashes())){
495
- if (blockNumber > latestBlock) {
496
- txsToMoveToPending.push(txHash);
497
- }
498
- }
499
- this.log.info(`Moving ${txsToMoveToPending.length} mined txs back to pending`);
500
- await this.txPool.markMinedAsPending(txsToMoveToPending);
531
+ // NOTE: given current fix for alphanet, the code below is redundant as all these txs will be deleted.
532
+ // TODO: bring back once fixed: #13770
533
+ // const txsToMoveToPending: TxHash[] = [];
534
+ // for (const [txHash, blockNumber] of minedTxs) {
535
+ // if (blockNumber > latestBlock) {
536
+ // txsToMoveToPending.push(txHash);
537
+ // }
538
+ // }
539
+ // this.log.info(`Moving ${txsToMoveToPending.length} mined txs back to pending`);
540
+ // await this.txPool.markMinedAsPending(txsToMoveToPending);
501
541
  await this.synchedLatestBlockNumber.set(latestBlock);
502
542
  // no need to update block hashes, as they will be updated as new blocks are added
503
543
  }
package/dest/config.d.ts CHANGED
@@ -34,6 +34,10 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig {
34
34
  * The port for the P2P service.
35
35
  */
36
36
  p2pPort: number;
37
+ /**
38
+ * The port to broadcast the P2P service on (included in the node's ENR).
39
+ */
40
+ p2pBroadcastPort?: number;
37
41
  /**
38
42
  * The IP address for the P2P service.
39
43
  */
@@ -130,6 +134,10 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig {
130
134
  * A list of trusted peers.
131
135
  */
132
136
  trustedPeers: string[];
137
+ /**
138
+ * A list of private peers.
139
+ */
140
+ privatePeers: string[];
133
141
  /**
134
142
  * The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKB.
135
143
  */
@@ -141,6 +149,7 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig {
141
149
  */
142
150
  maxTxPoolSize: number;
143
151
  }
152
+ export declare const DEFAULT_P2P_PORT = 40400;
144
153
  export declare const p2pConfigMappings: ConfigMappingsType<P2PConfig>;
145
154
  /**
146
155
  * Gets the config values for p2p client from environment variables.
@@ -151,7 +160,7 @@ export declare function getP2PDefaultConfig(): P2PConfig;
151
160
  /**
152
161
  * Required P2P config values for a bootstrap node.
153
162
  */
154
- export type BootnodeConfig = Pick<P2PConfig, 'p2pIp' | 'p2pPort' | 'peerIdPrivateKey' | 'peerIdPrivateKeyPath' | 'bootstrapNodes' | 'listenAddress'> & Required<Pick<P2PConfig, 'p2pIp' | 'p2pPort'>> & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKB'> & Pick<ChainConfig, 'l1ChainId'>;
163
+ export type BootnodeConfig = Pick<P2PConfig, 'p2pIp' | 'p2pPort' | 'p2pBroadcastPort' | 'peerIdPrivateKey' | 'peerIdPrivateKeyPath' | 'bootstrapNodes' | 'listenAddress'> & Required<Pick<P2PConfig, 'p2pIp' | 'p2pPort'>> & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKB'> & Pick<ChainConfig, 'l1ChainId'>;
155
164
  export declare const bootnodeConfigMappings: ConfigMappingsType<Pick<{
156
165
  l1ChainId: unknown;
157
166
  rollupVersion: unknown;
@@ -167,6 +176,7 @@ export declare const bootnodeConfigMappings: ConfigMappingsType<Pick<{
167
176
  peerCheckIntervalMS: unknown;
168
177
  l2QueueSize: unknown;
169
178
  p2pPort: unknown;
179
+ p2pBroadcastPort: unknown;
170
180
  p2pIp: unknown;
171
181
  listenAddress: unknown;
172
182
  peerIdPrivateKey: unknown;
@@ -193,10 +203,11 @@ export declare const bootnodeConfigMappings: ConfigMappingsType<Pick<{
193
203
  peerPenaltyValues: unknown;
194
204
  archivedTxLimit: unknown;
195
205
  trustedPeers: unknown;
206
+ privatePeers: unknown;
196
207
  p2pStoreMapSizeKb: unknown;
197
208
  txPublicSetupAllowList: unknown;
198
209
  maxTxPoolSize: unknown;
199
- }, "p2pPort" | "p2pIp" | "listenAddress" | "peerIdPrivateKey" | "peerIdPrivateKeyPath" | "bootstrapNodes" | "l1ChainId" | "dataDirectory" | "dataStoreMapSizeKB">>;
210
+ }, "p2pPort" | "p2pBroadcastPort" | "p2pIp" | "listenAddress" | "peerIdPrivateKey" | "peerIdPrivateKeyPath" | "bootstrapNodes" | "l1ChainId" | "dataDirectory" | "dataStoreMapSizeKB">>;
200
211
  /**
201
212
  * Parses a string to a list of allowed elements.
202
213
  * Each encoded is expected to be of one of the following formats
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAGlF,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAElG,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,8BAA8B,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,gBAAgB,EAAE,WAAW;IAC9D;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,6BAA6B,EAAE,OAAO,CAAC;IAEvC;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB,sEAAsE;IACtE,4BAA4B,EA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AE,CAAC;IAEvB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,iEAAiE;IACjE,sBAAsB,EAAE,cAAc,EAAE,CAAC;IAEzC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAEtC,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,SAAS,CAyM3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,SAAS,EACP,OAAO,GACP,SAAS,GACT,kBAAkB,GAClB,kBAAkB,GAClB,sBAAsB,GACtB,gBAAgB,GAChB,eAAe,CAClB,GACC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC,GAC9C,IAAI,CAAC,eAAe,EAAE,eAAe,GAAG,oBAAoB,CAAC,GAC7D,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAejC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uLAGlC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAqC9D"}
package/dest/config.js CHANGED
@@ -5,6 +5,7 @@ import { FunctionSelector } from '@aztec/stdlib/abi';
5
5
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
6
  import { chainConfigMappings } from '@aztec/stdlib/config';
7
7
  import { p2pReqRespConfigMappings } from './services/reqresp/config.js';
8
+ export const DEFAULT_P2P_PORT = 40400;
8
9
  export const p2pConfigMappings = {
9
10
  p2pEnabled: {
10
11
  env: 'P2P_ENABLED',
@@ -38,8 +39,12 @@ export const p2pConfigMappings = {
38
39
  },
39
40
  p2pPort: {
40
41
  env: 'P2P_PORT',
41
- description: 'The port for the P2P service.',
42
- ...numberConfigHelper(40400)
42
+ description: `The port for the P2P service. Defaults to ${DEFAULT_P2P_PORT}`,
43
+ ...numberConfigHelper(DEFAULT_P2P_PORT)
44
+ },
45
+ p2pBroadcastPort: {
46
+ env: 'P2P_BROADCAST_PORT',
47
+ description: `The port to broadcast the P2P service on (included in the node's ENR). Defaults to P2P_PORT.`
43
48
  },
44
49
  p2pIp: {
45
50
  env: 'P2P_IP',
@@ -172,7 +177,13 @@ export const p2pConfigMappings = {
172
177
  trustedPeers: {
173
178
  env: 'P2P_TRUSTED_PEERS',
174
179
  parseEnv: (val)=>val.split(','),
175
- description: 'A list of trusted peers ENRs. Separated by commas.',
180
+ description: 'A list of trusted peer ENRs that will always be persisted. Separated by commas.',
181
+ defaultValue: []
182
+ },
183
+ privatePeers: {
184
+ env: 'P2P_PRIVATE_PEERS',
185
+ parseEnv: (val)=>val.split(','),
186
+ description: 'A list of private peer ENRs that will always be persisted and not be used for discovery. Separated by commas.',
176
187
  defaultValue: []
177
188
  },
178
189
  p2pStoreMapSizeKb: {
@@ -206,6 +217,7 @@ export function getP2PDefaultConfig() {
206
217
  const bootnodeConfigKeys = [
207
218
  'p2pIp',
208
219
  'p2pPort',
220
+ 'p2pBroadcastPort',
209
221
  'listenAddress',
210
222
  'peerIdPrivateKey',
211
223
  'peerIdPrivateKeyPath',
@@ -1,7 +1,7 @@
1
1
  import type { LogFn } from '@aztec/foundation/log';
2
2
  import { SignableENR } from '@chainsafe/enr';
3
3
  import type { PeerId } from '@libp2p/interface';
4
- export declare function createBootnodeENRandPeerId(privateKey: string, p2pIp: string, p2pPort: number, l1ChainId: number): Promise<{
4
+ export declare function createBootnodeENRandPeerId(privateKey: string, p2pIp: string, p2pBroadcastPort: number, l1ChainId: number): Promise<{
5
5
  enr: SignableENR;
6
6
  peerId: PeerId;
7
7
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"generate-enr.d.ts","sourceRoot":"","sources":["../../src/enr/generate-enr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAO,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAOhD,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,GAAG,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAa/C;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAQrD"}
1
+ {"version":3,"file":"generate-enr.d.ts","sourceRoot":"","sources":["../../src/enr/generate-enr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAO,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAOhD,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,MAAM,EACxB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,GAAG,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAa/C;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAQrD"}
@@ -4,10 +4,10 @@ import { multiaddr } from '@multiformats/multiaddr';
4
4
  import { AZTEC_ENR_KEY } from '../types/index.js';
5
5
  import { convertToMultiaddr, createLibP2PPeerIdFromPrivateKey } from '../util.js';
6
6
  import { setAztecEnrKey } from '../versioning.js';
7
- export async function createBootnodeENRandPeerId(privateKey, p2pIp, p2pPort, l1ChainId) {
7
+ export async function createBootnodeENRandPeerId(privateKey, p2pIp, p2pBroadcastPort, l1ChainId) {
8
8
  const peerId = await createLibP2PPeerIdFromPrivateKey(privateKey);
9
9
  const enr = SignableENR.createFromPeerId(peerId);
10
- const publicAddr = multiaddr(convertToMultiaddr(p2pIp, p2pPort, 'udp'));
10
+ const publicAddr = multiaddr(convertToMultiaddr(p2pIp, p2pBroadcastPort, 'udp'));
11
11
  enr.setLocationMultiaddr(publicAddr);
12
12
  const config = {
13
13
  ...emptyChainConfig,
@@ -1 +1 @@
1
- {"version":3,"file":"attestation_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/attestation_pool_test_suite.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,wBAAgB,uBAAuB,CAAC,kBAAkB,EAAE,MAAM,eAAe,QAgPhF"}
1
+ {"version":3,"file":"attestation_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/attestation_pool_test_suite.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,wBAAgB,uBAAuB,CAAC,kBAAkB,EAAE,MAAM,eAAe,QA4OhF"}
@@ -21,7 +21,7 @@ export function describeAttestationPool(getAttestationPool) {
21
21
  });
22
22
  const createAttestationsForSlot = (slotNumber)=>{
23
23
  const archive = Fr.random();
24
- return Promise.all(signers.map((signer)=>mockAttestation(signer, slotNumber, archive)));
24
+ return signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
25
25
  };
26
26
  // We compare buffers as the objects can have cached values attached to them which are not serialised
27
27
  // using array containing as the kv store does not respect insertion order
@@ -34,7 +34,7 @@ export function describeAttestationPool(getAttestationPool) {
34
34
  it('should add attestations to pool', async ()=>{
35
35
  const slotNumber = 420;
36
36
  const archive = Fr.random();
37
- const attestations = await Promise.all(signers.slice(0, -1).map((signer)=>mockAttestation(signer, slotNumber, archive)));
37
+ const attestations = signers.slice(0, -1).map((signer)=>mockAttestation(signer, slotNumber, archive));
38
38
  await ap.addAttestations(attestations);
39
39
  // Check metrics have been updated.
40
40
  expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations.length);
@@ -45,7 +45,7 @@ export function describeAttestationPool(getAttestationPool) {
45
45
  expect(retrievedAttestationsForSlot.length).toBe(attestations.length);
46
46
  compareAttestations(retrievedAttestationsForSlot, attestations);
47
47
  // Add another one
48
- const newAttestation = await mockAttestation(signers[NUMBER_OF_SIGNERS_PER_TEST - 1], slotNumber, archive);
48
+ const newAttestation = mockAttestation(signers[NUMBER_OF_SIGNERS_PER_TEST - 1], slotNumber, archive);
49
49
  await ap.addAttestations([
50
50
  newAttestation
51
51
  ]);
@@ -83,7 +83,7 @@ export function describeAttestationPool(getAttestationPool) {
83
83
  const attestations = [];
84
84
  const signer = signers[0];
85
85
  for(let i = 0; i < NUMBER_OF_SIGNERS_PER_TEST; i++){
86
- attestations.push(await mockAttestation(signer, slotNumber, archive, txs));
86
+ attestations.push(mockAttestation(signer, slotNumber, archive, txs));
87
87
  }
88
88
  // Add them to store and check we end up with only one
89
89
  await ap.addAttestations(attestations);
@@ -91,7 +91,7 @@ export function describeAttestationPool(getAttestationPool) {
91
91
  expect(retreivedAttestations.length).toBe(1);
92
92
  expect(retreivedAttestations[0].toBuffer()).toEqual(attestations[0].toBuffer());
93
93
  expect(retreivedAttestations[0].payload.txHashes).toEqual(txs);
94
- expect((await retreivedAttestations[0].getSender()).toString()).toEqual(signer.address.toString());
94
+ expect(retreivedAttestations[0].getSender().toString()).toEqual(signer.address.toString());
95
95
  // Try adding them on another operation and check they are still not duplicated
96
96
  await ap.addAttestations([
97
97
  attestations[0]
@@ -105,7 +105,7 @@ export function describeAttestationPool(getAttestationPool) {
105
105
  3,
106
106
  4
107
107
  ];
108
- const attestations = await Promise.all(signers.map((signer, i)=>mockAttestation(signer, slotNumbers[i])));
108
+ const attestations = signers.map((signer, i)=>mockAttestation(signer, slotNumbers[i]));
109
109
  await ap.addAttestations(attestations);
110
110
  for (const attestation of attestations){
111
111
  const slot = attestation.payload.header.globalVariables.slotNumber;
@@ -129,7 +129,7 @@ export function describeAttestationPool(getAttestationPool) {
129
129
  Fr.random(),
130
130
  Fr.random()
131
131
  ];
132
- const attestations = await Promise.all(signers.map((signer, i)=>mockAttestation(signer, slotNumbers[i], archives[i])));
132
+ const attestations = signers.map((signer, i)=>mockAttestation(signer, slotNumbers[i], archives[i]));
133
133
  await ap.addAttestations(attestations);
134
134
  for (const attestation of attestations){
135
135
  const slot = attestation.payload.header.globalVariables.slotNumber;
@@ -143,7 +143,7 @@ export function describeAttestationPool(getAttestationPool) {
143
143
  it('should delete attestations', async ()=>{
144
144
  const slotNumber = 420;
145
145
  const archive = Fr.random();
146
- const attestations = await Promise.all(signers.map((signer)=>mockAttestation(signer, slotNumber, archive)));
146
+ const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
147
147
  const proposalId = attestations[0].archive.toString();
148
148
  await ap.addAttestations(attestations);
149
149
  expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations.length);
@@ -158,7 +158,7 @@ export function describeAttestationPool(getAttestationPool) {
158
158
  it('should blanket delete attestations per slot', async ()=>{
159
159
  const slotNumber = 420;
160
160
  const archive = Fr.random();
161
- const attestations = await Promise.all(signers.map((signer)=>mockAttestation(signer, slotNumber, archive)));
161
+ const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
162
162
  const proposalId = attestations[0].archive.toString();
163
163
  await ap.addAttestations(attestations);
164
164
  const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
@@ -171,11 +171,11 @@ export function describeAttestationPool(getAttestationPool) {
171
171
  it('should blanket delete attestations per slot and proposal', async ()=>{
172
172
  const slotNumber = 420;
173
173
  const archive = Fr.random();
174
- const attestations = await Promise.all(signers.map((signer)=>mockAttestation(signer, slotNumber, archive)));
174
+ const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
175
175
  const proposalId = attestations[0].archive.toString();
176
176
  // Add another set of attestations with a different proposalId, yet the same slot
177
177
  const archive2 = Fr.random();
178
- const attestations2 = await Promise.all(signers.map((signer)=>mockAttestation(signer, slotNumber, archive2)));
178
+ const attestations2 = signers.map((signer)=>mockAttestation(signer, slotNumber, archive2));
179
179
  const proposalId2 = attestations2[0].archive.toString();
180
180
  await ap.addAttestations(attestations);
181
181
  await ap.addAttestations(attestations2);
@@ -32,7 +32,7 @@ export class KvAttestationPool {
32
32
  for (const attestation of attestations){
33
33
  const slotNumber = attestation.payload.header.globalVariables.slotNumber;
34
34
  const proposalId = attestation.archive;
35
- const address = (await attestation.getSender()).toString();
35
+ const address = attestation.getSender().toString();
36
36
  await this.attestations.set(this.getAttestationKey(slotNumber, proposalId, address), attestation.toBuffer());
37
37
  await this.proposalsForSlot.set(slotNumber.toString(), proposalId.toString());
38
38
  await this.attestationsForProposal.set(this.getProposalKey(slotNumber, proposalId), this.getAttestationKey(slotNumber, proposalId, address));
@@ -115,7 +115,7 @@ export class KvAttestationPool {
115
115
  for (const attestation of attestations){
116
116
  const slotNumber = attestation.payload.header.globalVariables.slotNumber;
117
117
  const proposalId = attestation.archive;
118
- const address = (await attestation.getSender()).toString();
118
+ const address = attestation.getSender().toString();
119
119
  await this.attestations.delete(this.getAttestationKey(slotNumber, proposalId, address));
120
120
  await this.attestationsForProposal.deleteValue(this.getProposalKey(slotNumber, proposalId), this.getAttestationKey(slotNumber, proposalId, address));
121
121
  this.log.debug(`Deleted attestation for slot ${slotNumber} from ${address}`);
@@ -1 +1 @@
1
- {"version":3,"file":"memory_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/memory_attestation_pool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBA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GAAG;IAJ1E,OAAO,CAAC,OAAO,CAAwC;IAEvD,OAAO,CAAC,YAAY,CAAgG;gBAExG,SAAS,GAAE,eAAsC,EAAU,GAAG,yCAAuC;IAK1G,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAQjE,iCAAiC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAWhG,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC1D,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBpE,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWtD,oCAAoC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAerF,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAiB3E"}
@@ -23,12 +23,12 @@ export class InMemoryAttestationPool {
23
23
  }
24
24
  return Promise.resolve([]);
25
25
  }
26
- async addAttestations(attestations) {
26
+ addAttestations(attestations) {
27
27
  for (const attestation of attestations){
28
28
  // Perf: order and group by slot before insertion
29
29
  const slotNumber = attestation.payload.header.globalVariables.slotNumber;
30
30
  const proposalId = attestation.archive.toString();
31
- const address = await attestation.getSender();
31
+ const address = attestation.getSender();
32
32
  const slotAttestationMap = getSlotOrDefault(this.attestations, slotNumber.toBigInt());
33
33
  const proposalAttestationMap = getProposalOrDefault(slotAttestationMap, proposalId);
34
34
  proposalAttestationMap.set(address.toString(), attestation);
@@ -91,7 +91,7 @@ export class InMemoryAttestationPool {
91
91
  }
92
92
  return Promise.resolve();
93
93
  }
94
- async deleteAttestations(attestations) {
94
+ deleteAttestations(attestations) {
95
95
  for (const attestation of attestations){
96
96
  const slotNumber = attestation.payload.header.globalVariables.slotNumber;
97
97
  const slotAttestationMap = this.attestations.get(slotNumber.toBigInt());
@@ -99,7 +99,7 @@ export class InMemoryAttestationPool {
99
99
  const proposalId = attestation.archive.toString();
100
100
  const proposalAttestationMap = getProposalOrDefault(slotAttestationMap, proposalId);
101
101
  if (proposalAttestationMap) {
102
- const address = await attestation.getSender();
102
+ const address = attestation.getSender();
103
103
  proposalAttestationMap.delete(address.toString());
104
104
  this.log.debug(`Deleted attestation for slot ${slotNumber} from ${address}`);
105
105
  }