@aztec/p2p 4.0.0-nightly.20260111 → 4.0.0-nightly.20260113

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 (86) hide show
  1. package/dest/client/interface.d.ts +18 -5
  2. package/dest/client/interface.d.ts.map +1 -1
  3. package/dest/client/p2p_client.d.ts +9 -12
  4. package/dest/client/p2p_client.d.ts.map +1 -1
  5. package/dest/client/p2p_client.js +59 -103
  6. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +61 -42
  7. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  8. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
  9. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  10. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +225 -262
  11. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +21 -18
  12. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
  13. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +113 -108
  14. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +17 -16
  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 +89 -128
  17. package/dest/mem_pools/attestation_pool/mocks.d.ts +7 -6
  18. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  19. package/dest/mem_pools/attestation_pool/mocks.js +9 -8
  20. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -4
  21. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  22. package/dest/msg_validators/attestation_validator/attestation_validator.js +12 -10
  23. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -5
  24. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  25. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +5 -5
  26. package/dest/msg_validators/index.d.ts +2 -2
  27. package/dest/msg_validators/index.d.ts.map +1 -1
  28. package/dest/msg_validators/index.js +1 -1
  29. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +9 -0
  30. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -0
  31. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +6 -0
  32. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +9 -0
  33. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -0
  34. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +6 -0
  35. package/dest/msg_validators/proposal_validator/index.d.ts +4 -0
  36. package/dest/msg_validators/proposal_validator/index.d.ts.map +1 -0
  37. package/dest/msg_validators/proposal_validator/index.js +3 -0
  38. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -0
  39. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -0
  40. package/dest/msg_validators/{block_proposal_validator/block_proposal_validator.js → proposal_validator/proposal_validator.js} +19 -21
  41. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +23 -0
  42. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -0
  43. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +183 -0
  44. package/dest/services/dummy_service.d.ts +6 -2
  45. package/dest/services/dummy_service.d.ts.map +1 -1
  46. package/dest/services/dummy_service.js +3 -0
  47. package/dest/services/encoding.d.ts +1 -1
  48. package/dest/services/encoding.d.ts.map +1 -1
  49. package/dest/services/encoding.js +4 -2
  50. package/dest/services/libp2p/libp2p_service.d.ts +26 -10
  51. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  52. package/dest/services/libp2p/libp2p_service.js +218 -88
  53. package/dest/services/service.d.ts +16 -3
  54. package/dest/services/service.d.ts.map +1 -1
  55. package/dest/testbench/p2p_client_testbench_worker.js +25 -11
  56. package/dest/testbench/worker_client_manager.d.ts +1 -1
  57. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  58. package/dest/testbench/worker_client_manager.js +6 -1
  59. package/package.json +14 -14
  60. package/src/client/interface.ts +19 -4
  61. package/src/client/p2p_client.ts +69 -110
  62. package/src/mem_pools/attestation_pool/attestation_pool.ts +68 -41
  63. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +231 -287
  64. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +162 -140
  65. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +141 -164
  66. package/src/mem_pools/attestation_pool/mocks.ts +13 -9
  67. package/src/msg_validators/attestation_validator/attestation_validator.ts +16 -13
  68. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +7 -7
  69. package/src/msg_validators/index.ts +1 -1
  70. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +10 -0
  71. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +13 -0
  72. package/src/msg_validators/proposal_validator/index.ts +3 -0
  73. package/src/msg_validators/{block_proposal_validator/block_proposal_validator.ts → proposal_validator/proposal_validator.ts} +23 -28
  74. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +206 -0
  75. package/src/services/dummy_service.ts +6 -0
  76. package/src/services/encoding.ts +3 -1
  77. package/src/services/libp2p/libp2p_service.ts +258 -94
  78. package/src/services/service.ts +19 -4
  79. package/src/testbench/p2p_client_testbench_worker.ts +34 -11
  80. package/src/testbench/worker_client_manager.ts +6 -1
  81. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +0 -12
  82. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +0 -1
  83. package/dest/msg_validators/block_proposal_validator/index.d.ts +0 -2
  84. package/dest/msg_validators/block_proposal_validator/index.d.ts.map +0 -1
  85. package/dest/msg_validators/block_proposal_validator/index.js +0 -1
  86. package/src/msg_validators/block_proposal_validator/index.ts +0 -1
