@serfab/cadre-core 1.4.0 → 1.5.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 (63) hide show
  1. package/dist/cadre-node.d.ts +38 -15
  2. package/dist/cadre-node.js +77 -29
  3. package/dist/cadre-node.js.map +1 -1
  4. package/dist/control-database.d.ts +24 -10
  5. package/dist/control-database.js +48 -16
  6. package/dist/control-database.js.map +1 -1
  7. package/dist/control-read-retry.d.ts +12 -0
  8. package/dist/control-read-retry.js +12 -0
  9. package/dist/control-read-retry.js.map +1 -1
  10. package/dist/control-write-retry.d.ts +5 -4
  11. package/dist/control-write-retry.js +24 -7
  12. package/dist/control-write-retry.js.map +1 -1
  13. package/dist/index.d.ts +3 -2
  14. package/dist/index.js +5 -2
  15. package/dist/index.js.map +1 -1
  16. package/dist/link-budget.d.ts +182 -0
  17. package/dist/link-budget.js +195 -0
  18. package/dist/link-budget.js.map +1 -0
  19. package/dist/peer-dial.d.ts +36 -17
  20. package/dist/peer-dial.js +37 -17
  21. package/dist/peer-dial.js.map +1 -1
  22. package/dist/peer-join-backfill.d.ts +58 -4
  23. package/dist/peer-join-backfill.js +165 -20
  24. package/dist/peer-join-backfill.js.map +1 -1
  25. package/dist/relay-reservation.d.ts +59 -11
  26. package/dist/relay-reservation.js +169 -43
  27. package/dist/relay-reservation.js.map +1 -1
  28. package/dist/seed-bootstrap.js +2 -1
  29. package/dist/seed-bootstrap.js.map +1 -1
  30. package/dist/strand-first-sync-gate.d.ts +43 -5
  31. package/dist/strand-first-sync-gate.js +55 -7
  32. package/dist/strand-first-sync-gate.js.map +1 -1
  33. package/dist/strand-instance-manager.d.ts +27 -2
  34. package/dist/strand-instance-manager.js +56 -13
  35. package/dist/strand-instance-manager.js.map +1 -1
  36. package/dist/strand-membership-reconciler.d.ts +200 -45
  37. package/dist/strand-membership-reconciler.js +302 -86
  38. package/dist/strand-membership-reconciler.js.map +1 -1
  39. package/dist/strand-membership-writer.d.ts +3 -2
  40. package/dist/strand-membership-writer.js +67 -90
  41. package/dist/strand-membership-writer.js.map +1 -1
  42. package/dist/strand-network-config.d.ts +2 -2
  43. package/dist/strand-network-config.js +2 -2
  44. package/dist/types.d.ts +96 -9
  45. package/dist/types.js +14 -4
  46. package/dist/types.js.map +1 -1
  47. package/package.json +8 -8
  48. package/src/cadre-node.ts +7445 -7397
  49. package/src/control-database.ts +48 -16
  50. package/src/control-read-retry.ts +214 -202
  51. package/src/control-write-retry.ts +24 -7
  52. package/src/index.ts +581 -563
  53. package/src/link-budget.ts +217 -0
  54. package/src/peer-dial.ts +39 -17
  55. package/src/peer-join-backfill.ts +192 -23
  56. package/src/relay-reservation.ts +1119 -951
  57. package/src/seed-bootstrap.ts +2 -1
  58. package/src/strand-first-sync-gate.ts +55 -7
  59. package/src/strand-instance-manager.ts +1516 -1458
  60. package/src/strand-membership-reconciler.ts +334 -92
  61. package/src/strand-membership-writer.ts +1962 -1987
  62. package/src/strand-network-config.ts +2 -2
  63. package/src/types.ts +95 -8
@@ -8,6 +8,13 @@ import { BlockTransferClient, type IRawStorage } from '@optimystic/db-p2p';
8
8
  * changes it or starts exporting it.
9
9
  */
10
10
  export declare const MAX_BLOCK_MESSAGE_BYTES: number;
11
+ /**
12
+ * Consecutive failed catch-up runs against ONE peer before the module says so on
13
+ * `console.warn` rather than only in its DEBUG log. At the default backoff that is reached
14
+ * about 35 seconds in (5 s + 10 s + 20 s), which is late enough to have ruled out a blip and
15
+ * early enough to be the first thing an operator sees about a machine that is not catching up.
16
+ */
17
+ export declare const PEER_JOIN_BACKFILL_WARN_AFTER_FAILURES = 3;
11
18
  /** Tuning for the per-peer catch-up. Every field optional; defaults in {@link DEFAULT_PEER_JOIN_BACKFILL}. */
