@serfab/cadre-core 1.6.0 → 1.8.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 (179) hide show
  1. package/README.md +8 -6
  2. package/dist/cadre-node.d.ts +548 -137
  3. package/dist/cadre-node.js +1208 -383
  4. package/dist/cadre-node.js.map +1 -1
  5. package/dist/control-authorization.d.ts +2 -2
  6. package/dist/control-authorization.js +1 -0
  7. package/dist/control-authorization.js.map +1 -1
  8. package/dist/control-cohort.d.ts +6 -0
  9. package/dist/control-cohort.js +6 -0
  10. package/dist/control-cohort.js.map +1 -1
  11. package/dist/control-database.d.ts +46 -8
  12. package/dist/control-database.js +97 -18
  13. package/dist/control-database.js.map +1 -1
  14. package/dist/control-formation-recorder.d.ts +37 -14
  15. package/dist/control-formation-recorder.js +60 -10
  16. package/dist/control-formation-recorder.js.map +1 -1
  17. package/dist/control-read-retry.d.ts +13 -12
  18. package/dist/control-read-retry.js +14 -12
  19. package/dist/control-read-retry.js.map +1 -1
  20. package/dist/control-schema.d.ts +1 -1
  21. package/dist/control-schema.js +67 -5
  22. package/dist/control-schema.js.map +1 -1
  23. package/dist/control-stream.d.ts +9 -1
  24. package/dist/control-stream.js +24 -1
  25. package/dist/control-stream.js.map +1 -1
  26. package/dist/control-write-retry.d.ts +12 -2
  27. package/dist/control-write-retry.js +13 -2
  28. package/dist/control-write-retry.js.map +1 -1
  29. package/dist/delegate-admission.d.ts +11 -8
  30. package/dist/delegate-admission.js +19 -11
  31. package/dist/delegate-admission.js.map +1 -1
  32. package/dist/diagnostics/connection-path.d.ts +0 -7
  33. package/dist/diagnostics/connection-path.js +0 -7
  34. package/dist/diagnostics/connection-path.js.map +1 -1
  35. package/dist/formation-approval.d.ts +7 -0
  36. package/dist/formation-approval.js +9 -3
  37. package/dist/formation-approval.js.map +1 -1
  38. package/dist/fs-atomic.d.ts +11 -2
  39. package/dist/fs-atomic.js +13 -3
  40. package/dist/fs-atomic.js.map +1 -1
  41. package/dist/hibernation-manager.d.ts +111 -8
  42. package/dist/hibernation-manager.js +234 -49
  43. package/dist/hibernation-manager.js.map +1 -1
  44. package/dist/index.d.ts +13 -6
  45. package/dist/index.js +27 -5
  46. package/dist/index.js.map +1 -1
  47. package/dist/joined-strand-store.d.ts +177 -0
  48. package/dist/joined-strand-store.js +431 -0
  49. package/dist/joined-strand-store.js.map +1 -0
  50. package/dist/key-store-file.js +14 -5
  51. package/dist/key-store-file.js.map +1 -1
  52. package/dist/key-store.d.ts +6 -0
  53. package/dist/key-store.js.map +1 -1
  54. package/dist/link-budget.d.ts +367 -69
  55. package/dist/link-budget.js +375 -72
  56. package/dist/link-budget.js.map +1 -1
  57. package/dist/membership-connection-gater.d.ts +30 -43
  58. package/dist/membership-connection-gater.js +31 -42
  59. package/dist/membership-connection-gater.js.map +1 -1
  60. package/dist/node-local-snapshot.d.ts +5 -4
  61. package/dist/node-local-snapshot.js +6 -3
  62. package/dist/node-local-snapshot.js.map +1 -1
  63. package/dist/peer-dial.d.ts +24 -4
  64. package/dist/peer-dial.js +74 -5
  65. package/dist/peer-dial.js.map +1 -1
  66. package/dist/peer-join-backfill.d.ts +35 -15
  67. package/dist/peer-join-backfill.js +115 -55
  68. package/dist/peer-join-backfill.js.map +1 -1
  69. package/dist/push-fanout.d.ts +6 -0
  70. package/dist/push-fanout.js +6 -0
  71. package/dist/push-fanout.js.map +1 -1
  72. package/dist/relay-reservation.d.ts +3 -1
  73. package/dist/relay-reservation.js +3 -1
  74. package/dist/relay-reservation.js.map +1 -1
  75. package/dist/relay-server.d.ts +79 -0
  76. package/dist/relay-server.js +74 -0
  77. package/dist/relay-server.js.map +1 -0
  78. package/dist/seed-bootstrap.d.ts +57 -4
  79. package/dist/seed-bootstrap.js +107 -83
  80. package/dist/seed-bootstrap.js.map +1 -1
  81. package/dist/storage-scope.d.ts +33 -17
  82. package/dist/storage-scope.js +44 -23
  83. package/dist/storage-scope.js.map +1 -1
  84. package/dist/strand-addr-protocol.d.ts +58 -21
  85. package/dist/strand-addr-protocol.js +133 -85
  86. package/dist/strand-addr-protocol.js.map +1 -1
  87. package/dist/strand-database.d.ts +20 -2
  88. package/dist/strand-database.js +42 -5
  89. package/dist/strand-database.js.map +1 -1
  90. package/dist/strand-first-sync-gate.d.ts +59 -21
  91. package/dist/strand-first-sync-gate.js +58 -19
  92. package/dist/strand-first-sync-gate.js.map +1 -1
  93. package/dist/strand-formation-deadlines.d.ts +151 -0
  94. package/dist/strand-formation-deadlines.js +171 -0
  95. package/dist/strand-formation-deadlines.js.map +1 -0
  96. package/dist/strand-formation-manager.d.ts +63 -30
  97. package/dist/strand-formation-manager.js +67 -41
  98. package/dist/strand-formation-manager.js.map +1 -1
  99. package/dist/strand-formation-protocol.d.ts +45 -35
  100. package/dist/strand-formation-protocol.js +59 -122
  101. package/dist/strand-formation-protocol.js.map +1 -1
  102. package/dist/strand-instance-manager.d.ts +152 -6
  103. package/dist/strand-instance-manager.js +331 -42
  104. package/dist/strand-instance-manager.js.map +1 -1
  105. package/dist/strand-membership-writer.d.ts +6 -0
  106. package/dist/strand-membership-writer.js +11 -0
  107. package/dist/strand-membership-writer.js.map +1 -1
  108. package/dist/strand-peer-book-file.d.ts +12 -0
  109. package/dist/strand-peer-book-file.js +37 -0
  110. package/dist/strand-peer-book-file.js.map +1 -0
  111. package/dist/strand-peer-book-protocol.d.ts +168 -0
  112. package/dist/strand-peer-book-protocol.js +356 -0
  113. package/dist/strand-peer-book-protocol.js.map +1 -0
  114. package/dist/strand-peer-book-swap.d.ts +104 -0
  115. package/dist/strand-peer-book-swap.js +284 -0
  116. package/dist/strand-peer-book-swap.js.map +1 -0
  117. package/dist/strand-peer-book.d.ts +159 -0
  118. package/dist/strand-peer-book.js +361 -0
  119. package/dist/strand-peer-book.js.map +1 -0
  120. package/dist/strand-peer-observer.d.ts +88 -0
  121. package/dist/strand-peer-observer.js +180 -0
  122. package/dist/strand-peer-observer.js.map +1 -0
  123. package/dist/strand-revocation-enforcer.js +2 -1
  124. package/dist/strand-revocation-enforcer.js.map +1 -1
  125. package/dist/strand-solicitation.d.ts +36 -20
  126. package/dist/strand-solicitation.js +4 -4
  127. package/dist/strand-solicitation.js.map +1 -1
  128. package/dist/strand-wake-protocol.d.ts +80 -23
  129. package/dist/strand-wake-protocol.js +89 -64
  130. package/dist/strand-wake-protocol.js.map +1 -1
  131. package/dist/types.d.ts +181 -33
  132. package/dist/types.js +4 -3
  133. package/dist/types.js.map +1 -1
  134. package/package.json +11 -7
  135. package/src/cadre-node.ts +1316 -398
  136. package/src/control-authorization.ts +2 -1
  137. package/src/control-cohort.ts +6 -0
  138. package/src/control-database.ts +122 -18
  139. package/src/control-formation-recorder.ts +354 -305
  140. package/src/control-read-retry.ts +14 -12
  141. package/src/control-schema.ts +67 -5
  142. package/src/control-stream.ts +25 -1
  143. package/src/control-write-retry.ts +13 -2
  144. package/src/delegate-admission.ts +23 -13
  145. package/src/diagnostics/connection-path.ts +0 -7
  146. package/src/formation-approval.ts +610 -604
  147. package/src/fs-atomic.ts +14 -4
  148. package/src/hibernation-manager.ts +638 -437
  149. package/src/index.ts +91 -6
  150. package/src/joined-strand-store.ts +498 -0
  151. package/src/key-store-file.ts +14 -5
  152. package/src/key-store.ts +6 -0
  153. package/src/link-budget.ts +393 -74
  154. package/src/membership-connection-gater.ts +31 -45
  155. package/src/node-local-snapshot.ts +293 -289
  156. package/src/peer-dial.ts +81 -7
  157. package/src/peer-join-backfill.ts +120 -57
  158. package/src/push-fanout.ts +6 -0
  159. package/src/relay-reservation.ts +3 -1
  160. package/src/relay-server.ts +98 -0
  161. package/src/seed-bootstrap.ts +133 -91
  162. package/src/storage-scope.ts +44 -23
  163. package/src/strand-addr-protocol.ts +547 -458
  164. package/src/strand-database.ts +287 -242
  165. package/src/strand-first-sync-gate.ts +58 -19
  166. package/src/strand-formation-deadlines.ts +227 -0
  167. package/src/strand-formation-manager.ts +700 -647
  168. package/src/strand-formation-protocol.ts +103 -150
  169. package/src/strand-instance-manager.ts +387 -45
  170. package/src/strand-membership-writer.ts +12 -0
  171. package/src/strand-peer-book-file.ts +39 -0
  172. package/src/strand-peer-book-protocol.ts +466 -0
  173. package/src/strand-peer-book-swap.ts +338 -0
  174. package/src/strand-peer-book.ts +475 -0
  175. package/src/strand-peer-observer.ts +235 -0
  176. package/src/strand-revocation-enforcer.ts +2 -1
  177. package/src/strand-solicitation.ts +519 -500
  178. package/src/strand-wake-protocol.ts +401 -355
  179. package/src/types.ts +185 -33