@@ -1,5 +1,10 @@
1
1
  import type { SlotNumber } from '@aztec/foundation/branded-types';
2
- import type { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
2
+ import type {
3
+ BlockProposal,
4
+ CheckpointAttestation,
5
+ CheckpointProposal,
6
+ CheckpointProposalCore,
7
+ } from '@aztec/stdlib/p2p';
3
8
 
4
9
  /**
5
10
  * An Attestation Pool contains attestations collected by a validator
@@ -32,75 +37,74 @@ export interface AttestationPool {
32
37
  hasBlockProposal(idOrProposal: string | BlockProposal): Promise<boolean>;
33
38
 
34
39
  /**
35
- * AddAttestations
40
+ * Adds a checkpoint proposal to the pool.
36
41
  *
37
- * @param attestations - Attestations to add into the pool
42
+ * If the proposal contains a lastBlock, the BlockProposal is automatically extracted
43
+ * and stored separately via addBlockProposal. The checkpoint proposal is then stored
44
+ * without the lastBlock info (as CheckpointProposalCore).
45
+ *
46
+ * @param proposal - The checkpoint proposal to add
47
+ * @throws ProposalSlotCapExceededError if the slot has reached the maximum number of proposals
38
48
  */
39
- addAttestations(attestations: BlockAttestation[]): Promise<void>;
49
+ addCheckpointProposal(proposal: CheckpointProposal): Promise<void>;
40
50
 
41
51
  /**
42
- * DeleteAttestation
52
+ * Get checkpoint proposal by its ID.
53
+ *
54
+ * Returns a CheckpointProposalCore (without lastBlock info) since the lastBlock
55
+ * is extracted and stored separately as a BlockProposal when added.
43
56
  *
44
- * @param attestations - Attestations to remove from the pool
57
+ * @param id - The ID of the checkpoint proposal to retrieve (proposal.archive)
58
+ * @return The checkpoint proposal core if it exists, otherwise undefined.
45
59
  */
46
- deleteAttestations(attestations: BlockAttestation[]): Promise<void>;
60
+ getCheckpointProposal(id: string): Promise<CheckpointProposalCore | undefined>;
47
61
 
48
62
  /**
49
- * Delete Attestations with a slot number smaller than the given slot
50
- *
51
- * Removes all attestations associated with a slot
63
+ * Check if a checkpoint proposal exists in the pool
52
64
  *
53
- * @param slot - The oldest slot to keep.
65
+ * @param idOrProposal - The ID of the checkpoint proposal or the proposal itself
66
+ * @return True if the proposal exists, false otherwise.
54
67
  */
55
- deleteAttestationsOlderThan(slot: SlotNumber): Promise<void>;
68
+ hasCheckpointProposal(idOrProposal: string | CheckpointProposal): Promise<boolean>;
56
69
 
57
70
  /**
58
- * Delete Attestations for slot
59
- *
60
- * Removes all attestations associated with a slot
71
+ * Add checkpoint attestations to the pool
61
72
  *
62
- * @param slot - The slot to delete.
73
+ * @param attestations - Checkpoint attestations to add into the pool
63
74
  */
64
- deleteAttestationsForSlot(slot: SlotNumber): Promise<void>;
75
+ addCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void>;
65
76
 
66
77
  /**
67
- * Delete Attestations for slot and proposal
68
- *
69
- * Removes all attestations associated with a slot and proposal
78
+ * Delete checkpoint attestations older than the given slot
70
79
  *
71
- * @param slot - The slot to delete.
72
- * @param proposalId - The proposal to delete.
80
+ * @param slot - The oldest slot to keep.
73
81
  */
74
- deleteAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<void>;
82
+ deleteCheckpointAttestationsOlderThan(slot: SlotNumber): Promise<void>;
75
83
 
76
84
  /**
77
- * Get all Attestations for all proposals for a given slot
78
- *
79
- * Retrieve all of the attestations observed pertaining to a given slot
85
+ * Get all checkpoint attestations for a given slot
80
86
  *
81
87
  * @param slot - The slot to query
82
- * @return BlockAttestations
88
+ * @return CheckpointAttestations
83
89
  */
84
- getAttestationsForSlot(slot: SlotNumber): Promise<BlockAttestation[]>;
90
+ getCheckpointAttestationsForSlot(slot: SlotNumber): Promise<CheckpointAttestation[]>;
85
91
 
86
92
  /**
87
- * Get Attestations for slot and given proposal
88
- *
89
- * Retrieve all of the attestations observed pertaining to a given slot
93
+ * Get checkpoint attestations for slot and given proposal
90
94
  *
91
95
  * @param slot - The slot to query
92
96
  * @param proposalId - The proposal to query
93
- * @return BlockAttestations
97
+ * @return CheckpointAttestations
94
98
  */
95
- getAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<BlockAttestation[]>;
99
+ getCheckpointAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<CheckpointAttestation[]>;
96
100
 
97
101
  /**
98
- * Check if a specific attestation exists in the pool
102
+ * Check if a specific checkpoint attestation exists in the pool
99
103
  *
100
104
  * @param attestation - The attestation to check
101
105
  * @return True if the attestation exists, false otherwise
102
106
  */
103
- hasAttestation(attestation: BlockAttestation): Promise<boolean>;
107
+ hasCheckpointAttestation(attestation: CheckpointAttestation): Promise<boolean>;
104
108
 
105
109
  /**
106
110
  * Returns whether adding this proposal is permitted at current capacity:
@@ -114,16 +118,39 @@ export interface AttestationPool {
114
118
  canAddProposal(block: BlockProposal): Promise<boolean>;
115
119
 
116
120
  /**
117
- * Returns whether an attestation would be accepted for (slot, proposalId):
118
- * - True if the attestation already exists for this sender.
119
- * - True if the attestation cap for (slot, proposalId) has not been reached.
120
- * - False if the cap is reached and this attestation would be a new unique entry.
121
+ * Returns whether adding this checkpoint proposal is permitted at current capacity.
122
+ *
123
+ * @param proposal - The checkpoint proposal to check
124
+ * @returns True if the proposal can be added, false otherwise.
125
+ */
126
+ canAddCheckpointProposal(proposal: CheckpointProposal): Promise<boolean>;
127
+
128
+ /**
129
+ * Returns whether a checkpoint attestation would be accepted for (slot, proposalId).
121
130
  *
122
131
  * @param attestation - The attestation to check
123
- * @param committeeSize - Committee size for the attestation's slot, implementation may add a small buffer
132
+ * @param committeeSize - Committee size for the attestation's slot
124
133
  * @returns True if the attestation can be added, false otherwise.
125
134
  */
126
- canAddAttestation(attestation: BlockAttestation, committeeSize: number): Promise<boolean>;
135
+ canAddCheckpointAttestation(attestation: CheckpointAttestation, committeeSize: number): Promise<boolean>;
136
+
137
+ /**
138
+ * Returns whether the checkpoint proposal cap for the given slot has been reached.
139
+ *
140
+ * @param slot - The slot to check
141
+ * @returns True if the cap has been reached, false otherwise.
142
+ */
143
+ hasReachedCheckpointProposalCap(slot: SlotNumber): Promise<boolean>;
144
+
145
+ /**
146
+ * Returns whether the checkpoint attestation cap for the given slot and proposal has been reached.
147
+ *
148
+ * @param slot - The slot to check
149
+ * @param proposalId - The proposal to check
150
+ * @param committeeSize - Committee size for the slot
151
+ * @returns True if the cap has been reached, false otherwise.
152
+ */
153
+ hasReachedCheckpointAttestationCap(slot: SlotNumber, proposalId: string, committeeSize: number): Promise<boolean>;
127
154
 
128
155
  /** Returns whether the pool is empty. */
129
156
  isEmpty(): Promise<boolean>;