@aztec/p2p 0.0.1-commit.88c5703d4 → 0.0.1-commit.88e6f9396

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 (89) hide show
  1. package/dest/client/p2p_client.d.ts +1 -1
  2. package/dest/client/p2p_client.d.ts.map +1 -1
  3. package/dest/client/p2p_client.js +6 -4
  4. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -5
  5. package/dest/config.d.ts +7 -1
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +10 -0
  8. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +3 -3
  9. package/dest/mem_pools/attestation_pool/attestation_pool.js +3 -3
  10. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
  11. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +4 -4
  12. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -1
  13. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  14. package/dest/msg_validators/attestation_validator/attestation_validator.js +5 -4
  15. package/dest/msg_validators/clock_tolerance.d.ts +1 -1
  16. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
  17. package/dest/msg_validators/clock_tolerance.js +4 -3
  18. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +1 -1
  19. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  20. package/dest/msg_validators/proposal_validator/proposal_validator.js +5 -5
  21. package/dest/services/encoding.d.ts +5 -1
  22. package/dest/services/encoding.d.ts.map +1 -1
  23. package/dest/services/encoding.js +7 -1
  24. package/dest/services/libp2p/libp2p_service.d.ts +2 -9
  25. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  26. package/dest/services/libp2p/libp2p_service.js +7 -24
  27. package/dest/services/peer-manager/peer_manager.d.ts +1 -1
  28. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  29. package/dest/services/peer-manager/peer_manager.js +4 -2
  30. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -7
  31. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  32. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +40 -56
  33. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +1 -2
  34. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  35. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +4 -4
  36. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  37. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +7 -7
  38. package/dest/services/reqresp/reqresp.d.ts +1 -1
  39. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  40. package/dest/services/reqresp/reqresp.js +16 -8
  41. package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
  42. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  43. package/dest/services/tx_collection/fast_tx_collection.js +57 -73
  44. package/dest/services/tx_collection/proposal_tx_collector.d.ts +6 -7
  45. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  46. package/dest/services/tx_collection/proposal_tx_collector.js +4 -4
  47. package/dest/services/tx_collection/request_tracker.d.ts +53 -0
  48. package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
  49. package/dest/services/tx_collection/request_tracker.js +84 -0
  50. package/dest/services/tx_collection/slow_tx_collection.js +1 -1
  51. package/dest/services/tx_collection/tx_collection.d.ts +3 -6
  52. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  53. package/dest/test-helpers/testbench-utils.d.ts +1 -1
  54. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  55. package/dest/test-helpers/testbench-utils.js +20 -2
  56. package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
  57. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  58. package/dest/testbench/p2p_client_testbench_worker.js +6 -5
  59. package/package.json +14 -14
  60. package/src/client/p2p_client.ts +6 -4
  61. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +6 -7
  62. package/src/config.ts +17 -0
  63. package/src/mem_pools/attestation_pool/attestation_pool.ts +3 -3
  64. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
  65. package/src/mem_pools/tx_pool_v2/interfaces.ts +4 -4
  66. package/src/msg_validators/attestation_validator/README.md +1 -1
  67. package/src/msg_validators/attestation_validator/attestation_validator.ts +5 -4
  68. package/src/msg_validators/clock_tolerance.ts +4 -3
  69. package/src/msg_validators/proposal_validator/README.md +3 -3
  70. package/src/msg_validators/proposal_validator/proposal_validator.ts +6 -5
  71. package/src/services/encoding.ts +9 -1
  72. package/src/services/libp2p/libp2p_service.ts +6 -27
  73. package/src/services/peer-manager/peer_manager.ts +5 -2
  74. package/src/services/reqresp/batch-tx-requester/README.md +46 -7
  75. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +32 -60
  76. package/src/services/reqresp/batch-tx-requester/interface.ts +0 -1
  77. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +6 -6
  78. package/src/services/reqresp/reqresp.ts +18 -10
  79. package/src/services/tx_collection/fast_tx_collection.ts +57 -83
  80. package/src/services/tx_collection/proposal_tx_collector.ts +8 -13
  81. package/src/services/tx_collection/request_tracker.ts +127 -0
  82. package/src/services/tx_collection/slow_tx_collection.ts +1 -1
  83. package/src/services/tx_collection/tx_collection.ts +3 -5
  84. package/src/test-helpers/testbench-utils.ts +28 -3
  85. package/src/testbench/p2p_client_testbench_worker.ts +6 -8
  86. package/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
  87. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
  88. package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
  89. package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
@@ -4,7 +4,7 @@
4
4
  * Used when running testbench commands.
5
5
  */
6
6
  import { MockL2BlockSource } from '@aztec/archiver/test';