12
19
  export interface PeerJoinBackfillConfig {
13
20
  /** Default true. False disables the catch-up entirely (the pre-existing behaviour). */
@@ -20,10 +27,28 @@ export interface PeerJoinBackfillConfig {
20
27
  maxChunkBytes?: number;
21
28
  /** Max blocks per push message. Default 64. */
22
29
  maxChunkBlocks?: number;
23
- /** Per-push dial deadline, ms. Default 3000 (matches SpreadOnChurnMonitor). */
30
+ /**
31
+ * Per-push dial deadline, ms. Default {@link peerJoinPushBudget}'s `dialTimeoutMs` — four link
32
+ * round trips at the declared link, 8000 ms as shipped. NOT a fixed number: a relayed dial
33
+ * costs a fixed number of exchanges, so a host on a slower link moves this (and every other
34
+ * cadre dial budget) by declaring `NetworkConfig.linkRoundTripMs`. Naming it here still wins
35
+ * over the derived value — `link-budget.ts` has the counts and the measurement.
36
+ */
24
37
  dialTimeoutMs?: number;
25
- /** Per-push response deadline, ms. Default 10_000 (matches SpreadOnChurnMonitor). */
38
+ /**
39
+ * Per-push response deadline, ms. Default {@link peerJoinPushBudget}'s `responseTimeoutMs` —
40
+ * two link round trips at the declared link plus a transfer allowance for the chunk's own
41
+ * bytes, 10_000 ms as shipped. Derived differently from {@link dialTimeoutMs} because it
42
+ * bounds a data transfer over a connection that is already open, not a dial.
43
+ */
26
44
  responseTimeoutMs?: number;
45
+ /**
46
+ * First wait before re-running a catch-up whose last run did not complete cleanly, ms.
47
+ * Default 5000. Doubles per consecutive failure up to {@link maxRetryBackoffMs}.
48
+ */
49
+ retryBackoffMs?: number;
50
+ /** Ceiling on that doubling wait, ms. Default 60_000. */
51
+ maxRetryBackoffMs?: number;
27
52
  }
28
53
  /** The resolved defaults every {@link PeerJoinBackfill} starts from. */
29
54
  export declare const DEFAULT_PEER_JOIN_BACKFILL: Required<PeerJoinBackfillConfig>;
@@ -105,8 +130,18 @@ export declare class PeerJoinBackfill {
105
130
  * reconnect, which is exactly what the re-arm exists to avoid.
106
131
  */
107
132
  private readonly rearmAfterFlight;
108
- /** Pending per-peer debounce timers, cleared on stop. */
133
+ /** Pending per-peer timers — the debounce, or a backoff re-arm. Cleared on stop. */
109
134
  private readonly timers;
135
+ /** Consecutive non-clean runs per peer, cleared when one finishes cleanly. */
136
+ private readonly failures;
137
+ /**
138
+ * Epoch ms before which a peer's catch-up must not be re-run, set alongside a backoff timer
139
+ * that will run it. Its presence is what makes `connection:open` churn free: a schedule
140
+ * arriving inside the wait is dropped, rather than collapsing the backoff to the debounce.
141
+ */
142
+ private readonly retryAfter;
143
+ /** Peers already reported on `console.warn`; reset when a run finally lands cleanly. */
144
+ private readonly warned;
110
145
  private readonly onConnectionOpen;
111
146
  private loggedNoListBlockIds;
112
147
  constructor(deps: PeerJoinBackfillDeps, config?: PeerJoinBackfillConfig);
@@ -133,6 +168,25 @@ export declare class PeerJoinBackfill {
133
168
  * caught up, or this backfill is stopped.
134
169
  */
135
170
  catchUpPeer(peerId: PeerId): Promise<PeerJoinBackfillResult>;
136
- /** The actual copy. `clean` = every chunk pushed and the remote persisted every block. */
171
+ /** Whether this network's libp2p node still holds a connection to that peer. */
172
+ private isConnected;
173
+ /**
174
+ * Re-arm one peer's catch-up after a run whose push failed, on a wait that doubles
175
+ * per consecutive failure up to `maxRetryBackoffMs`. Sets {@link retryAfter} alongside the
176
+ * timer, which is what makes `connection:open` churn inside the wait free.
177
+ */
178
+ private scheduleRetryWithBackoff;
179
+ /**
180
+ * Say ONCE per peer, outside the DEBUG log, that its catch-up is not landing. Without this a
181
+ * machine on a link too slow for a relayed dial produces no statement that anything is wrong:
182
+ * the peer never appears to hold the blocks, and the only trace is a DEBUG line naming a dial
183
+ * timeout. Reset when a run finally lands cleanly, so a peer that recovers can report again.
184
+ */
185
+ private warnPersistentFailure;
186
+ /**
187
+ * The actual copy. `clean` = every chunk pushed and the remote persisted every block.
188
+ * `pushFailed` = at least one push THREW, which is the only non-clean outcome a retry can
189
+ * change; the others are verdicts (denied, inert store, blocks the receiver refused).
190
+ */
137
191
  private runCatchUp;
138
192
  }
@@ -1,5 +1,6 @@
1
1
  import debug from 'debug';
2
2
  import { BlockTransferClient } from '@optimystic/db-p2p';
3
+ import { peerJoinPushBudget } from './link-budget.js';
3
4
  // Peer-join whole-store block catch-up, shared by the STRAND networks and the CONTROL
4
5
  // network. On `connection:open` (debounced) it pushes every committed, materialized block
5
6
  // in the local raw store to the new peer, so a machine that joined after blocks were
@@ -40,19 +41,74 @@ import { BlockTransferClient } from '@optimystic/db-p2p';
40
41
  // `scheduleConnectedPeers()` on a membership change (the production join order is
41
42
  // connect-then-authorize, so the denial at dial time is the expected first pass).
42
43
  //
43
- // NOTE: a failing dial to a non-speaking peer costs one dial timeout per connection:open
44
- // from such a peer, and is never memoized (only clean runs are). Bounded today by the
45
- // debounce plus the unreachable-peer bail in `runCatchUp` — one dial per event, not one
46
- // per chunk. If a node ever holds many such connections, or the enumeration ahead of the
47
- // first chunk gets expensive, pre-check `libp2p.peerStore` for this network's
48
- // block-transfer protocol before enumerating.
44
+ // Both per-push deadlines are DERIVED from the declared link round trip
45
+ // (`link-budget.ts`), not fixed milliseconds. That is not tuning — it is what makes this
46
+ // module work at all over a relay. Opening a relayed connection costs a fixed number of
47
+ // exchanges, so the 3000 ms this catch-up used to allow its dial could never finish one
48
+ // above 375 ms of one-way link delay: the catch-up existed so that a machine which joined
49
+ // after blocks were committed physically ends up holding them, and through a relay on any
50
+ // link slow enough to matter it had never once managed to. The reproduction is
51
+ // `packages/integration-tests/src/scenarios/relayed-dial-cost-by-latency.integration.ts`.
49
52
  //
50
- // NOTE: a run that fails is retried only when that peer next opens a connection (or, with
51
- // an `authorizePeer` gate wired, when `scheduleConnectedPeers()` is driven). Over a stable
52
- // connection a transient push failure therefore leaves the peer partially copied until the
53
- // next reconnect (read repair still covers reads meanwhile). If these meshes ever hold
54
- // long-lived connections where that matters, re-arm the debounce timer with a backoff on a
55
- // non-clean run instead of waiting for connection:open.
53
+ // It does NOT work at every speed. Above roughly 1250 ms one-way, two libp2p budgets that
54
+ // sereus cannot reach abandon the connection before any deadline here is consulted, and the
55
+ // listener's one makes that failure look like an absent peer rather than a timeout — see
56
+ // `link-budget.ts` ("The ceiling this does NOT lift") and
57
+ // `tickets/blocked/how-slow-a-relayed-link-does-sereus-carry`.
58
+ //
59
+ // RETRY, and why it backs off. A run whose PUSH FAILED — the transport threw, which is what
60
+ // a dial or response deadline expiring looks like here — re-arms on a doubling backoff
61
+ // (`retryBackoffMs` to `maxRetryBackoffMs`), and a `connection:open` arriving while that wait
62
+ // is outstanding is DROPPED rather than collapsing it back to the debounce. Both halves are
63
+ // load-bearing:
64
+ //
65
+ // - Without the re-arm, a transient push failure over a stable connection left the peer
66
+ // partially copied until its next reconnect (read repair still covered reads meanwhile).
67
+ // - Without dropping churn inside the wait, a peer that cannot be reached at all is
68
+ // re-dialled on every `connection:open` forever. That is not hypothetical: the 2026-09-26
69
+ // relayed reproduction shows one peer re-opening a connection about every 14.5 s for a
70
+ // 200-second run, each event starting a catch-up whose dial could not possibly finish.
71
+ // The connection kept re-appearing because Optimystic's own block-transfer push path
72
+ // budgets its dial at `transferTimeoutMs ?? 30000` — the one dial budget in the stack
73
+ // above the measured relayed setup cost — so it succeeded where this one could not.
74
+ //
75
+ // A NON-CLEAN run is NOT on its own enough to re-arm, and the distinction is what keeps the
76
+ // backoff from becoming a worse problem than the one it fixes. `clean` also goes false for
77
+ // outcomes no amount of retrying can change: the membership gate DENIED the peer; this
78
+ // network's raw storage implements no `listBlockIds`, so the catch-up is inert; or the
79
+ // receiver reported blocks in `missing`, which it does per block for a payload it cannot
80
+ // parse and for a revision whose retained commit proof this node does not hold (a push
81
+ // carrying no proof is refused outright by a receiver running the default
82
+ // `requirePushCertificate: true`, and an unretained proof is the ordinary case — see
83
+ // {@link Chunk.proofs}). Re-arming on those would re-push the WHOLE store to that peer every
84
+ // `maxRetryBackoffMs` for as long as the node runs, and report the failure below as a link
85
+ // budget problem when nothing about the link is wrong. All three still leave the peer
86
+ // un-memoized, so its next `connection:open` retries — the behaviour that predates the
87
+ // backoff, and the right one for a verdict rather than a timeout. Denial in particular is
88
+ // re-driven on purpose by `scheduleConnectedPeers()` the moment the membership commit lands,
89
+ // because the control network's join order is connect-then-authorize.
90
+ //
91
+ // A re-arm is also skipped when the peer is no longer CONNECTED. This module's trigger is
92
+ // `connection:open`, so a peer that went away already has one: re-arming instead would leave
93
+ // a machine dialing a peer it cannot see once a minute for the rest of its uptime.
94
+ //
95
+ // After `PEER_JOIN_BACKFILL_WARN_AFTER_FAILURES` consecutive failures one `console.warn`
96
+ // names the peer and the budget, because otherwise a machine on a too-slow link says
97
+ // nothing at all: the connection simply never appears and only a DEBUG log mentions a dial
98
+ // timeout.
99
+ //
100
+ // NOTE: a failing dial to a non-speaking peer costs one dial timeout per attempt, and is
101
+ // never memoized (only clean runs are). Bounded by the backoff above plus the
102
+ // unreachable-peer bail in `runCatchUp` — one dial per attempt, not one per chunk. If a node
103
+ // ever holds many such connections, or the enumeration ahead of the first chunk gets
104
+ // expensive, pre-check `libp2p.peerStore` for this network's block-transfer protocol before
105
+ // enumerating.
106
+ //
107
+ // NOTE: a peer that disconnects INSIDE a backoff wait still costs the one attempt that wait
108
+ // was already armed for — the connectivity check is made when the re-arm is decided, not when
109
+ // the timer fires, and this module subscribes to `connection:open` only. One dial, not a
110
+ // recurring one; if a node ever holds many transient peers, subscribe to `connection:close`
111
+ // and clear the pending timer there.
56
112
  const log = debug('sereus:cadre:peer-join-backfill');
57
113
  /**
58
114
  * The block-transfer protocol's hard cap on one length-prefixed message. Mirrors
@@ -61,6 +117,13 @@ const log = debug('sereus:cadre:peer-join-backfill');
61
117
  * changes it or starts exporting it.
62
118
  */
63
119
  export const MAX_BLOCK_MESSAGE_BYTES = 8 * 1024 * 1024;
120
+ /**
121
+ * Consecutive failed catch-up runs against ONE peer before the module says so on
122
+ * `console.warn` rather than only in its DEBUG log. At the default backoff that is reached
123
+ * about 35 seconds in (5 s + 10 s + 20 s), which is late enough to have ruled out a blip and
124
+ * early enough to be the first thing an operator sees about a machine that is not catching up.
125
+ */
126
+ export const PEER_JOIN_BACKFILL_WARN_AFTER_FAILURES = 3;
64
127
  /** The resolved defaults every {@link PeerJoinBackfill} starts from. */
65
128
  export const DEFAULT_PEER_JOIN_BACKFILL = {
66
129
  enabled: true,
@@ -68,8 +131,13 @@ export const DEFAULT_PEER_JOIN_BACKFILL = {
68
131
  maxBlocks: 10000,
69
132
  maxChunkBytes: 1024 * 1024,
70
133
  maxChunkBlocks: 64,
71
- dialTimeoutMs: 3000,
72
- responseTimeoutMs: 10000
134
+ // Derived at the DEFAULT declared link, for a `PeerJoinBackfill` built without a host's
135
+ // declaration (this module's own tests, an embedder driving it directly). The two production
136
+ // construction sites pass `peerJoinPushBudget(network?.linkRoundTripMs)` so a host that
137
+ // declares a slower link moves both — see `link-budget.ts`.
138
+ ...peerJoinPushBudget(),
139
+ retryBackoffMs: 5000,
140
+ maxRetryBackoffMs: 60000
73
141
  };
74
142
  function emptyResult() {
75
143
  return { offered: 0, accepted: 0, rejected: [], uncommitted: 0, unmaterialized: 0, capped: 0, oversized: [], denied: false };
@@ -110,8 +178,18 @@ export class PeerJoinBackfill {
110
178
  * reconnect, which is exactly what the re-arm exists to avoid.
111
179
  */
112
180
  this.rearmAfterFlight = new Set();
113
- /** Pending per-peer debounce timers, cleared on stop. */
181
+ /** Pending per-peer timers — the debounce, or a backoff re-arm. Cleared on stop. */
114
182
  this.timers = new Map();
183
+ /** Consecutive non-clean runs per peer, cleared when one finishes cleanly. */
184
+ this.failures = new Map();
185
+ /**
186
+ * Epoch ms before which a peer's catch-up must not be re-run, set alongside a backoff timer
187
+ * that will run it. Its presence is what makes `connection:open` churn free: a schedule
188
+ * arriving inside the wait is dropped, rather than collapsing the backoff to the debounce.
189
+ */
190
+ this.retryAfter = new Map();
191
+ /** Peers already reported on `console.warn`; reset when a run finally lands cleanly. */
192
+ this.warned = new Set();
115
193
  this.loggedNoListBlockIds = false;
116
194
  this.config = { ...DEFAULT_PEER_JOIN_BACKFILL, ...config };
117
195
  this.createPushClient = deps.createPushClient
@@ -142,6 +220,7 @@ export class PeerJoinBackfill {
142
220
  }
143
221
  this.timers.clear();
144
222
  this.rearmAfterFlight.clear();
223
+ this.retryAfter.clear();
145
224
  log('[%s] stopped', this.deps.label);
146
225
  }
147
226
  /**
@@ -178,6 +257,13 @@ export class PeerJoinBackfill {
178
257
  this.rearmAfterFlight.add(key);
179
258
  return;
180
259
  }
260
+ // A peer whose last run failed is already re-armed on a backoff timer that will run it, so
261
+ // DROP this schedule instead of shortening the wait — otherwise a peer that cannot be
262
+ // reached is re-dialled on every connection:open forever (see the module comment's retry
263
+ // paragraph). A denied run never gets here: it does not set a backoff.
264
+ const retryAt = this.retryAfter.get(key);
265
+ if (retryAt !== undefined && Date.now() < retryAt)
266
+ return;
181
267
  const existing = this.timers.get(key);
182
268
  if (existing)
183
269
  clearTimeout(existing);
@@ -198,7 +284,7 @@ export class PeerJoinBackfill {
198
284
  }
199
285
  this.inFlight.add(key);
200
286
  try {
201
- const { result, clean } = await this.runCatchUp(peerId);
287
+ const { result, clean, pushFailed } = await this.runCatchUp(peerId);
202
288
  // NOTE: a run that hit `maxBlocks` is still "clean" and still memoizes the peer, so
203
289
  // the tail past the ceiling never reaches it. Deliberate: enumeration is not
204
290
  // resumable, so not memoizing would re-push the same prefix on every reconnect
@@ -206,6 +292,19 @@ export class PeerJoinBackfill {
206
292
  // realistically exceed maxBlocks, the fix is a resumable cursor, not either policy.
207
293
  if (clean && !this.stopped) {
208
294
  this.done.add(key);
295
+ this.failures.delete(key);
296
+ this.retryAfter.delete(key);
297
+ this.warned.delete(key);
298
+ }
299
+ else if (pushFailed && !this.stopped && this.started && this.isConnected(peerId)) {
300
+ // `pushFailed`, not `!clean`: a denial, an inert store and a receiver's per-block
301
+ // rejection are all verdicts a retry cannot change, and re-arming on them would
302
+ // re-push the whole store to that peer forever. See the module comment.
303
+ //
304
+ // Gated on `started` too: the re-arm exists to REPLACE a connection:open-driven retry,
305
+ // so a caller driving `catchUpPeer` by hand against a backfill that was never started
306
+ // owns its own retry policy and must not be left holding a background timer.
307
+ this.scheduleRetryWithBackoff(peerId);
209
308
  }
210
309
  log('[%s] catch-up peer=%s offered=%d accepted=%d rejected=%d uncommitted=%d unmaterialized=%d capped=%d oversized=%d denied=%s done=%s', this.deps.label, key, result.offered, result.accepted, result.rejected.length, result.uncommitted, result.unmaterialized, result.capped, result.oversized.length, result.denied, clean);
211
310
  return result;
@@ -225,7 +324,53 @@ export class PeerJoinBackfill {
225
324
  }
226
325
  }
227
326
  }
228
- /** The actual copy. `clean` = every chunk pushed and the remote persisted every block. */
327
+ /** Whether this network's libp2p node still holds a connection to that peer. */
328
+ isConnected(peerId) {
329
+ return this.deps.libp2p.getConnections(peerId).length > 0;
330
+ }
331
+ /**
332
+ * Re-arm one peer's catch-up after a run whose push failed, on a wait that doubles
333
+ * per consecutive failure up to `maxRetryBackoffMs`. Sets {@link retryAfter} alongside the
334
+ * timer, which is what makes `connection:open` churn inside the wait free.
335
+ */
336
+ scheduleRetryWithBackoff(peerId) {
337
+ const key = peerId.toString();
338
+ const failures = (this.failures.get(key) ?? 0) + 1;
339
+ this.failures.set(key, failures);
340
+ const delayMs = Math.min(this.config.retryBackoffMs * 2 ** (failures - 1), this.config.maxRetryBackoffMs);
341
+ this.retryAfter.set(key, Date.now() + delayMs);
342
+ const existing = this.timers.get(key);
343
+ if (existing)
344
+ clearTimeout(existing);
345
+ this.timers.set(key, setTimeout(() => {
346
+ this.timers.delete(key);
347
+ this.retryAfter.delete(key);
348
+ void this.catchUpPeer(peerId);
349
+ }, delayMs));
350
+ log('[%s] catch-up peer=%s failed %d time(s) in a row; retrying in %dms', this.deps.label, key, failures, delayMs);
351
+ this.warnPersistentFailure(key, failures);
352
+ }
353
+ /**
354
+ * Say ONCE per peer, outside the DEBUG log, that its catch-up is not landing. Without this a
355
+ * machine on a link too slow for a relayed dial produces no statement that anything is wrong:
356
+ * the peer never appears to hold the blocks, and the only trace is a DEBUG line naming a dial
357
+ * timeout. Reset when a run finally lands cleanly, so a peer that recovers can report again.
358
+ */
359
+ warnPersistentFailure(key, failures) {
360
+ if (failures < PEER_JOIN_BACKFILL_WARN_AFTER_FAILURES || this.warned.has(key))
361
+ return;
362
+ this.warned.add(key);
363
+ console.warn(`[cadre:${this.deps.label}] peer-join block catch-up to peer ${key} has failed ${failures} times in a row `
364
+ + `(dial budget ${this.config.dialTimeoutMs}ms, response budget ${this.config.responseTimeoutMs}ms). `
365
+ + 'That peer may not be holding blocks committed before it joined. If it is reachable only through a relay, '
366
+ + 'these budgets are derived from network.linkRoundTripMs (see link-budget.ts); above about a 2.5-second '
367
+ + 'round trip no relayed connection can be established at all, whatever they are set to.');
368
+ }
369
+ /**
370
+ * The actual copy. `clean` = every chunk pushed and the remote persisted every block.
371
+ * `pushFailed` = at least one push THREW, which is the only non-clean outcome a retry can
372
+ * change; the others are verdicts (denied, inert store, blocks the receiver refused).
373
+ */
229
374
  async runCatchUp(peerId) {
230
375
  const result = emptyResult();
231
376
  const { storage } = this.deps;
@@ -243,7 +388,7 @@ export class PeerJoinBackfill {
243
388
  }
244
389
  if (!authorized) {
245
390
  result.denied = true;
246
- return { result, clean: false };
391
+ return { result, clean: false, pushFailed: false };
247
392
  }
248
393
  }
249
394
  if (!storage.listBlockIds) {
@@ -251,7 +396,7 @@ export class PeerJoinBackfill {
251
396
  this.loggedNoListBlockIds = true;
252
397
  log('[%s] raw storage does not implement listBlockIds(); backfill is inert', this.deps.label);
253
398
  }
254
- return { result, clean: false };
399
+ return { result, clean: false, pushFailed: false };
255
400
  }
256
401
  const client = this.createPushClient(peerId);
257
402
  const encoder = new TextEncoder();
@@ -363,7 +508,7 @@ export class PeerJoinBackfill {
363
508
  log('[%s] peer=%s catch-up CAPPED at %d blocks; %d block id(s) not attempted', this.deps.label, peerId.toString(), this.config.maxBlocks, result.capped);
364
509
  }
365
510
  const clean = !chunkFailed && result.rejected.length === 0;
366
- return { result, clean };
511
+ return { result, clean, pushFailed: chunkFailed };
367
512
  }
368
513
  }
369
514
  //# sourceMappingURL=peer-join-backfill.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"peer-join-backfill.js","sourceRoot":"","sources":["../src/peer-join-backfill.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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AC;IAC3B,CAAC;CACF"}
1
+ {"version":3,"file":"peer-join-backfill.js","sourceRoot":"","sources":["../src/peer-join-backfill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,mBAAmB,EAA2C,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,sFAAsF;AACtF,0FAA0F;AAC1F,qFAAqF;AACrF,0FAA0F;AAC1F,0FAA0F;AAC1F,yFAAyF;AACzF,yFAAyF;AACzF,EAAE;AACF,wFAAwF;AACxF,iFAAiF;AACjF,0FAA0F;AAC1F,uFAAuF;AACvF,0FAA0F;AAC1F,sBAAsB;AACtB,EAAE;AACF,2FAA2F;AAC3F,wFAAwF;AACxF,oBAAoB;AACpB,EAAE;AACF,gFAAgF;AAChF,uBAAuB;AACvB,EAAE;AACF,2FAA2F;AAC3F,2FAA2F;AAC3F,0FAA0F;AAC1F,2FAA2F;AAC3F,2FAA2F;AAC3F,4EAA4E;AAC5E,sFAAsF;AACtF,kFAAkF;AAClF,gFAAgF;AAChF,iFAAiF;AACjF,wFAAwF;AACxF,yFAAyF;AACzF,wFAAwF;AACxF,wFAAwF;AACxF,uEAAuE;AACvE,oFAAoF;AACpF,oFAAoF;AACpF,EAAE;AACF,wEAAwE;AACxE,yFAAyF;AACzF,wFAAwF;AACxF,wFAAwF;AACxF,0FAA0F;AAC1F,0FAA0F;AAC1F,+EAA+E;AAC/E,0FAA0F;AAC1F,EAAE;AACF,0FAA0F;AAC1F,4FAA4F;AAC5F,yFAAyF;AACzF,0DAA0D;AAC1D,+DAA+D;AAC/D,EAAE;AACF,4FAA4F;AAC5F,uFAAuF;AACvF,8FAA8F;AAC9F,4FAA4F;AAC5F,gBAAgB;AAChB,EAAE;AACF,wFAAwF;AACxF,2FAA2F;AAC3F,oFAAoF;AACpF,4FAA4F;AAC5F,yFAAyF;AACzF,yFAAyF;AACzF,uFAAuF;A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QAAQ,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9E,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC;QAC3D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IACpD,CAAC;CACF"}
@@ -81,7 +81,11 @@
81
81
  * And because discovery is out of reach, nothing would ever ASK again either —
82
82
  * so {@link driveRelayReservation} stays a single-shot primitive and
83
83
  * {@link superviseRelayReservation} owns the retry cadence on top of it. That
84
- * loop is what makes a lost reservation recover without a page reload.
84
+ * loop is what makes a lost reservation recover without a page reload. Single-shot
85
+ * but not unstoppable: the primitive takes an `AbortSignal` and the loop trips it
86
+ * from `stop()`, because a drive left running against a node being torn down both
87
+ * logs failures that read as real and — through the timers it still holds — keeps
88
+ * the process alive for the rest of its `timeoutMs`.
85
89
  *
86
90
  * One measured refinement to "out of reach": libp2p 3.1.3's `connection.newStream`
87
91
  * records every protocol OUR OWN outbound stream negotiated into the peer store, so
@@ -125,12 +129,45 @@ export interface RelayReservationState {
125
129
  */
126
130
  retryAtMs: number | null;
127
131
  }
128
- /** How long {@link driveRelayReservation} waits for a reservation to appear. */
129
- export declare const DEFAULT_RELAY_RESERVE_TIMEOUT_MS = 10000;
132
+ /**
133
+ * How long {@link driveRelayReservation} waits for a reservation to appear, at the DEFAULT
134
+ * declared link round trip: `RELAY_RESERVATION_ROUND_TRIPS` (4) x `DECLARED_LINK_ROUND_TRIP_MS`
135
+ * (2000 ms) = 8000 ms, where it was a fixed 10_000 before.
136
+ *
137
+ * Counted rather than chosen because this one deadline bounds the whole drive — dial the relay,
138
+ * request the reservation, wait — and each of those costs a fixed number of exchanges, not a
139
+ * fixed number of milliseconds. `link-budget.ts` carries the counts, the measurement behind
140
+ * them, and the ceiling above which no relayed connection can be established whatever this says.
141
+ *
142
+ * A host on a slower link moves it by declaring `NetworkConfig.linkRoundTripMs`, which both
143
+ * call sites thread in (`CadreNode.reserveRelays` for the control node,
144
+ * `StrandInstanceManager`'s per-relay supervisors for a strand). This constant is the fallback
145
+ * for a caller that declares nothing.
146
+ */
147
+ export declare const DEFAULT_RELAY_RESERVE_TIMEOUT_MS: number;
130
148
  export declare const DEFAULT_RELAY_RESERVE_POLL_MS = 250;
131
149
  export interface RelayReserveOptions {
132
150
  timeoutMs?: number;
133
151
  pollMs?: number;
152
+ /**
153
+ * Ends an in-flight drive early. Aborting is not a failure: the drive returns
154
+ * `{ error: null, cancelled: true }` and clears every timer it holds, so the
155
+ * process is free to exit immediately instead of trailing the teardown that
156
+ * cancelled it.
157
+ */
158
+ signal?: AbortSignal;
159
+ }
160
+ /** What one {@link driveRelayReservation} came back with. */
161
+ export interface RelayReserveResult {
162
+ /** Why no reservation landed; `null` when one did — or when the drive was cancelled. */
163
+ error: string | null;
164
+ /**
165
+ * The drive ended because its caller's `signal` tripped, not because of anything
166
+ * the relay did. Separate from `error` because `error: null` means "a reservation
167
+ * landed" and a cancelled drive landed nothing: folded together, a caller would
168
+ * read cancellation as success. `cancelled: true` always implies `error: null`.
169
+ */
170
+ cancelled: boolean;
134
171
  }
135
172
  /**
136
173
  * The slice of `@libp2p/utils`' `Filter` (a cuckoo filter) that the reservation
@@ -205,18 +242,27 @@ export declare function findCircuitRelayTransport(node: Libp2p): CircuitRelayTra
205
242
  * (`error: null`).
206
243
  *
207
244
  * `timeoutMs` bounds the WHOLE drive — dials, reservation requests and the wait
208
- * share one deadline.
245
+ * share one deadline. `opts.signal` bounds it from the other side: every phase
246
+ * below returns as soon as it trips, and the drive reports `cancelled` rather than
247
+ * inventing a failure for a relay that was never given a chance to answer.
209
248
  */
210
- export declare function driveRelayReservation(node: Libp2p, addrs: readonly string[], opts?: RelayReserveOptions): Promise<{
211
- error: string | null;
212
- }>;
249
+ export declare function driveRelayReservation(node: Libp2p, addrs: readonly string[], opts?: RelayReserveOptions): Promise<RelayReserveResult>;
213
250
  /** Gap between liveness checks while a reservation is held. */
214
251
  export declare const DEFAULT_RELAY_CHECK_MS = 5000;
215
252
  /** Backoff before the first re-drive after a failed attempt. */
216
253
  export declare const DEFAULT_RELAY_MIN_BACKOFF_MS = 2000;
217
254
  /** Ceiling the backoff doubles up to. */
218
255
  export declare const DEFAULT_RELAY_MAX_BACKOFF_MS = 60000;
219
- export interface RelayReservationSupervisorOptions extends RelayReserveOptions {
256
+ /**
257
+ * Everything one drive takes, minus its `signal`, plus the loop's own cadence.
258
+ *
259
+ * `signal` is omitted rather than inherited because these options are handed
260
+ * straight to every drive: a caller-supplied one would cancel each attempt without
261
+ * the loop knowing, leaving it to reschedule drives that return immediately and
262
+ * forever. The way to cancel a supervisor is
263
+ * {@link RelayReservationSupervisor.stop}, which owns the signal it passes down.
264
+ */
265
+ export interface RelayReservationSupervisorOptions extends Omit<RelayReserveOptions, 'signal'> {
220
266
  /** Gap between liveness checks while a reservation is held. Default 5_000. */
221
267
  checkMs?: number;
222
268
  /** Backoff before the first re-drive after a failure. Default 2_000. */
@@ -256,9 +302,11 @@ export interface RelayReservationSupervisor {
256
302
  /** Reason the last drive produced no reservation; `null` once one is held. */
257
303
  readonly lastError: string | null;
258
304
  /**
259
- * Idempotent. Clears the timer so no further drive is scheduled. A drive that
260
- * is ALREADY in flight is not aborted — {@link driveRelayReservation} takes no
261
- * signal — but its result is discarded and nothing follows it.
305
+ * Idempotent. Clears the timer so no further drive is scheduled, and CANCELS the
306
+ * drive already in flight: it stops dialing or polling, clears every timer it
307
+ * holds and reports `cancelled`, so a teardown does not trail an attempt against
308
+ * the node it is dismantling. That result is discarded — a cancelled drive is
309
+ * not a failure — and nothing follows it.
262
310
  */
263
311
  stop(): void;
264
312
  }