@serfab/cadre-core 1.3.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.
- package/README.md +5 -3
- package/dist/cadre-node.d.ts +70 -34
- package/dist/cadre-node.js +197 -60
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-database.d.ts +24 -10
- package/dist/control-database.js +48 -16
- package/dist/control-database.js.map +1 -1
- package/dist/control-formation-recorder.d.ts +4 -4
- package/dist/control-formation-recorder.js +6 -6
- package/dist/control-formation-recorder.js.map +1 -1
- package/dist/control-read-retry.d.ts +12 -0
- package/dist/control-read-retry.js +12 -0
- package/dist/control-read-retry.js.map +1 -1
- package/dist/control-write-retry.d.ts +5 -4
- package/dist/control-write-retry.js +24 -7
- package/dist/control-write-retry.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/link-budget.d.ts +182 -0
- package/dist/link-budget.js +195 -0
- package/dist/link-budget.js.map +1 -0
- package/dist/membership-connection-gater.d.ts +18 -5
- package/dist/membership-connection-gater.js +50 -10
- package/dist/membership-connection-gater.js.map +1 -1
- package/dist/peer-dial.d.ts +36 -17
- package/dist/peer-dial.js +37 -17
- package/dist/peer-dial.js.map +1 -1
- package/dist/peer-join-backfill.d.ts +58 -4
- package/dist/peer-join-backfill.js +165 -20
- package/dist/peer-join-backfill.js.map +1 -1
- package/dist/relay-reservation.d.ts +59 -11
- package/dist/relay-reservation.js +169 -43
- package/dist/relay-reservation.js.map +1 -1
- package/dist/seed-bootstrap.js +2 -1
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/storage-scope.d.ts +50 -12
- package/dist/storage-scope.js +85 -12
- package/dist/storage-scope.js.map +1 -1
- package/dist/strand-first-sync-gate.d.ts +43 -5
- package/dist/strand-first-sync-gate.js +55 -7
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-formation-manager.js +2 -1
- package/dist/strand-formation-manager.js.map +1 -1
- package/dist/strand-id.d.ts +35 -0
- package/dist/strand-id.js +46 -0
- package/dist/strand-id.js.map +1 -0
- package/dist/strand-instance-manager.d.ts +27 -2
- package/dist/strand-instance-manager.js +75 -15
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-reconciler.d.ts +200 -45
- package/dist/strand-membership-reconciler.js +302 -86
- package/dist/strand-membership-reconciler.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +3 -2
- package/dist/strand-membership-writer.js +67 -90
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-network-config.d.ts +3 -3
- package/dist/strand-network-config.js +3 -3
- package/dist/strand-solicitation.js +2 -1
- package/dist/strand-solicitation.js.map +1 -1
- package/dist/strand-watcher.d.ts +45 -0
- package/dist/strand-watcher.js +74 -13
- package/dist/strand-watcher.js.map +1 -1
- package/dist/types.d.ts +190 -24
- package/dist/types.js +73 -4
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/src/cadre-node.ts +7445 -7302
- package/src/control-database.ts +48 -16
- package/src/control-formation-recorder.ts +6 -6
- package/src/control-read-retry.ts +214 -202
- package/src/control-write-retry.ts +24 -7
- package/src/index.ts +29 -2
- package/src/link-budget.ts +217 -0
- package/src/membership-connection-gater.ts +56 -11
- package/src/peer-dial.ts +39 -17
- package/src/peer-join-backfill.ts +192 -23
- package/src/relay-reservation.ts +1119 -951
- package/src/seed-bootstrap.ts +2 -1
- package/src/storage-scope.ts +163 -78
- package/src/strand-first-sync-gate.ts +55 -7
- package/src/strand-formation-manager.ts +647 -646
- package/src/strand-id.ts +48 -0
- package/src/strand-instance-manager.ts +1516 -1440
- package/src/strand-membership-reconciler.ts +334 -92
- package/src/strand-membership-writer.ts +1962 -1987
- package/src/strand-network-config.ts +250 -250
- package/src/strand-solicitation.ts +500 -499
- package/src/strand-watcher.ts +388 -325
- package/src/types.ts +192 -23
|
@@ -2,6 +2,7 @@ import debug from 'debug';
|
|
|
2
2
|
import type { Connection, Libp2p, PeerId } from '@libp2p/interface';
|
|
3
3
|
import type { ActionId, IPeerNetwork } from '@optimystic/db-core';
|
|
4
4
|
import { BlockTransferClient, type BlockCommitProof, type IRawStorage } from '@optimystic/db-p2p';
|
|
5
|
+
import { peerJoinPushBudget } from './link-budget.js';
|
|
5
6
|
|
|
6
7
|
// Peer-join whole-store block catch-up, shared by the STRAND networks and the CONTROL
|
|
7
8
|
// network. On `connection:open` (debounced) it pushes every committed, materialized block
|
|
@@ -43,19 +44,74 @@ import { BlockTransferClient, type BlockCommitProof, type IRawStorage } from '@o
|
|
|
43
44
|
// `scheduleConnectedPeers()` on a membership change (the production join order is
|
|
44
45
|
// connect-then-authorize, so the denial at dial time is the expected first pass).
|
|
45
46
|
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
47
|
+
// Both per-push deadlines are DERIVED from the declared link round trip
|
|
48
|
+
// (`link-budget.ts`), not fixed milliseconds. That is not tuning — it is what makes this
|
|
49
|
+
// module work at all over a relay. Opening a relayed connection costs a fixed number of
|
|
50
|
+
// exchanges, so the 3000 ms this catch-up used to allow its dial could never finish one
|
|
51
|
+
// above 375 ms of one-way link delay: the catch-up existed so that a machine which joined
|
|
52
|
+
// after blocks were committed physically ends up holding them, and through a relay on any
|
|
53
|
+
// link slow enough to matter it had never once managed to. The reproduction is
|
|
54
|
+
// `packages/integration-tests/src/scenarios/relayed-dial-cost-by-latency.integration.ts`.
|
|
52
55
|
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
56
|
+
// It does NOT work at every speed. Above roughly 1250 ms one-way, two libp2p budgets that
|
|
57
|
+
// sereus cannot reach abandon the connection before any deadline here is consulted, and the
|
|
58
|
+
// listener's one makes that failure look like an absent peer rather than a timeout — see
|
|
59
|
+
// `link-budget.ts` ("The ceiling this does NOT lift") and
|
|
60
|
+
// `tickets/blocked/how-slow-a-relayed-link-does-sereus-carry`.
|
|
61
|
+
//
|
|
62
|
+
// RETRY, and why it backs off. A run whose PUSH FAILED — the transport threw, which is what
|
|
63
|
+
// a dial or response deadline expiring looks like here — re-arms on a doubling backoff
|
|
64
|
+
// (`retryBackoffMs` to `maxRetryBackoffMs`), and a `connection:open` arriving while that wait
|
|
65
|
+
// is outstanding is DROPPED rather than collapsing it back to the debounce. Both halves are
|
|
66
|
+
// load-bearing:
|
|
67
|
+
//
|
|
68
|
+
// - Without the re-arm, a transient push failure over a stable connection left the peer
|
|
69
|
+
// partially copied until its next reconnect (read repair still covered reads meanwhile).
|
|
70
|
+
// - Without dropping churn inside the wait, a peer that cannot be reached at all is
|
|
71
|
+
// re-dialled on every `connection:open` forever. That is not hypothetical: the 2026-09-26
|
|
72
|
+
// relayed reproduction shows one peer re-opening a connection about every 14.5 s for a
|
|
73
|
+
// 200-second run, each event starting a catch-up whose dial could not possibly finish.
|
|
74
|
+
// The connection kept re-appearing because Optimystic's own block-transfer push path
|
|
75
|
+
// budgets its dial at `transferTimeoutMs ?? 30000` — the one dial budget in the stack
|
|
76
|
+
// above the measured relayed setup cost — so it succeeded where this one could not.
|
|
77
|
+
//
|
|
78
|
+
// A NON-CLEAN run is NOT on its own enough to re-arm, and the distinction is what keeps the
|
|
79
|
+
// backoff from becoming a worse problem than the one it fixes. `clean` also goes false for
|
|
80
|
+
// outcomes no amount of retrying can change: the membership gate DENIED the peer; this
|
|
81
|
+
// network's raw storage implements no `listBlockIds`, so the catch-up is inert; or the
|
|
82
|
+
// receiver reported blocks in `missing`, which it does per block for a payload it cannot
|
|
83
|
+
// parse and for a revision whose retained commit proof this node does not hold (a push
|
|
84
|
+
// carrying no proof is refused outright by a receiver running the default
|
|
85
|
+
// `requirePushCertificate: true`, and an unretained proof is the ordinary case — see
|
|
86
|
+
// {@link Chunk.proofs}). Re-arming on those would re-push the WHOLE store to that peer every
|
|
87
|
+
// `maxRetryBackoffMs` for as long as the node runs, and report the failure below as a link
|
|
88
|
+
// budget problem when nothing about the link is wrong. All three still leave the peer
|
|
89
|
+
// un-memoized, so its next `connection:open` retries — the behaviour that predates the
|
|
90
|
+
// backoff, and the right one for a verdict rather than a timeout. Denial in particular is
|
|
91
|
+
// re-driven on purpose by `scheduleConnectedPeers()` the moment the membership commit lands,
|
|
92
|
+
// because the control network's join order is connect-then-authorize.
|
|
93
|
+
//
|
|
94
|
+
// A re-arm is also skipped when the peer is no longer CONNECTED. This module's trigger is
|
|
95
|
+
// `connection:open`, so a peer that went away already has one: re-arming instead would leave
|
|
96
|
+
// a machine dialing a peer it cannot see once a minute for the rest of its uptime.
|
|
97
|
+
//
|
|
98
|
+
// After `PEER_JOIN_BACKFILL_WARN_AFTER_FAILURES` consecutive failures one `console.warn`
|
|
99
|
+
// names the peer and the budget, because otherwise a machine on a too-slow link says
|
|
100
|
+
// nothing at all: the connection simply never appears and only a DEBUG log mentions a dial
|
|
101
|
+
// timeout.
|
|
102
|
+
//
|
|
103
|
+
// NOTE: a failing dial to a non-speaking peer costs one dial timeout per attempt, and is
|
|
104
|
+
// never memoized (only clean runs are). Bounded by the backoff above plus the
|
|
105
|
+
// unreachable-peer bail in `runCatchUp` — one dial per attempt, not one per chunk. If a node
|
|
106
|
+
// ever holds many such connections, or the enumeration ahead of the first chunk gets
|
|
107
|
+
// expensive, pre-check `libp2p.peerStore` for this network's block-transfer protocol before
|
|
108
|
+
// enumerating.
|
|
109
|
+
//
|
|
110
|
+
// NOTE: a peer that disconnects INSIDE a backoff wait still costs the one attempt that wait
|
|
111
|
+
// was already armed for — the connectivity check is made when the re-arm is decided, not when
|
|
112
|
+
// the timer fires, and this module subscribes to `connection:open` only. One dial, not a
|
|
113
|
+
// recurring one; if a node ever holds many transient peers, subscribe to `connection:close`
|
|
114
|
+
// and clear the pending timer there.
|
|
59
115
|
|
|
60
116
|
const log = debug('sereus:cadre:peer-join-backfill');
|
|
61
117
|
|
|
@@ -67,6 +123,14 @@ const log = debug('sereus:cadre:peer-join-backfill');
|
|
|
67
123
|
*/
|
|
68
124
|
export const MAX_BLOCK_MESSAGE_BYTES = 8 * 1024 * 1024;
|
|
69
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Consecutive failed catch-up runs against ONE peer before the module says so on
|
|
128
|
+
* `console.warn` rather than only in its DEBUG log. At the default backoff that is reached
|
|
129
|
+
* about 35 seconds in (5 s + 10 s + 20 s), which is late enough to have ruled out a blip and
|
|
130
|
+
* early enough to be the first thing an operator sees about a machine that is not catching up.
|
|
131
|
+
*/
|
|
132
|
+
export const PEER_JOIN_BACKFILL_WARN_AFTER_FAILURES = 3;
|
|
133
|
+
|
|
70
134
|
/** Tuning for the per-peer catch-up. Every field optional; defaults in {@link DEFAULT_PEER_JOIN_BACKFILL}. */
|
|
71
135
|
export interface PeerJoinBackfillConfig {
|
|
72
136
|
/** Default true. False disables the catch-up entirely (the pre-existing behaviour). */
|
|
@@ -79,10 +143,28 @@ export interface PeerJoinBackfillConfig {
|
|
|
79
143
|
maxChunkBytes?: number;
|
|
80
144
|
/** Max blocks per push message. Default 64. */
|
|
81
145
|
maxChunkBlocks?: number;
|
|
82
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* Per-push dial deadline, ms. Default {@link peerJoinPushBudget}'s `dialTimeoutMs` — four link
|
|
148
|
+
* round trips at the declared link, 8000 ms as shipped. NOT a fixed number: a relayed dial
|
|
149
|
+
* costs a fixed number of exchanges, so a host on a slower link moves this (and every other
|
|
150
|
+
* cadre dial budget) by declaring `NetworkConfig.linkRoundTripMs`. Naming it here still wins
|
|
151
|
+
* over the derived value — `link-budget.ts` has the counts and the measurement.
|
|
152
|
+
*/
|
|
83
153
|
dialTimeoutMs?: number;
|
|
84
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Per-push response deadline, ms. Default {@link peerJoinPushBudget}'s `responseTimeoutMs` —
|
|
156
|
+
* two link round trips at the declared link plus a transfer allowance for the chunk's own
|
|
157
|
+
* bytes, 10_000 ms as shipped. Derived differently from {@link dialTimeoutMs} because it
|
|
158
|
+
* bounds a data transfer over a connection that is already open, not a dial.
|
|
159
|
+
*/
|
|
85
160
|
responseTimeoutMs?: number;
|
|
161
|
+
/**
|
|
162
|
+
* First wait before re-running a catch-up whose last run did not complete cleanly, ms.
|
|
163
|
+
* Default 5000. Doubles per consecutive failure up to {@link maxRetryBackoffMs}.
|
|
164
|
+
*/
|
|
165
|
+
retryBackoffMs?: number;
|
|
166
|
+
/** Ceiling on that doubling wait, ms. Default 60_000. */
|
|
167
|
+
maxRetryBackoffMs?: number;
|
|
86
168
|
}
|
|
87
169
|
|
|
88
170
|
/** The resolved defaults every {@link PeerJoinBackfill} starts from. */
|
|
@@ -92,8 +174,13 @@ export const DEFAULT_PEER_JOIN_BACKFILL: Required<PeerJoinBackfillConfig> = {
|
|
|
92
174
|
maxBlocks: 10_000,
|
|
93
175
|
maxChunkBytes: 1024 * 1024,
|
|
94
176
|
maxChunkBlocks: 64,
|
|
95
|
-
|
|
96
|
-
|
|
177
|
+
// Derived at the DEFAULT declared link, for a `PeerJoinBackfill` built without a host's
|
|
178
|
+
// declaration (this module's own tests, an embedder driving it directly). The two production
|
|
179
|
+
// construction sites pass `peerJoinPushBudget(network?.linkRoundTripMs)` so a host that
|
|
180
|
+
// declares a slower link moves both — see `link-budget.ts`.
|
|
181
|
+
...peerJoinPushBudget(),
|
|
182
|
+
retryBackoffMs: 5000,
|
|
183
|
+
maxRetryBackoffMs: 60_000
|
|
97
184
|
};
|
|
98
185
|
|
|
99
186
|
/**
|
|
@@ -209,8 +296,18 @@ export class PeerJoinBackfill {
|
|
|
209
296
|
* reconnect, which is exactly what the re-arm exists to avoid.
|
|
210
297
|
*/
|
|
211
298
|
private readonly rearmAfterFlight = new Set<string>();
|
|
212
|
-
/** Pending per-peer debounce
|
|
299
|
+
/** Pending per-peer timers — the debounce, or a backoff re-arm. Cleared on stop. */
|
|
213
300
|
private readonly timers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
301
|
+
/** Consecutive non-clean runs per peer, cleared when one finishes cleanly. */
|
|
302
|
+
private readonly failures = new Map<string, number>();
|
|
303
|
+
/**
|
|
304
|
+
* Epoch ms before which a peer's catch-up must not be re-run, set alongside a backoff timer
|
|
305
|
+
* that will run it. Its presence is what makes `connection:open` churn free: a schedule
|
|
306
|
+
* arriving inside the wait is dropped, rather than collapsing the backoff to the debounce.
|
|
307
|
+
*/
|
|
308
|
+
private readonly retryAfter = new Map<string, number>();
|
|
309
|
+
/** Peers already reported on `console.warn`; reset when a run finally lands cleanly. */
|
|
310
|
+
private readonly warned = new Set<string>();
|
|
214
311
|
private readonly onConnectionOpen: (evt: CustomEvent<Connection>) => void;
|
|
215
312
|
private loggedNoListBlockIds = false;
|
|
216
313
|
|
|
@@ -244,6 +341,7 @@ export class PeerJoinBackfill {
|
|
|
244
341
|
}
|
|
245
342
|
this.timers.clear();
|
|
246
343
|
this.rearmAfterFlight.clear();
|
|
344
|
+
this.retryAfter.clear();
|
|
247
345
|
log('[%s] stopped', this.deps.label);
|
|
248
346
|
}
|
|
249
347
|
|
|
@@ -279,6 +377,12 @@ export class PeerJoinBackfill {
|
|
|
279
377
|
this.rearmAfterFlight.add(key);
|
|
280
378
|
return;
|
|
281
379
|
}
|
|
380
|
+
// A peer whose last run failed is already re-armed on a backoff timer that will run it, so
|
|
381
|
+
// DROP this schedule instead of shortening the wait — otherwise a peer that cannot be
|
|
382
|
+
// reached is re-dialled on every connection:open forever (see the module comment's retry
|
|
383
|
+
// paragraph). A denied run never gets here: it does not set a backoff.
|
|
384
|
+
const retryAt = this.retryAfter.get(key);
|
|
385
|
+
if (retryAt !== undefined && Date.now() < retryAt) return;
|
|
282
386
|
const existing = this.timers.get(key);
|
|
283
387
|
if (existing) clearTimeout(existing);
|
|
284
388
|
this.timers.set(key, setTimeout(() => {
|
|
@@ -299,7 +403,7 @@ export class PeerJoinBackfill {
|
|
|
299
403
|
}
|
|
300
404
|
this.inFlight.add(key);
|
|
301
405
|
try {
|
|
302
|
-
const { result, clean } = await this.runCatchUp(peerId);
|
|
406
|
+
const { result, clean, pushFailed } = await this.runCatchUp(peerId);
|
|
303
407
|
// NOTE: a run that hit `maxBlocks` is still "clean" and still memoizes the peer, so
|
|
304
408
|
// the tail past the ceiling never reaches it. Deliberate: enumeration is not
|
|
305
409
|
// resumable, so not memoizing would re-push the same prefix on every reconnect
|
|
@@ -307,6 +411,18 @@ export class PeerJoinBackfill {
|
|
|
307
411
|
// realistically exceed maxBlocks, the fix is a resumable cursor, not either policy.
|
|
308
412
|
if (clean && !this.stopped) {
|
|
309
413
|
this.done.add(key);
|
|
414
|
+
this.failures.delete(key);
|
|
415
|
+
this.retryAfter.delete(key);
|
|
416
|
+
this.warned.delete(key);
|
|
417
|
+
} else if (pushFailed && !this.stopped && this.started && this.isConnected(peerId)) {
|
|
418
|
+
// `pushFailed`, not `!clean`: a denial, an inert store and a receiver's per-block
|
|
419
|
+
// rejection are all verdicts a retry cannot change, and re-arming on them would
|
|
420
|
+
// re-push the whole store to that peer forever. See the module comment.
|
|
421
|
+
//
|
|
422
|
+
// Gated on `started` too: the re-arm exists to REPLACE a connection:open-driven retry,
|
|
423
|
+
// so a caller driving `catchUpPeer` by hand against a backfill that was never started
|
|
424
|
+
// owns its own retry policy and must not be left holding a background timer.
|
|
425
|
+
this.scheduleRetryWithBackoff(peerId);
|
|
310
426
|
}
|
|
311
427
|
log('[%s] catch-up peer=%s offered=%d accepted=%d rejected=%d uncommitted=%d unmaterialized=%d capped=%d oversized=%d denied=%s done=%s',
|
|
312
428
|
this.deps.label, key, result.offered, result.accepted, result.rejected.length,
|
|
@@ -327,8 +443,61 @@ export class PeerJoinBackfill {
|
|
|
327
443
|
}
|
|
328
444
|
}
|
|
329
445
|
|
|
330
|
-
/**
|
|
331
|
-
private
|
|
446
|
+
/** Whether this network's libp2p node still holds a connection to that peer. */
|
|
447
|
+
private isConnected(peerId: PeerId): boolean {
|
|
448
|
+
return this.deps.libp2p.getConnections(peerId).length > 0;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Re-arm one peer's catch-up after a run whose push failed, on a wait that doubles
|
|
453
|
+
* per consecutive failure up to `maxRetryBackoffMs`. Sets {@link retryAfter} alongside the
|
|
454
|
+
* timer, which is what makes `connection:open` churn inside the wait free.
|
|
455
|
+
*/
|
|
456
|
+
private scheduleRetryWithBackoff(peerId: PeerId): void {
|
|
457
|
+
const key = peerId.toString();
|
|
458
|
+
const failures = (this.failures.get(key) ?? 0) + 1;
|
|
459
|
+
this.failures.set(key, failures);
|
|
460
|
+
const delayMs = Math.min(
|
|
461
|
+
this.config.retryBackoffMs * 2 ** (failures - 1),
|
|
462
|
+
this.config.maxRetryBackoffMs
|
|
463
|
+
);
|
|
464
|
+
this.retryAfter.set(key, Date.now() + delayMs);
|
|
465
|
+
const existing = this.timers.get(key);
|
|
466
|
+
if (existing) clearTimeout(existing);
|
|
467
|
+
this.timers.set(key, setTimeout(() => {
|
|
468
|
+
this.timers.delete(key);
|
|
469
|
+
this.retryAfter.delete(key);
|
|
470
|
+
void this.catchUpPeer(peerId);
|
|
471
|
+
}, delayMs));
|
|
472
|
+
log('[%s] catch-up peer=%s failed %d time(s) in a row; retrying in %dms',
|
|
473
|
+
this.deps.label, key, failures, delayMs);
|
|
474
|
+
this.warnPersistentFailure(key, failures);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Say ONCE per peer, outside the DEBUG log, that its catch-up is not landing. Without this a
|
|
479
|
+
* machine on a link too slow for a relayed dial produces no statement that anything is wrong:
|
|
480
|
+
* the peer never appears to hold the blocks, and the only trace is a DEBUG line naming a dial
|
|
481
|
+
* timeout. Reset when a run finally lands cleanly, so a peer that recovers can report again.
|
|
482
|
+
*/
|
|
483
|
+
private warnPersistentFailure(key: string, failures: number): void {
|
|
484
|
+
if (failures < PEER_JOIN_BACKFILL_WARN_AFTER_FAILURES || this.warned.has(key)) return;
|
|
485
|
+
this.warned.add(key);
|
|
486
|
+
console.warn(
|
|
487
|
+
`[cadre:${this.deps.label}] peer-join block catch-up to peer ${key} has failed ${failures} times in a row `
|
|
488
|
+
+ `(dial budget ${this.config.dialTimeoutMs}ms, response budget ${this.config.responseTimeoutMs}ms). `
|
|
489
|
+
+ 'That peer may not be holding blocks committed before it joined. If it is reachable only through a relay, '
|
|
490
|
+
+ 'these budgets are derived from network.linkRoundTripMs (see link-budget.ts); above about a 2.5-second '
|
|
491
|
+
+ 'round trip no relayed connection can be established at all, whatever they are set to.'
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* The actual copy. `clean` = every chunk pushed and the remote persisted every block.
|
|
497
|
+
* `pushFailed` = at least one push THREW, which is the only non-clean outcome a retry can
|
|
498
|
+
* change; the others are verdicts (denied, inert store, blocks the receiver refused).
|
|
499
|
+
*/
|
|
500
|
+
private async runCatchUp(peerId: PeerId): Promise<{ result: PeerJoinBackfillResult; clean: boolean; pushFailed: boolean }> {
|
|
332
501
|
const result = emptyResult();
|
|
333
502
|
const { storage } = this.deps;
|
|
334
503
|
|
|
@@ -345,7 +514,7 @@ export class PeerJoinBackfill {
|
|
|
345
514
|
}
|
|
346
515
|
if (!authorized) {
|
|
347
516
|
result.denied = true;
|
|
348
|
-
return { result, clean: false };
|
|
517
|
+
return { result, clean: false, pushFailed: false };
|
|
349
518
|
}
|
|
350
519
|
}
|
|
351
520
|
|
|
@@ -354,7 +523,7 @@ export class PeerJoinBackfill {
|
|
|
354
523
|
this.loggedNoListBlockIds = true;
|
|
355
524
|
log('[%s] raw storage does not implement listBlockIds(); backfill is inert', this.deps.label);
|
|
356
525
|
}
|
|
357
|
-
return { result, clean: false };
|
|
526
|
+
return { result, clean: false, pushFailed: false };
|
|
358
527
|
}
|
|
359
528
|
|
|
360
529
|
const client = this.createPushClient(peerId);
|
|
@@ -473,6 +642,6 @@ export class PeerJoinBackfill {
|
|
|
473
642
|
}
|
|
474
643
|
|
|
475
644
|
const clean = !chunkFailed && result.rejected.length === 0;
|
|
476
|
-
return { result, clean };
|
|
645
|
+
return { result, clean, pushFailed: chunkFailed };
|
|
477
646
|
}
|
|
478
647
|
}
|