@@ -85,7 +85,10 @@
85
85
  * infra outright, and admits peers it cannot place only within a bounded
86
86
  * budget ({@link UnauthorizedReservationBudget}) — a member whose row is in
87
87
  * flight always finds a slot under any sane cap, while outsiders cannot
88
- * annex the party's relay capacity.
88
+ * annex the party's relay capacity. COUNT and lifetime are the only bounds
89
+ * on such a peer: a party-run relay forwards without libp2p's per-connection
90
+ * data and duration limit by default (`relay-server.ts`), so what a granted
91
+ * slot carries is not capped.
89
92
  * - An `'admit-for-relay'` connection that is NOT reserving is dropped: it has
90
93
  * {@link RELAY_ADMISSION_RESERVE_DEADLINE_MS} to get a reservation ADMITTED
91
94
  * at that hook, after which the gate CLOSES the underlying connection so
@@ -170,21 +173,6 @@ export declare const STRANGER_OPEN_PROTOCOLS: readonly string[];
170
173
  * caller re-opens the window via `CadreNode.openEnrollmentWindow`).
171
174
  */
172
175
  export declare const DEFAULT_ENROLLMENT_WINDOW_MS: number;
173
- /**
174
- * Deadline for one admission decision, after which the fail-open outcome is
175
- * used (connection admitted / reservation admitted).
176
- *
177
- * libp2p awaits `denyInboundEncryptedConnection` inside the inbound upgrade
178
- * WITHOUT racing its inbound-upgrade timeout signal (unlike the pre-encryption
179
- * `denyInboundConnection` hook), so a decision that never settles wedges that
180
- * upgrade forever — the connection-manager's inbound-upgrade slot is taken by
181
- * `acceptIncomingConnection` and released in the `finally` that never runs. The
182
- * real policy reads the control DB (`listAuthorizedMembers`), which can pull
183
- * over the network, so "never settles" is reachable. Bounding it here keeps the
184
- * fail-open contract honest: a slow decision admits rather than silently
185
- * failing closed (or not at all).
186
- */
187
- export declare const ADMISSION_DECISION_TIMEOUT_MS = 2000;
188
176
  /**
189
177
  * How long an `'admit-for-relay'` connection may exist without a relay
190
178
  * reservation being ADMITTED at the `denyInboundRelayReservation` hook, after
@@ -193,8 +181,13 @@ export declare const ADMISSION_DECISION_TIMEOUT_MS = 2000;
193
181
  * dials and requests in one drive; a strand node's configured circuit listener
194
182
  * does the same from inside its own `listen()`), so a connection idle past this
195
183
  * deadline is not reserving.
184
+ *
185
+ * Derived from the link ({@link relayAdmissionReserveDeadlineMs}): one link round trip for the
186
+ * request to arrive plus one admission decision on it. This is the value at the default
187
+ * declaration; `CadreNode` passes the one derived from the relay's OWN declaration, because the
188
+ * relay is the machine that decides.
196
189
  */