7
- import type { EpochCacheInterface } from '@aztec/epoch-cache';
7
+ import type { EpochCache, EpochCacheInterface } from '@aztec/epoch-cache';
8
8
  import { BlockNumber } from '@aztec/foundation/branded-types';
9
9
  import { SecretValue } from '@aztec/foundation/config';
10
10
  import { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
@@ -28,6 +28,7 @@ import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-clien
28
28
  import type { Message, PeerId } from '@libp2p/interface';
29
29
  import { TopicValidatorResult } from '@libp2p/interface';
30
30
  import { peerIdFromString } from '@libp2p/peer-id';
31
+ import { mock } from 'jest-mock-extended';
31
32
 
32
33
  import type { P2PClient } from '../client/index.js';
33
34
  import type { P2PConfig } from '../config.js';
@@ -40,7 +41,7 @@ import type { IBatchRequestTxValidator } from '../services/reqresp/batch-tx-requ
40
41
  import { RateLimitStatus } from '../services/reqresp/rate-limiter/rate_limiter.js';
41
42
  import type { ReqResp } from '../services/reqresp/reqresp.js';
42
43
  import type { PeerDiscoveryService } from '../services/service.js';
43
- import { MissingTxsTracker } from '../services/tx_collection/missing_txs_tracker.js';
44
+ import { RequestTracker } from '../services/tx_collection/request_tracker.js';
44
45
  import { AlwaysTrueCircuitVerifier } from '../test-helpers/index.js';
45
46
  import {
46
47
  BENCHMARK_CONSTANTS,
@@ -49,7 +50,6 @@ import {
49
50
  InMemoryAttestationPool,
50
51
  InMemoryTxPool,
51
52
  UNLIMITED_RATE_LIMIT_QUOTA,
52
- createMockEpochCache,
53
53
  createMockWorldStateSynchronizer,
54
54
  filterTxsByDistribution,
55
55
  } from '../test-helpers/index.js';
@@ -273,10 +273,9 @@ async function runAggregatorBenchmark(
273
273
  noopTxValidator,
274
274
  );
275
275
  const fetchedTxs = await collector.collectTxs(
276
- MissingTxsTracker.fromArray(txHashes),
276
+ RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs)),
277
277
  blockProposal,
278
278
  pinnedPeer,
279
- timeoutMs,
280
279
  );
281
280
  const durationMs = timer.ms();
282
281
  return {
@@ -293,10 +292,9 @@ async function runAggregatorBenchmark(
293
292
  BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS,
294
293
  );
295
294
  const fetchedTxs = await collector.collectTxs(
296
- MissingTxsTracker.fromArray(txHashes),
295
+ RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs)),
297
296
  blockProposal,
298
297
  pinnedPeer,
299
- timeoutMs,
300
298
  );
301
299
  const durationMs = timer.ms();