197
- export declare const RELAY_ADMISSION_RESERVE_DEADLINE_MS = 5000;
190
+ export declare const RELAY_ADMISSION_RESERVE_DEADLINE_MS: number;
198
191
  /**
199
192
  * Bound on the graceful close of an expired relay-only connection. It exists
200
193
  * because `AbstractMultiaddrConnection.close()` awaits an `idle`/`drain` event
@@ -215,29 +208,16 @@ export declare const RELAY_ADMISSION_CLOSE_TIMEOUT_MS = 2000;
215
208
  * `network.unauthorizedRelayReservationCap` (0 refuses every unauthorized
216
209
  * reservation — the strict pre-seam posture).
217
210
  *
218
- * NOTE: this cap shares the relay server's own reservation store, whose default
219
- * size is 15 (`@libp2p/circuit-relay-v2`'s `DEFAULT_MAX_RESERVATION_STORE_SIZE`);
220
- * unplaced peers may therefore occupy up to this many of those slots, and the
221
- * rest are what members and delegates compete for. This module cannot read the
222
- * server's size, so the two are kept apart by hand — if either is raised, keep
223
- * this one well under the store's, or a fleet of unplaceable peers can crowd
224
- * genuine members out of the server's own store (which the gate cannot override).
211
+ * NOTE: this cap shares the relay server's own reservation store, whose
212
+ * party-run default size is `PARTY_RELAY_MAX_RESERVATIONS` (128,
213
+ * `relay-server.ts`); unplaced peers may therefore occupy up to this many of
214
+ * those slots, and the rest are what members and delegates compete for. The two
215
+ * are kept apart by hand — if this is raised, or an embedder shrinks the store
216
+ * through `network.relayServerInit.reservations.maxReservations`, keep this one
217
+ * well under the store's, or a fleet of unplaceable peers can crowd genuine
218
+ * members out of the server's own store (which the gate cannot override).
225
219
  */
226
220
  export declare const MAX_UNAUTHORIZED_RELAY_RESERVATIONS = 8;
227
- /**
228
- * How long one {@link UnauthorizedReservationBudget} entry occupies a slot
229
- * without a refresh. Mirrors the relay server's own default reservation TTL
230
- * (`@libp2p/circuit-relay-v2`'s `DEFAULT_MAX_RESERVATION_TTL`, 2 h): the server
231
- * holds an unrefreshed reservation exactly that long, and a live reserver
232
- * re-requests (re-hitting the admission hook, refreshing its entry) well before
233
- * expiry — so the live entry count tracks the server's own occupancy without
234
- * this module reaching into the server's reservation store.
235
- *
236
- * NOTE: a mirror, not a live coupling — if the relay server is ever configured
237
- * with a non-default `reservationTtl` (db-p2p's `relayServerInit`), update this
238
- * constant alongside it or the budget's occupancy drifts from the server's.
239
- */
240
- export declare const UNAUTHORIZED_RESERVATION_TTL_MS: number;
241
221
  /**
242
222
  * The connection-level outcome of the admission policy:
243
223
  * - `'admit'` — a peer with a legitimate claim on the connection (member,
@@ -278,19 +258,26 @@ export interface InboundAdmissionPolicy {
278
258
  * Bounded budget of concurrent relay reservations for peers the membership
279
259
  * check could not place. `tryAdmit` is the whole surface: an already-admitted
280
260
  * peer refreshes its entry (a reservation refresh never double-counts), a new
281
- * peer takes a free slot or is refused. Entries expire after `ttlMs` (see
282
- * {@link UNAUTHORIZED_RESERVATION_TTL_MS} for why that mirrors the relay
283
- * server's own hold). Injectable `now` keeps expiry testable without fake
261
+ * peer takes a free slot or is refused. Entries expire after `ttlMs`, which
262
+ * `CadreNode` passes as the relay server's own resolved `reservationTtl`
263
+ * (`relay-server.ts`): the server holds an unrefreshed reservation exactly that
264
+ * long, and a live reserver re-requests (re-hitting the admission hook,
265
+ * refreshing its entry) well before expiry — so the live entry count tracks the
266
+ * server's own occupancy without this module reaching into the server's
267
+ * reservation store. Injectable `now` keeps expiry testable without fake
284
268
  * timers. Authorized members and delegates are never run through this — the
285
269
  * policy admits them before consulting the budget, and `release`s the slot such
286
270
  * a peer took while it was still unplaceable, so the boot-ordering window a
287
271
  * member passes through costs the budget nothing once its row lands.
288
272
  */