302
300
  return {
@@ -346,7 +344,7 @@ process.on('message', async msg => {
346
344
  workerConfig = config;
347
345
  workerTxPool = new InMemoryTxPool();
348
346
  workerAttestationPool = new InMemoryAttestationPool();
349
- const epochCache = createMockEpochCache();
347
+ const epochCache = mock<EpochCache>();
350
348
  const worldState = createMockWorldStateSynchronizer();
351
349
  const l2BlockSource = new MockL2BlockSource();
352
350
 
@@ -1,32 +0,0 @@
1
- import { TxHash } from '@aztec/stdlib/tx';
2
- import type { Tx } from '@aztec/stdlib/tx';
3
- /**
4
- * Tracks which transactions are still missing and need to be fetched.
5
- * Allows external code to mark transactions as fetched, enabling coordination
6
- * between multiple fetching mechanisms (e.g., BatchTxRequester and Rpc Node requests).
7
- */
8
- export interface IMissingTxsTracker {
9
- /** Returns the set of transaction hashes that are still missing. */
10
- get missingTxHashes(): Set<string>;
11
- /** Size of this.missingTxHashes */
12
- get numberOfMissingTxs(): number;
13
- /** Are all requested txs are fetched */
14
- allFetched(): boolean;
15
- /** Checks that transaction is still missing */
16
- isMissing(txHash: string): boolean;
17
- /** Marks a transaction as fetched. Returns true if it was previously missing. */
18
- markFetched(tx: Tx): boolean;
19
- /** Get list of collected txs */
20
- get collectedTxs(): Tx[];
21
- }
22
- export declare class MissingTxsTracker implements IMissingTxsTracker {
23
- readonly missingTxHashes: Set<string>;
24
- readonly collectedTxs: Tx[];
25
- private constructor();
26
- static fromArray(hashes: TxHash[] | string[]): MissingTxsTracker;
27
- markFetched(tx: Tx): boolean;
28
- get numberOfMissingTxs(): number;
29
- allFetched(): boolean;
30
- isMissing(txHash: string): boolean;
31
- }
32
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlzc2luZ190eHNfdHJhY2tlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NlcnZpY2VzL3R4X2NvbGxlY3Rpb24vbWlzc2luZ190eHNfdHJhY2tlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDMUMsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFM0M7Ozs7R0FJRztBQUNILE1BQU0sV0FBVyxrQkFBa0I7SUFDakMsb0VBQW9FO0lBQ3BFLElBQUksZUFBZSxJQUFJLEdBQUcsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNuQyxtQ0FBbUM7SUFDbkMsSUFBSSxrQkFBa0IsSUFBSSxNQUFNLENBQUM7SUFDakMsd0NBQXdDO0lBQ3hDLFVBQVUsSUFBSSxPQUFPLENBQUM7SUFDdEIsK0NBQStDO0lBQy9DLFNBQVMsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQztJQUNuQyxpRkFBaUY7SUFDakYsV0FBVyxDQUFDLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDO0lBQzdCLGdDQUFnQztJQUNoQyxJQUFJLFlBQVksSUFBSSxFQUFFLEVBQUUsQ0FBQztDQUMxQjtBQUVELHFCQUFhLGlCQUFrQixZQUFXLGtCQUFrQjthQUd0QixlQUFlLEVBQUUsR0FBRyxDQUFDLE1BQU0sQ0FBQztJQUZoRSxTQUFnQixZQUFZLEVBQUUsRUFBRSxFQUFFLENBQU07SUFFeEMsT0FBTyxlQUE2RDtJQUVwRSxPQUF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AAO,CAM3B;IAED,IAAI,kBAAkB,IAAI,MAAM,CAE/B;IAED,UAAU,IAAI,OAAO,CAEpB;IAED,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEjC;CACF"}
@@ -1,27 +0,0 @@
1
- export class MissingTxsTracker {
2
- missingTxHashes;
3
- collectedTxs;
4
- constructor(missingTxHashes){
5
- this.missingTxHashes = missingTxHashes;
6
- this.collectedTxs = [];
7
- }
8
- static fromArray(hashes) {
9
- return new MissingTxsTracker(new Set(hashes.map((hash)=>hash.toString())));
10
- }
11
- markFetched(tx) {
12
- if (this.missingTxHashes.delete(tx.txHash.toString())) {
13
- this.collectedTxs.push(tx);
14
- return true;
15
- }
16
- return false;
17
- }
18
- get numberOfMissingTxs() {
19
- return this.missingTxHashes.size;
20
- }
21
- allFetched() {
22
- return this.numberOfMissingTxs === 0;
23
- }
24
- isMissing(txHash) {
25
- return this.missingTxHashes.has(txHash.toString());
26
- }
27
- }
@@ -1,52 +0,0 @@
1
- import { TxHash } from '@aztec/stdlib/tx';
2
- import type { Tx } from '@aztec/stdlib/tx';
3
-
4
- /**
5
- * Tracks which transactions are still missing and need to be fetched.
6
- * Allows external code to mark transactions as fetched, enabling coordination
7
- * between multiple fetching mechanisms (e.g., BatchTxRequester and Rpc Node requests).
8
- */
9
- export interface IMissingTxsTracker {
10
- /** Returns the set of transaction hashes that are still missing. */
11
- get missingTxHashes(): Set<string>;
12
- /** Size of this.missingTxHashes */
13
- get numberOfMissingTxs(): number;
14
- /** Are all requested txs are fetched */
15
- allFetched(): boolean;
16
- /** Checks that transaction is still missing */
17
- isMissing(txHash: string): boolean;
18
- /** Marks a transaction as fetched. Returns true if it was previously missing. */
19
- markFetched(tx: Tx): boolean;
20
- /** Get list of collected txs */
21
- get collectedTxs(): Tx[];
22
- }
23
-
24
- export class MissingTxsTracker implements IMissingTxsTracker {
25
- public readonly collectedTxs: Tx[] = [];
26
-
27
- private constructor(public readonly missingTxHashes: Set<string>) {}
28
-
29
- public static fromArray(hashes: TxHash[] | string[]) {
30
- return new MissingTxsTracker(new Set(hashes.map(hash => hash.toString())));
31
- }
32
-
33
- markFetched(tx: Tx): boolean {
34
- if (this.missingTxHashes.delete(tx.txHash.toString())) {
35
- this.collectedTxs.push(tx);
36
- return true;
37
- }
38
- return false;
39
- }
40
-
41
- get numberOfMissingTxs(): number {
42
- return this.missingTxHashes.size;
43
- }
44
-
45
- allFetched(): boolean {
46
- return this.numberOfMissingTxs === 0;
47
- }
48
-
49
- isMissing(txHash: string): boolean {
50
- return this.missingTxHashes.has(txHash.toString());
51
- }
52
- }