289
273
  export declare class UnauthorizedReservationBudget {
290
- private readonly cap;
274
+ /** Most peers admitted at once — `network.unauthorizedRelayReservationCap`, resolved. */
275
+ readonly cap: number;
291
276
  private readonly ttlMs;
292
277
  private readonly admitted;
293
- constructor(cap?: number, ttlMs?: number);
278
+ constructor(
279
+ /** Most peers admitted at once — `network.unauthorizedRelayReservationCap`, resolved. */
280
+ cap?: number, ttlMs?: number);
294
281
  /** Number of live (unexpired at last prune) entries — test/diagnostic surface. */
295
282
  get size(): number;
296
283
  /** Admit (or refresh) `remotePeerId` if a slot is free; false when the cap is spent. */
@@ -85,7 +85,10 @@
85
85
  * infra outright, and admits peers it cannot place only within a bounded
86
86
  * budget ({@link UnauthorizedReservationBudget}) — a member whose row is in
87
87
  * flight always finds a slot under any sane cap, while outsiders cannot
88
- * annex the party's relay capacity.
88
+ * annex the party's relay capacity. COUNT and lifetime are the only bounds
89
+ * on such a peer: a party-run relay forwards without libp2p's per-connection
90
+ * data and duration limit by default (`relay-server.ts`), so what a granted
91
+ * slot carries is not capped.
89
92
  * - An `'admit-for-relay'` connection that is NOT reserving is dropped: it has
90
93
  * {@link RELAY_ADMISSION_RESERVE_DEADLINE_MS} to get a reservation ADMITTED
91
94
  * at that hook, after which the gate CLOSES the underlying connection so
@@ -158,6 +161,8 @@ import debug from 'debug';
158
161
  import { SEED_PROTOCOL } from './seed-bootstrap.js';
159
162
  import { FORMATION_PROTOCOL } from './strand-formation-protocol.js';
160
163
  import { withDeadline } from './control-stream.js';
164
+ import { PARTY_RELAY_RESERVATION_TTL_MS } from './relay-server.js';
165
+ import { ADMISSION_DECISION_TIMEOUT_MS, relayAdmissionReserveDeadlineMs } from './link-budget.js';
161
166
  const log = debug('sereus:cadre:connection-gater');
162
167
  /**
163
168
  * The protocols a not-yet-authorized peer may legitimately speak on a control
@@ -174,21 +179,6 @@ export const STRANGER_OPEN_PROTOCOLS = [SEED_PROTOCOL, FORMATION_PROTOCOL];
174
179
  * caller re-opens the window via `CadreNode.openEnrollmentWindow`).
175
180
  */
176
181
  export const DEFAULT_ENROLLMENT_WINDOW_MS = 30 * 60 * 1000;
177
- /**
178
- * Deadline for one admission decision, after which the fail-open outcome is
179
- * used (connection admitted / reservation admitted).
180
- *
181
- * libp2p awaits `denyInboundEncryptedConnection` inside the inbound upgrade
182
- * WITHOUT racing its inbound-upgrade timeout signal (unlike the pre-encryption
183
- * `denyInboundConnection` hook), so a decision that never settles wedges that
184
- * upgrade forever — the connection-manager's inbound-upgrade slot is taken by
185
- * `acceptIncomingConnection` and released in the `finally` that never runs. The
186
- * real policy reads the control DB (`listAuthorizedMembers`), which can pull
187
- * over the network, so "never settles" is reachable. Bounding it here keeps the
188
- * fail-open contract honest: a slow decision admits rather than silently
189
- * failing closed (or not at all).
190
- */
191
- export const ADMISSION_DECISION_TIMEOUT_MS = 2000;
192
182
  /**
193
183
  * How long an `'admit-for-relay'` connection may exist without a relay
194
184
  * reservation being ADMITTED at the `denyInboundRelayReservation` hook, after
@@ -197,8 +187,13 @@ export const ADMISSION_DECISION_TIMEOUT_MS = 2000;
197
187
  * dials and requests in one drive; a strand node's configured circuit listener
198
188
  * does the same from inside its own `listen()`), so a connection idle past this
199
189
  * deadline is not reserving.
190
+ *
191
+ * Derived from the link ({@link relayAdmissionReserveDeadlineMs}): one link round trip for the
192
+ * request to arrive plus one admission decision on it. This is the value at the default
193
+ * declaration; `CadreNode` passes the one derived from the relay's OWN declaration, because the
194
+ * relay is the machine that decides.
200
195
  */
201
- export const RELAY_ADMISSION_RESERVE_DEADLINE_MS = 5000;
196
+ export const RELAY_ADMISSION_RESERVE_DEADLINE_MS = relayAdmissionReserveDeadlineMs();
202
197
  /**
203
198
  * Bound on the graceful close of an expired relay-only connection. It exists
204
199
  * because `AbstractMultiaddrConnection.close()` awaits an `idle`/`drain` event
@@ -210,6 +205,7 @@ export const RELAY_ADMISSION_RESERVE_DEADLINE_MS = 5000;
210
205
  * Applied through {@link withDeadline}, not `AbortSignal.timeout`: the latter is
211
206
  * not reliably present on React Native/Hermes, which loads this same module.
212
207
  */
208
+ // eslint-disable-next-line no-restricted-syntax -- link-independent: bounds a local connection close inside a timer callback, and expiry aborts the connection instead
213
209
  export const RELAY_ADMISSION_CLOSE_TIMEOUT_MS = 2000;
214
210
  /**
215
211
  * Default cap on concurrent relay reservations held by peers the membership
@@ -219,43 +215,36 @@ export const RELAY_ADMISSION_CLOSE_TIMEOUT_MS = 2000;
219
215
  * `network.unauthorizedRelayReservationCap` (0 refuses every unauthorized
220
216
  * reservation — the strict pre-seam posture).
221
217
  *
222
- * NOTE: this cap shares the relay server's own reservation store, whose default
223
- * size is 15 (`@libp2p/circuit-relay-v2`'s `DEFAULT_MAX_RESERVATION_STORE_SIZE`);
224
- * unplaced peers may therefore occupy up to this many of those slots, and the
225
- * rest are what members and delegates compete for. This module cannot read the
226
- * server's size, so the two are kept apart by hand — if either is raised, keep
227
- * this one well under the store's, or a fleet of unplaceable peers can crowd
228
- * genuine members out of the server's own store (which the gate cannot override).
218
+ * NOTE: this cap shares the relay server's own reservation store, whose
219
+ * party-run default size is `PARTY_RELAY_MAX_RESERVATIONS` (128,
220
+ * `relay-server.ts`); unplaced peers may therefore occupy up to this many of
221
+ * those slots, and the rest are what members and delegates compete for. The two
222
+ * are kept apart by hand — if this is raised, or an embedder shrinks the store
223
+ * through `network.relayServerInit.reservations.maxReservations`, keep this one
224
+ * well under the store's, or a fleet of unplaceable peers can crowd genuine
225
+ * members out of the server's own store (which the gate cannot override).
229
226
  */
230
227
  export const MAX_UNAUTHORIZED_RELAY_RESERVATIONS = 8;
231
- /**
232
- * How long one {@link UnauthorizedReservationBudget} entry occupies a slot
233
- * without a refresh. Mirrors the relay server's own default reservation TTL
234
- * (`@libp2p/circuit-relay-v2`'s `DEFAULT_MAX_RESERVATION_TTL`, 2 h): the server
235
- * holds an unrefreshed reservation exactly that long, and a live reserver
236
- * re-requests (re-hitting the admission hook, refreshing its entry) well before
237
- * expiry — so the live entry count tracks the server's own occupancy without
238
- * this module reaching into the server's reservation store.
239
- *
240
- * NOTE: a mirror, not a live coupling — if the relay server is ever configured
241
- * with a non-default `reservationTtl` (db-p2p's `relayServerInit`), update this
242
- * constant alongside it or the budget's occupancy drifts from the server's.
243
- */
244
- export const UNAUTHORIZED_RESERVATION_TTL_MS = 2 * 60 * 60 * 1000;
245
228
  /**
246
229
  * Bounded budget of concurrent relay reservations for peers the membership
247
230
  * check could not place. `tryAdmit` is the whole surface: an already-admitted
248
231
  * peer refreshes its entry (a reservation refresh never double-counts), a new
249
- * peer takes a free slot or is refused. Entries expire after `ttlMs` (see
250
- * {@link UNAUTHORIZED_RESERVATION_TTL_MS} for why that mirrors the relay
251
- * server's own hold). Injectable `now` keeps expiry testable without fake
232
+ * peer takes a free slot or is refused. Entries expire after `ttlMs`, which
233
+ * `CadreNode` passes as the relay server's own resolved `reservationTtl`
234
+ * (`relay-server.ts`): the server holds an unrefreshed reservation exactly that
235
+ * long, and a live reserver re-requests (re-hitting the admission hook,
236
+ * refreshing its entry) well before expiry — so the live entry count tracks the
237
+ * server's own occupancy without this module reaching into the server's
238
+ * reservation store. Injectable `now` keeps expiry testable without fake
252
239
  * timers. Authorized members and delegates are never run through this — the
253
240
  * policy admits them before consulting the budget, and `release`s the slot such
254
241
  * a peer took while it was still unplaceable, so the boot-ordering window a
255
242
  * member passes through costs the budget nothing once its row lands.
256
243
  */
257
244
  export class UnauthorizedReservationBudget {
258
- constructor(cap = MAX_UNAUTHORIZED_RELAY_RESERVATIONS, ttlMs = UNAUTHORIZED_RESERVATION_TTL_MS) {
245
+ constructor(
246
+ /** Most peers admitted at once — `network.unauthorizedRelayReservationCap`, resolved. */
247
+ cap = MAX_UNAUTHORIZED_RELAY_RESERVATIONS, ttlMs = PARTY_RELAY_RESERVATION_TTL_MS) {
259
248
  this.cap = cap;
260
249
  this.ttlMs = ttlMs;
261
250
  this.admitted = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"membership-connection-gater.js","sourceRoot":"","sources":["../src/membership-connection-gater.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2JG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,GAAG,GAAG,KAAK,CAAC,+BAA+B,CAAC,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAsB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAE9F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAK,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,IAAK,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAK,CAAC;AAEtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,GAAG,EA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EACtC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CACrC,CAAC;YACF,OAAO;QACT,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,yEAAyE,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QACtG,CAAC;QACD,8EAA8E;QAC9E,2EAA2E;QAC3E,gEAAgE;QAChE,uEAAuE;QACvE,wDAAwD;QACxD,gGAAgG;QAChG,6EAA6E;QAC7E,yEAAyE;QACzE,kEAAkE;QAClE,IAAI,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,sEAAsE,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;QACrH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,8DAA8D,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;CACF"}
@@ -28,15 +28,16 @@ export interface DurableSlot {
28
28
  }
29
29
  /**
30
30
  * What one unusable entry means for its siblings — the single intentional
31
- * difference between the two records:
31
+ * difference between the records:
32
32
  *
33
33
  * - `'discard-all'` (the trusted-owner anchor): a record that cannot be read
34
34
  * in full is not an anchor. Trusting a *subset* of the keys a file claims is
35
35
  * a silent, security-relevant downgrade, so the whole record is discarded
36
36
  * and the node trusts no one until re-seeded out of band.
37
- * - `'drop-entry'` (the bootstrap-peer store): the record is a best-effort
38
- * retry list and nothing in it is trust-bearing, so one junk entry must not
39
- * discard a stranded node's only remaining way back into its party.
37
+ * - `'drop-entry'` (the bootstrap-peer store and the strand peer book): the
38
+ * record is a best-effort dial list and nothing in it is trust-bearing, so one
39
+ * junk entry must not discard a stranded node's only remaining way back to
40
+ * its party or its strand's peers.
40
41
  */
41
42
  export type UnusableEntryPolicy = 'discard-all' | 'drop-entry';
42
43
  /** What a particular node-local record persists, and how it validates it. */
@@ -4,15 +4,18 @@
4
4
  * from shared group state:
5
5
  *
6
6
  * - the trusted-owner anchor (`trusted-owner-store.ts`),
7
- * - the cold-start bootstrap-peer store (`bootstrap-peer-store.ts`).
7
+ * - the cold-start bootstrap-peer store (`bootstrap-peer-store.ts`),
8
+ * - the strand peer book (`strand-peer-book.ts`), whose entries are one map per
9
+ * strand rather than one value per key — the validation hook below is what
10
+ * lets it drop a single junk peer without dropping the strand.
8
11
  *
9
- * A THIRD node-local record — the enrolled-machine count
12
+ * ANOTHER node-local record — the enrolled-machine count
10
13
  * (`enrolled-machine-store.ts`) — reuses {@link DurableSlot} but deliberately
11
14
  * NOT this module's snapshot machinery: it is one scalar rather than an entry
12
15
  * map, and it must cold-start rather than throw on an unreadable slot. Its
13
16
  * module comment carries the reasoning; do not fold it in here.
14
17
  *
15
- * Both records here are the same mechanism with a different payload: a
18
+ * Every record here is the same mechanism with a different payload: a
16
19
  * `{ version, partyId, <entries> }` envelope, snapshot-written whole on every
17
20
  * change, loaded under one fail-safe-but-not-fail-silent policy. The only part
18
21
  * that differs per platform is WHERE the bytes are kept — Node writes a file,
@@ -1 +1 @@
1
- {"version":3,"file":"node-local-snapshot.js","sourceRoot":"","sources":["../src/node-local-snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,GAAG,GAAG,KAAK,CAAC,kCAAkC,CAAC,CAAC;AA+BtD,kFAAkF;AAClF,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAgC3B;;;;;;;;;;GAUG;AACH,MAAM,OAAO,iBAAiB;IAQ7B,YACkB,IAAiB,EACzB,OAAe,EACP,IAA8B,EAC9B,OAAuB;QAHvB,SAAI,GAAJ,IAAI,CAAa;QACzB,YAAO,GAAP,OAAO,CAAQ;QACP,SAAI,GAAJ,IAAI,CAA0B;QAC9B,YAAO,GAAP,OAAO,CAAgB;QAXzC;;;;WAIG;QACK,eAAU,GAAkB,OAAO,CAAC,OAAO,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IACvC,2EAA2E;IAC3E,oDAAoD;IACpD,IAAI,KAAK,CAAC,OAAO,KAAK,gBAAgB,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IACtF,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IAClC,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC"}
@@ -22,12 +22,13 @@
22
22
  * Dependency-free apart from `control-stream.ts`, so any module may import it
23
23
  * without creating an import cycle.
24
24
  */
25
- import type { Connection } from '@libp2p/interface';
25
+ import type { Connection, PeerId } from '@libp2p/interface';
26
26
  import type { Multiaddr } from '@multiformats/multiaddr';
27
27
  /**
28
28
  * Default limit on ONE address's dial attempt, in ms, at the DEFAULT declared link round trip:
29
- * `RELAYED_DIAL_ROUND_TRIPS` (4) x `DECLARED_LINK_ROUND_TRIP_MS` (3500 ms) = 14 000 ms. It was
30
- * a fixed 8000 ms before it was derived.
29
+ * `RELAYED_DIAL_ROUND_TRIPS` (4) x `DECLARED_LINK_ROUND_TRIP_MS` (3500 ms) plus the called
30
+ * machine's `ADMISSION_DECISION_TIMEOUT_MS` (2000 ms) = 16 000 ms (`relayedDialBudgetMs`). It
31
+ * was a fixed 8000 ms before it was derived.
31
32
  *
32
33
  * It has to cover the slowest address that should succeed, because an attempt
33
34
  * that needs longer fails the same way on every retry. That is a relayed dial on
@@ -101,20 +102,39 @@ export interface PeerDialBudget {
101
102
  export declare const DEFAULT_PEER_DIAL_BUDGET: Readonly<PeerDialBudget>;
102
103
  /** The slice of a libp2p node {@link dialPeerAddrs} uses. */
103
104
  export interface AddrDialer {
105
+ /** This node's id, to recognise an address that relays through this node ({@link relaysThrough}). */
106
+ readonly peerId: PeerId;
104
107
  dial(addr: Multiaddr, options: {
105
108
  signal: AbortSignal;
106
109
  }): Promise<Connection>;
107
110
  }
111
+ /**
112
+ * Thrown by {@link dialPeerAddrs} when it was given addresses but every one reaches the peer by
113
+ * relaying through this node, so none was dialed.
114
+ *
115
+ * This is where a relay lands for a peer that holds a reservation on it (a phone, or any node that
116
+ * cannot listen): the address that peer publishes is `/<relay transport>/p2p/<relay>/p2p-circuit/p2p/<peer>`,
117
+ * and dialing it from the relay itself fails with libp2p's `Can not dial self`. Nothing this node
118
+ * does can repair it; once the peer's connection drops, only the peer can reconnect. Callers log it
119
+ * as that rather than as a dial failure.
120
+ */
121
+ export declare class SelfRelayOnlyError extends Error {
122
+ constructor(label: string);
123
+ }
108
124
  /**
109
125
  * Dial one peer from `addrs`, one address per `dial()` call, and return the
110
126
  * first connection that forms. Direct addresses are tried before relayed ones
111
127
  * ({@link directBeforeRelayed}); otherwise the given order is kept.
112
128
  *
129
+ * Addresses that relay through this node are dropped first ({@link relaysThrough}):
130
+ * dialing one could only fail with `Can not dial self`. When that leaves nothing
131
+ * of a non-empty list, this throws {@link SelfRelayOnlyError} without dialing.
132
+ *
113
133
  * Addresses naming a transport this node lacks are not filtered out first: a
114
134
  * one-address `dial()` rejects those at once (`NoValidAddressesError`), so they
115
135
  * cost a log line, not time.
116
136
  *
117
- * Throws when no address connects — see {@link tryAddrsInTurn} for the error.
137
+ * Otherwise throws when no address connects — see {@link tryAddrsInTurn} for the error.
118
138
  *
119
139
  * @param label Names the dial in timeout messages and logs, e.g.
120
140
  * `reconcileControlCohort dial of sibling <peerId>`; each attempt reads
package/dist/peer-dial.js CHANGED
@@ -23,13 +23,15 @@
23
23
  * without creating an import cycle.
24
24
  */
25
25
  import debug from 'debug';
26
+ import { peerIdFromString } from '@libp2p/peer-id';
26
27
  import { withDeadline } from './control-stream.js';
27
28
  import { relayedDialBudgetMs } from './link-budget.js';
28
29
  const log = debug('sereus:cadre:peer-dial');
29
30
  /**
30
31
  * Default limit on ONE address's dial attempt, in ms, at the DEFAULT declared link round trip:
31
- * `RELAYED_DIAL_ROUND_TRIPS` (4) x `DECLARED_LINK_ROUND_TRIP_MS` (3500 ms) = 14 000 ms. It was
32
- * a fixed 8000 ms before it was derived.
32
+ * `RELAYED_DIAL_ROUND_TRIPS` (4) x `DECLARED_LINK_ROUND_TRIP_MS` (3500 ms) plus the called
33
+ * machine's `ADMISSION_DECISION_TIMEOUT_MS` (2000 ms) = 16 000 ms (`relayedDialBudgetMs`). It
34
+ * was a fixed 8000 ms before it was derived.
33
35
  *
34
36
  * It has to cover the slowest address that should succeed, because an attempt
35
37
  * that needs longer fails the same way on every retry. That is a relayed dial on
@@ -97,23 +99,47 @@ export const DEFAULT_PEER_DIAL_BUDGET = {
97
99
  perAddressMs: DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS,
98
100
  totalMs: DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS,
99
101
  };
102
+ /**
103
+ * Thrown by {@link dialPeerAddrs} when it was given addresses but every one reaches the peer by
104
+ * relaying through this node, so none was dialed.
105
+ *
106
+ * This is where a relay lands for a peer that holds a reservation on it (a phone, or any node that
107
+ * cannot listen): the address that peer publishes is `/<relay transport>/p2p/<relay>/p2p-circuit/p2p/<peer>`,
108
+ * and dialing it from the relay itself fails with libp2p's `Can not dial self`. Nothing this node
109
+ * does can repair it; once the peer's connection drops, only the peer can reconnect. Callers log it
110
+ * as that rather than as a dial failure.
111
+ */
112
+ export class SelfRelayOnlyError extends Error {
113
+ constructor(label) {
114
+ super(`${label}: every candidate address relays through this node; only the peer can reconnect`);
115
+ this.name = 'SelfRelayOnlyError';
116
+ }
117
+ }
100
118
  /**
101
119
  * Dial one peer from `addrs`, one address per `dial()` call, and return the
102
120
  * first connection that forms. Direct addresses are tried before relayed ones
103
121
  * ({@link directBeforeRelayed}); otherwise the given order is kept.
104
122
  *
123
+ * Addresses that relay through this node are dropped first ({@link relaysThrough}):
124
+ * dialing one could only fail with `Can not dial self`. When that leaves nothing
125
+ * of a non-empty list, this throws {@link SelfRelayOnlyError} without dialing.
126
+ *
105
127
  * Addresses naming a transport this node lacks are not filtered out first: a
106
128
  * one-address `dial()` rejects those at once (`NoValidAddressesError`), so they
107
129
  * cost a log line, not time.
108
130
  *
109
- * Throws when no address connects — see {@link tryAddrsInTurn} for the error.
131
+ * Otherwise throws when no address connects — see {@link tryAddrsInTurn} for the error.
110
132
  *
111
133
  * @param label Names the dial in timeout messages and logs, e.g.
112
134
  * `reconcileControlCohort dial of sibling <peerId>`; each attempt reads
113
135
  * `<label> via <addr>`.
114
136
  */
115
- export function dialPeerAddrs(dialer, addrs, budget, label) {
116
- return tryAddrsInTurn(directBeforeRelayed(addrs), budget, label, (addr, signal) => dialer.dial(addr, { signal }));
137
+ export async function dialPeerAddrs(dialer, addrs, budget, label) {
138
+ const dialable = withoutSelfRelayed(dialer, addrs, label);
139
+ if (addrs.length > 0 && dialable.length === 0) {
140
+ throw new SelfRelayOnlyError(label);
141
+ }
142
+ return tryAddrsInTurn(directBeforeRelayed(dialable), budget, label, (addr, signal) => dialer.dial(addr, { signal }));
117
143
  }
118
144
  /**
119
145
  * Run `attempt` against each address in the given order until one succeeds, and
@@ -180,6 +206,49 @@ export function directBeforeRelayed(addrs) {
180
206
  const relayed = (addr) => addr.getComponents().some((c) => c.name === 'p2p-circuit');
181
207
  return [...addrs.filter((addr) => !relayed(addr)), ...addrs.filter(relayed)];
182
208
  }
209
+ /** `addrs` without those that relay through `dialer` itself, each dropped one logged. */
210
+ function withoutSelfRelayed(dialer, addrs, label) {
211
+ return addrs.filter((addr) => {
212
+ if (!relaysThrough(addr, dialer.peerId)) {
213
+ return true;
214
+ }
215
+ log('%s: skipping %s — it relays through this node', label, addr.toString());
216
+ return false;
217
+ });
218
+ }
219
+ /**
220
+ * Whether `addr` reaches its target by relaying through `relay` at any hop.
221
+ *
222
+ * A circuit address names its relay in the `p2p` component immediately before
223
+ * the `p2p-circuit` marker (`/<transport>/p2p/<relay>/p2p-circuit/p2p/<target>`),
224
+ * so the components are walked rather than the text searched: the target's id
225
+ * after the marker, a bare `/p2p-circuit` naming no relay, and a multi-hop chain
226
+ * each read correctly that way. Same rule as db-p2p's `routesThroughRelay`, which
227
+ * its package does not export.
228
+ */
229
+ function relaysThrough(addr, relay) {
230
+ const components = addr.getComponents();
231
+ return components.some((component, i) => component.name === 'p2p-circuit' && namesPeer(components[i - 1], relay));
232
+ }
233
+ /**
234
+ * Whether `component` is a `p2p` component naming `peer`. Compared as canonical
235
+ * strings because a multiaddr keeps a peer id in whichever form it was written
236
+ * (base58 or CIDv1). `PeerId.equals` is avoided because test doubles supply the
237
+ * dialer's `peerId` with `toString` only.
238
+ */
239
+ function namesPeer(component, peer) {
240
+ if (component?.name !== 'p2p' || component.value === undefined) {
241
+ return false;
242
+ }
243
+ const expected = peer.toString();
244
+ try {
245
+ return peerIdFromString(component.value).toString() === expected;
246
+ }
247
+ catch (err) {
248
+ log('cannot read %s as a peer id; treating it as not this node: %o', component.value, err);
249
+ return false;
250
+ }
251
+ }
183
252
  function allAttemptsFailed(label, failures) {
184
253
  if (failures.length === 0) {
185
254
  return new Error(`${label}: no candidate addresses`);
@@ -1 +1 @@
1
- {"version":3,"file":"peer-dial.js","sourceRoot":"","sources":["../src/peer-dial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,GAAG,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,kDAAkD,GAAG,mBAA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