@serfab/cadre-core 1.23.0 → 1.24.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 +216 -294
- package/dist/arachnode-stub.d.ts +12 -4
- package/dist/arachnode-stub.js +15 -8
- package/dist/arachnode-stub.js.map +1 -1
- package/dist/cadre-invite-protocol.js +5 -4
- package/dist/cadre-invite-protocol.js.map +1 -1
- package/dist/cadre-node.d.ts +145 -44
- package/dist/cadre-node.js +239 -79
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-authorization.d.ts +14 -2
- package/dist/control-authorization.js +8 -3
- package/dist/control-authorization.js.map +1 -1
- package/dist/control-cohort.d.ts +27 -13
- package/dist/control-cohort.js +21 -14
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +18 -16
- package/dist/control-database.js +57 -22
- package/dist/control-database.js.map +1 -1
- package/dist/control-protocol-guard.d.ts +1 -1
- package/dist/control-protocol-guard.js +7 -3
- package/dist/control-protocol-guard.js.map +1 -1
- package/dist/control-read-retry.d.ts +49 -11
- package/dist/control-read-retry.js +56 -15
- package/dist/control-read-retry.js.map +1 -1
- package/dist/control-retry.d.ts +32 -3
- package/dist/control-retry.js +35 -4
- package/dist/control-retry.js.map +1 -1
- package/dist/control-schema-version.d.ts +5 -5
- package/dist/control-schema-version.js +5 -5
- package/dist/control-schema-version.js.map +1 -1
- package/dist/control-schema.d.ts +5 -5
- package/dist/control-schema.js +1032 -1011
- package/dist/control-schema.js.map +1 -1
- package/dist/control-write-retry.d.ts +54 -65
- package/dist/control-write-retry.js +134 -158
- package/dist/control-write-retry.js.map +1 -1
- package/dist/delegate-admission.d.ts +1 -1
- package/dist/delegate-admission.js +1 -1
- package/dist/edge-node/config.d.ts +4 -3
- package/dist/edge-node/config.js +11 -9
- package/dist/edge-node/config.js.map +1 -1
- package/dist/edge-node/dissolve.d.ts +4 -4
- package/dist/edge-node/dissolve.js +4 -4
- package/dist/edge-node/edge-join.d.ts +1 -1
- package/dist/edge-node/edge-join.js +1 -1
- package/dist/edge-node/edge-node.js +2 -2
- package/dist/edge-node/edge-node.js.map +1 -1
- package/dist/edge-node/index.d.ts +1 -0
- package/dist/edge-node/index.js +1 -0
- package/dist/edge-node/index.js.map +1 -1
- package/dist/edge-node/join-credential.d.ts +1 -1
- package/dist/edge-node/join-credential.js +1 -1
- package/dist/edge-node/lazy-raw-storage.js +12 -0
- package/dist/edge-node/lazy-raw-storage.js.map +1 -1
- package/dist/edge-node/listen-addrs.d.ts +21 -0
- package/dist/edge-node/listen-addrs.js +25 -0
- package/dist/edge-node/listen-addrs.js.map +1 -0
- package/dist/edge-node/owner-grant.d.ts +1 -1
- package/dist/edge-node/owner-grant.js +1 -1
- package/dist/edge-node/platform.d.ts +5 -4
- package/dist/edge-node/platform.js.map +1 -1
- package/dist/edge-node/strand-move.d.ts +1 -1
- package/dist/edge-node/strand-move.js +1 -1
- package/dist/edge-node/strands.js +27 -11
- package/dist/edge-node/strands.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +18 -7
- package/dist/index.js.map +1 -1
- package/dist/invitation-bootstrap.d.ts +28 -5
- package/dist/invitation-bootstrap.js +41 -8
- package/dist/invitation-bootstrap.js.map +1 -1
- package/dist/link-budget.d.ts +53 -4
- package/dist/link-budget.js +58 -5
- package/dist/link-budget.js.map +1 -1
- package/dist/machine-removal.d.ts +2 -2
- package/dist/machine-removal.js +4 -3
- package/dist/machine-removal.js.map +1 -1
- package/dist/membership-connection-gater.d.ts +2 -2
- package/dist/membership-connection-gater.js +2 -2
- package/dist/membership-view.d.ts +2 -2
- package/dist/membership-view.js +2 -2
- package/dist/node-claim-payload.d.ts +15 -7
- package/dist/node-claim-payload.js +25 -9
- package/dist/node-claim-payload.js.map +1 -1
- package/dist/node-class.d.ts +36 -0
- package/dist/node-class.js +26 -0
- package/dist/node-class.js.map +1 -0
- package/dist/node-default-transports.d.ts +50 -3
- package/dist/node-default-transports.js +48 -3
- package/dist/node-default-transports.js.map +1 -1
- package/dist/node-roles.d.ts +118 -0
- package/dist/node-roles.js +142 -0
- package/dist/node-roles.js.map +1 -0
- package/dist/node-transports.d.ts +6 -2
- package/dist/node-transports.js +39 -7
- package/dist/node-transports.js.map +1 -1
- package/dist/owner-anchor-sync.js +1 -1
- package/dist/owner-key-export.js +1 -1
- package/dist/owner-key-flows.d.ts +1 -1
- package/dist/owner-key-store.js +1 -1
- package/dist/owner-signer.js +1 -1
- package/dist/peer-authorization.d.ts +3 -1
- package/dist/peer-authorization.js +3 -1
- package/dist/peer-authorization.js.map +1 -1
- package/dist/peer-dial.d.ts +74 -10
- package/dist/peer-dial.js +89 -17
- package/dist/peer-dial.js.map +1 -1
- package/dist/peer-join-backfill.js +4 -4
- package/dist/peer-join-backfill.js.map +1 -1
- package/dist/peer-record.d.ts +34 -9
- package/dist/peer-record.js +66 -13
- package/dist/peer-record.js.map +1 -1
- package/dist/pending-join-runner.d.ts +1 -1
- package/dist/pending-join-runner.js +1 -1
- package/dist/provider/client.d.ts +6 -5
- package/dist/provider/client.js +3 -3
- package/dist/provider/client.js.map +1 -1
- package/dist/provider/descriptor.d.ts +1 -1
- package/dist/provider/descriptor.js +1 -1
- package/dist/provider/oauth.d.ts +1 -1
- package/dist/provider/oauth.js +1 -1
- package/dist/provider/rent-node.d.ts +4 -3
- package/dist/provider/rent-node.js +3 -3
- package/dist/provider/rent-node.js.map +1 -1
- package/dist/relay-addrs.d.ts +62 -7
- package/dist/relay-addrs.js +74 -11
- package/dist/relay-addrs.js.map +1 -1
- package/dist/relay-reservation.d.ts +1 -1
- package/dist/relay-reservation.js +1 -1
- package/dist/relay-server.d.ts +6 -5
- package/dist/relay-server.js +5 -5
- package/dist/relay-server.js.map +1 -1
- package/dist/schema-verification.d.ts +13 -10
- package/dist/schema-verification.js +32 -24
- package/dist/schema-verification.js.map +1 -1
- package/dist/sealed-party-key.js +1 -1
- package/dist/seed-bootstrap.d.ts +4 -3
- package/dist/seed-bootstrap.js +6 -7
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/strand-addr-protocol.d.ts +8 -6
- package/dist/strand-addr-protocol.js +12 -10
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-app-schema-report.d.ts +16 -2
- package/dist/strand-app-schema-report.js +15 -0
- package/dist/strand-app-schema-report.js.map +1 -1
- package/dist/strand-cohort.d.ts +1 -4
- package/dist/strand-cohort.js.map +1 -1
- package/dist/strand-commit-durability.d.ts +1 -1
- package/dist/strand-database.d.ts +13 -6
- package/dist/strand-database.js +17 -9
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-first-sync-gate.d.ts +3 -2
- package/dist/strand-first-sync-gate.js +3 -2
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-formation-deadlines.d.ts +2 -2
- package/dist/strand-formation-deadlines.js +2 -2
- package/dist/strand-formation-protocol.d.ts +1 -1
- package/dist/strand-formation-protocol.js +51 -16
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +67 -33
- package/dist/strand-instance-manager.js +164 -55
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-reconciler.d.ts +8 -3
- package/dist/strand-membership-reconciler.js +8 -3
- package/dist/strand-membership-reconciler.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +2 -2
- package/dist/strand-membership-writer.js +41 -39
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-move.js +1 -1
- package/dist/strand-network-config.d.ts +15 -5
- package/dist/strand-network-config.js +7 -6
- package/dist/strand-network-config.js.map +1 -1
- package/dist/strand-party-key-rotation.d.ts +7 -3
- package/dist/strand-party-key-rotation.js +7 -3
- package/dist/strand-party-key-rotation.js.map +1 -1
- package/dist/strand-party-machines.d.ts +19 -8
- package/dist/strand-party-machines.js +26 -11
- package/dist/strand-party-machines.js.map +1 -1
- package/dist/strand-party-peers.d.ts +36 -14
- package/dist/strand-party-peers.js +24 -15
- package/dist/strand-party-peers.js.map +1 -1
- package/dist/strand-peer-redial.d.ts +1 -1
- package/dist/strand-peer-redial.js +1 -1
- package/dist/strand-reactivity.d.ts +20 -17
- package/dist/strand-reactivity.js +31 -18
- package/dist/strand-reactivity.js.map +1 -1
- package/dist/strand-revocation-enforcer.d.ts +3 -3
- package/dist/strand-revocation-enforcer.js +3 -3
- package/dist/strand-wake-protocol.d.ts +19 -7
- package/dist/strand-wake-protocol.js +22 -10
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/strand-watcher.d.ts +1 -1
- package/dist/strand-watcher.js +1 -1
- package/dist/table-change-watch.js +1 -1
- package/dist/types.d.ts +116 -55
- package/dist/types.js.map +1 -1
- package/dist/webrtc-upgrade.d.ts +254 -0
- package/dist/webrtc-upgrade.js +355 -0
- package/dist/webrtc-upgrade.js.map +1 -0
- package/package.json +9 -9
- package/src/announce-addrs.ts +93 -93
- package/src/arachnode-stub.ts +18 -10
- package/src/bootstrap-peer-store-file.ts +44 -44
- package/src/bootstrap-peer-store.ts +214 -214
- package/src/cadre-invite-protocol.ts +741 -740
- package/src/cadre-node.ts +12462 -12280
- package/src/claim-proof.ts +147 -147
- package/src/control-authorization.ts +290 -276
- package/src/control-cohort.ts +223 -204
- package/src/control-database.ts +72 -28
- package/src/control-formation-recorder.ts +359 -359
- package/src/control-protocol-guard.ts +370 -366
- package/src/control-read-retry.ts +222 -180
- package/src/control-retry.ts +36 -4
- package/src/control-schema-version.ts +301 -301
- package/src/control-schema.ts +1108 -1087
- package/src/control-write-retry.ts +639 -669
- package/src/delegate-admission.ts +351 -351
- package/src/describe-thrown.ts +60 -60
- package/src/ed25519-key.ts +185 -185
- package/src/edge-node/config.ts +13 -10
- package/src/edge-node/dissolve.ts +252 -252
- package/src/edge-node/edge-join.ts +320 -320
- package/src/edge-node/edge-node.ts +1095 -1095
- package/src/edge-node/index.ts +60 -59
- package/src/edge-node/join-credential.ts +16 -16
- package/src/edge-node/lazy-raw-storage.ts +194 -178
- package/src/edge-node/listen-addrs.ts +26 -0
- package/src/edge-node/node-local.ts +84 -84
- package/src/edge-node/options.ts +195 -195
- package/src/edge-node/owner-grant.ts +63 -63
- package/src/edge-node/platform.ts +5 -4
- package/src/edge-node/strand-move.ts +266 -266
- package/src/edge-node/strands.ts +27 -12
- package/src/enrolled-machine-store-file.ts +43 -43
- package/src/enrolled-machine-store.ts +280 -280
- package/src/fetch-impl.ts +23 -23
- package/src/file-durable-slot.ts +64 -64
- package/src/file-safe-name.ts +32 -32
- package/src/formation-approval.ts +604 -604
- package/src/formation-token.ts +63 -63
- package/src/fs-atomic.ts +92 -92
- package/src/index.ts +987 -957
- package/src/invitation-bootstrap.ts +152 -118
- package/src/joined-strand-store.ts +553 -553
- package/src/key-store-file.ts +142 -142
- package/src/link-budget.ts +61 -5
- package/src/machine-removal.ts +211 -210
- package/src/member-redemption.ts +643 -643
- package/src/membership-connection-gater.ts +650 -650
- package/src/membership-view.ts +147 -147
- package/src/node-claim-payload.ts +34 -12
- package/src/node-class.ts +47 -0
- package/src/node-default-transports.ts +65 -3
- package/src/node-roles.ts +220 -0
- package/src/node-transports.ts +86 -49
- package/src/owner-anchor-sync.ts +172 -172
- package/src/owner-grant-protocol.ts +547 -547
- package/src/owner-key-export.ts +348 -348
- package/src/owner-key-flows.ts +109 -109
- package/src/owner-key-store.ts +1 -1
- package/src/owner-keys.ts +179 -179
- package/src/owner-signer.ts +92 -92
- package/src/peer-addr-book.ts +252 -252
- package/src/peer-authorization.ts +584 -582
- package/src/peer-dial.ts +698 -605
- package/src/peer-join-backfill.ts +961 -961
- package/src/peer-record.ts +71 -16
- package/src/pending-join-runner.ts +798 -798
- package/src/primary-lan-address.ts +47 -47
- package/src/provider/client.ts +327 -326
- package/src/provider/descriptor.ts +129 -129
- package/src/provider/index.ts +59 -59
- package/src/provider/oauth.ts +285 -285
- package/src/provider/rent-node.ts +276 -275
- package/src/relay-addrs.ts +90 -12
- package/src/relay-reservation.ts +1 -1
- package/src/relay-server.ts +99 -98
- package/src/schema-verification.ts +38 -23
- package/src/sealed-party-key.ts +190 -190
- package/src/seed-bootstrap.ts +8 -11
- package/src/seed-trust-policy.ts +353 -353
- package/src/self-address-update.ts +19 -19
- package/src/strand-addr-protocol.ts +17 -14
- package/src/strand-app-schema-report.ts +147 -122
- package/src/strand-cohort.ts +1 -5
- package/src/strand-commit-durability.ts +165 -165
- package/src/strand-database.ts +522 -510
- package/src/strand-first-sync-gate.ts +3 -2
- package/src/strand-formation-deadlines.ts +227 -227
- package/src/strand-formation-manager.ts +731 -731
- package/src/strand-formation-protocol.ts +1174 -1138
- package/src/strand-fret-addrs.ts +179 -179
- package/src/strand-instance-manager.ts +188 -63
- package/src/strand-membership-reconciler.ts +1315 -1310
- package/src/strand-membership-writer.ts +2152 -2150
- package/src/strand-move.ts +1 -1
- package/src/strand-network-config.ts +16 -6
- package/src/strand-offline.ts +178 -178
- package/src/strand-party-key-rotation.ts +440 -436
- package/src/strand-party-machines.ts +308 -293
- package/src/strand-party-peers.ts +151 -129
- package/src/strand-peer-redial.ts +1 -1
- package/src/strand-reactivity.ts +36 -19
- package/src/strand-revocation-enforcer.ts +758 -758
- package/src/strand-wake-protocol.ts +406 -394
- package/src/strand-watcher.ts +1 -1
- package/src/table-change-watch.ts +285 -285
- package/src/timed-step.ts +28 -28
- package/src/timeout-scheduler.ts +29 -29
- package/src/trusted-owner-store.ts +242 -242
- package/src/types.ts +3182 -3121
- package/src/webrtc-upgrade.ts +439 -0
|
@@ -3,6 +3,7 @@ import { createLibp2pNode } from '@optimystic/db-p2p';
|
|
|
3
3
|
import { wrapStorageWithCache, disposeStorageCache, checkAppSchema, appSchemaRefusalOf } from '@serfab/quereus-plugin-sereus';
|
|
4
4
|
import { StrandDatabase } from './strand-database.js';
|
|
5
5
|
import { PeerJoinBackfill } from './peer-join-backfill.js';
|
|
6
|
+
import { WebrtcUpgradeService } from './webrtc-upgrade.js';
|
|
6
7
|
import { strandNetworkStatePersistence } from './strand-network-state.js';
|
|
7
8
|
import { StrandRevocationEnforcer, createRevocationConnectionGater, readStrandRevocationRows } from './strand-revocation-enforcer.js';
|
|
8
9
|
import { StrandMembershipReconciler } from './strand-membership-reconciler.js';
|
|
@@ -14,19 +15,20 @@ import { assertStrandScopeKey } from './storage-scope.js';
|
|
|
14
15
|
import { StrandFirstSyncGate, StrandAwaitingFirstSyncError, DEFAULT_STRAND_FIRST_SYNC_TIMEOUT_MS } from './strand-first-sync-gate.js';
|
|
15
16
|
import { DEFAULT_CONNECTION_MONITOR, resolveStrandClusterSize, strandClusterPolicy } from './types.js';
|
|
16
17
|
import { strandNodeAddrs } from './strand-network-config.js';
|
|
18
|
+
import { listenTransportNodeOptions } from './relay-addrs.js';
|
|
17
19
|
import { nodeTransportsOption } from './node-transports.js';
|
|
18
20
|
import { resolveRelayServer } from './relay-server.js';
|
|
19
21
|
import { strandCohortTopicOption } from './strand-reactivity.js';
|
|
20
22
|
import { superviseRelayReservation } from './relay-reservation.js';
|
|
21
23
|
import { strandRedialTimings, superviseStrandPeerRedial } from './strand-peer-redial.js';
|
|
22
24
|
import { groupAddrsByPeerId } from './peer-addr-book.js';
|
|
23
|
-
import { isCohortUnreachableRead } from './control-read-retry.js';
|
|
24
|
-
import { declaredCohortReadDeadlineMs, optimysticDialLimits, peerJoinPushBudget, relayReservationBudgetMs, resolveLinkRoundTripMs } from './link-budget.js';
|
|
25
|
+
import { isCohortUnreachableRead, isNoCoordinatorResolved } from './control-read-retry.js';
|
|
26
|
+
import { declaredCohortReadDeadlineMs, optimysticDialLimits, peerJoinPushBudget, relayReservationBudgetMs, resolveLinkRoundTripMs, webrtcUpgradeDialBudgetMs } from './link-budget.js';
|
|
25
27
|
import { describeThrown } from './describe-thrown.js';
|
|
26
28
|
const log = debug('sereus:cadre:strand-manager');
|
|
27
29
|
/**
|
|
28
|
-
* How often a
|
|
29
|
-
*
|
|
30
|
+
* How often a launch that could not build its database, because no machine that can answer for
|
|
31
|
+
* the strand's blocks was reachable, retries the build on its running libp2p node
|
|
30
32
|
* (`StrandInstanceManager.deferUnreachableJoin`). Each attempt composes a fresh database and
|
|
31
33
|
* re-reads the schema catalog over the network, so it is spaced well above the first-sync
|
|
32
34
|
* gate's probe cadence.
|
|
@@ -128,6 +130,7 @@ function verifiedSAppInfo(strandId, sAppConfig, requireSignedSchemas) {
|
|
|
128
130
|
return {
|
|
129
131
|
id: sAppConfig.id,
|
|
130
132
|
version: sAppConfig.version,
|
|
133
|
+
schemaVersion: sAppConfig.schemaVersion,
|
|
131
134
|
schema: sAppConfig.schema,
|
|
132
135
|
signature: sAppConfig.signature
|
|
133
136
|
};
|
|
@@ -146,7 +149,7 @@ export class StrandInstanceManager {
|
|
|
146
149
|
/**
|
|
147
150
|
* Retained launch config per strand, captured in `startStrand` and cleared in
|
|
148
151
|
* `stopStrand`. `resumeStrand` reuses it to rebuild a quiesced strand's runtime
|
|
149
|
-
* without the caller re-threading storage/network/
|
|
152
|
+
* without the caller re-threading storage/network/node-class/key/sApp config.
|
|
150
153
|
*/
|
|
151
154
|
this.launchConfigs = new Map();
|
|
152
155
|
/**
|
|
@@ -212,6 +215,13 @@ export class StrandInstanceManager {
|
|
|
212
215
|
* nobody and a resume redials over the new node.
|
|
213
216
|
*/
|
|
214
217
|
this.peerRedials = new Map();
|
|
218
|
+
/**
|
|
219
|
+
* The per-strand background WebRTC upgrade of relayed connections (`webrtc-upgrade.ts`), keyed
|
|
220
|
+
* by strand id. Same lifecycle as {@link peerRedials}: started in `buildStrandRuntime` once
|
|
221
|
+
* the libp2p node exists, stopped first in `releaseRuntime`, so a hibernating strand dials no
|
|
222
|
+
* upgrade and a resume judges the new node's connections with no backoff carried over.
|
|
223
|
+
*/
|
|
224
|
+
this.webrtcUpgrades = new Map();
|
|
215
225
|
/**
|
|
216
226
|
* The party's other machines known to hold each strand (`strand-party-machines.ts`), keyed
|
|
217
227
|
* by strand id, on a node offering offline mode for a launch with a party-machine seam. Same
|
|
@@ -267,7 +277,8 @@ export class StrandInstanceManager {
|
|
|
267
277
|
this.transitions = new Map();
|
|
268
278
|
/**
|
|
269
279
|
* The pending database retry per strand id of a launch whose database could not be built
|
|
270
|
-
* because no
|
|
280
|
+
* because no machine that can answer for the strand's blocks was reachable yet
|
|
281
|
+
* ({@link deferUnreachableJoin}). Cleared by
|
|
271
282
|
* {@link releaseRuntime}, so a stop or a quiesce cancels it.
|
|
272
283
|
*/
|
|
273
284
|
this.unreachableJoinRetries = new Map();
|
|
@@ -314,6 +325,10 @@ export class StrandInstanceManager {
|
|
|
314
325
|
hasStrand(strandId) {
|
|
315
326
|
return this.instances.has(strandId);
|
|
316
327
|
}
|
|
328
|
+
/** The sApp config the tracked strand's next build applies (its retained launch config's), or `undefined` for a replica or an untracked strand. */
|
|
329
|
+
launchedSAppConfig(strandId) {
|
|
330
|
+
return this.launchConfigs.get(strandId)?.sAppConfig;
|
|
331
|
+
}
|
|
317
332
|
/**
|
|
318
333
|
* Start a new strand instance.
|
|
319
334
|
*
|
|
@@ -363,10 +378,21 @@ export class StrandInstanceManager {
|
|
|
363
378
|
// function is provided, it is called with the strandId to create strand-specific
|
|
364
379
|
// storage (e.g. strand-isolated directories). A provider that throws therefore
|
|
365
380
|
// fails the launch alongside the schema-signature check, leaving nothing tracked.
|
|
366
|
-
|
|
381
|
+
//
|
|
382
|
+
// Never on a client (`roles.strandCohortMember: false`, built so in `buildStrandRuntime`):
|
|
383
|
+
// it stores no blocks, and the provider call itself has a side effect — a per-strand
|
|
384
|
+
// database on a phone, a per-strand directory on a node — so it is not made. Nothing is
|
|
385
|
+
// recorded in `strandStorages`, and every reader of that map (the join catch-up, the
|
|
386
|
+
// first-join test, the storage dispose) already handles the absent store.
|
|
387
|
+
const strandStorage = config.roles.strandCohortMember
|
|
388
|
+
? resolveStrandStorage(config.storage?.provider, strandId)
|
|
389
|
+
: undefined;
|
|
367
390
|
if (strandStorage) {
|
|
368
391
|
log('Strand %s using provided storage provider', strandId);
|
|
369
392
|
}
|
|
393
|
+
else if (!config.roles.strandCohortMember) {
|
|
394
|
+
log('Strand %s runs as a client: no store is resolved, its blocks live on the serving machines', strandId);
|
|
395
|
+
}
|
|
370
396
|
// Determine latency hint: sApp config > default
|
|
371
397
|
const latencyHint = sAppConfig?.latencyHint ?? config.defaultLatencyHint;
|
|
372
398
|
const instance = {
|
|
@@ -440,15 +466,15 @@ export class StrandInstanceManager {
|
|
|
440
466
|
* Build (or rebuild) the libp2p node + StrandDatabase for an instance and
|
|
441
467
|
* attach them, transitioning it to `active`. Shared by `startStrand` (fresh
|
|
442
468
|
* launch) and `resumeStrand` (rehydrating a quiesced instance). Reads all
|
|
443
|
-
* volatile inputs (bootstrapNodes, servingMachines, network,
|
|
469
|
+
* volatile inputs (bootstrapNodes, servingMachines, network, roles,
|
|
444
470
|
* privateKey, sApp config) from `config`, so the caller controls the
|
|
445
471
|
* cohort-derived values. Storage is the
|
|
446
472
|
* one input it does NOT re-read from `config`: that belongs to the instance and
|
|
447
473
|
* comes from `strandStorages`.
|
|
448
474
|
*
|
|
449
|
-
* A database that cannot be built because no
|
|
450
|
-
* build: the runtime comes up `'syncing'` without it and the
|
|
451
|
-
* retried on the same node ({@link deferUnreachableJoin}).
|
|
475
|
+
* A database that cannot be built because no machine that can answer for the strand's blocks
|
|
476
|
+
* was reachable does not fail the build: the runtime comes up `'syncing'` without it and the
|
|
477
|
+
* database phase alone is retried on the same node ({@link deferUnreachableJoin}).
|
|
452
478
|
*/
|
|
453
479
|
async buildStrandRuntime(instance, config) {
|
|
454
480
|
const strandId = instance.strandId;
|
|
@@ -457,6 +483,12 @@ export class StrandInstanceManager {
|
|
|
457
483
|
// (backfill disabled, no relay addrs), so a zero or NaN declaration would otherwise
|
|
458
484
|
// surface later inside a path that logs and carries on. `link-budget.ts`.
|
|
459
485
|
resolveLinkRoundTripMs(config.network?.linkRoundTripMs);
|
|
486
|
+
// Whether this strand node stores and signs the strand's blocks, or is a CLIENT that reads
|
|
487
|
+
// and writes through the machines that do (`NodeRoles.strandCohortMember`). The one place
|
|
488
|
+
// the role is turned into a node: everything below that differs on a client follows from
|
|
489
|
+
// this binding, and `startStrand` resolved no store for one, so `strandStorage` is undefined
|
|
490
|
+
// there and `backfillArms` is false with it.
|
|
491
|
+
const servesBlocks = config.roles.strandCohortMember;
|
|
460
492
|
// The store the instance OWNS (resolved once in `startStrand`), not a fresh
|
|
461
493
|
// resolution: a rebuild must reach the same backend through the same warm cache.
|
|
462
494
|
const strandStorage = this.strandStorages.get(strandId);
|
|
@@ -472,7 +504,7 @@ export class StrandInstanceManager {
|
|
|
472
504
|
const protocolPrefix = `/optimystic/${networkName}`;
|
|
473
505
|
// Whether this node runs the circuit-relay server, and its init — the same
|
|
474
506
|
// resolution the control node takes from the same config (`relay-server.ts`).
|
|
475
|
-
const relayServer = resolveRelayServer(config.network, config.
|
|
507
|
+
const relayServer = resolveRelayServer(config.network, config.roles);
|
|
476
508
|
// The strand-node VIEW of the machine's one `NetworkConfig`, not the control
|
|
477
509
|
// node's resolution: fixed direct listen ports become ephemeral (two nodes cannot
|
|
478
510
|
// bind one port), the announce config is dropped (it names the control node's
|
|
@@ -484,8 +516,10 @@ export class StrandInstanceManager {
|
|
|
484
516
|
// `strand-network-config.ts` for all three, and `relay-reservation.ts`.
|
|
485
517
|
//
|
|
486
518
|
// `relayAddrs` is destructured OFF: it is not a `createLibp2pNode` option, and
|
|
487
|
-
// spreading it would hand db-p2p a key it does not know.
|
|
488
|
-
|
|
519
|
+
// spreading it would hand db-p2p a key it does not know. `listenTransports` is split out
|
|
520
|
+
// for the same reason — `wsPort` is db-p2p's switch but the WebRTC ICE servers beside it
|
|
521
|
+
// are read only by `network.defaultTransports` (`listenTransportNodeOptions` drops them).
|
|
522
|
+
const { relayAddrs: relayDialAddrs = [], listenAddrs, ...listenTransports } = strandNodeAddrs(config.network);
|
|
489
523
|
// Bound once, before anything is built — so, like the round-trip check above, a
|
|
490
524
|
// rejected clusterSize fails the build with nothing to release. The breadth is also
|
|
491
525
|
// the ceiling on the repair yardstick and the revocation enforcer's wide-strand
|
|
@@ -541,9 +575,9 @@ export class StrandInstanceManager {
|
|
|
541
575
|
: config.network?.connectionGater
|
|
542
576
|
? { connectionGater: config.network.connectionGater }
|
|
543
577
|
: {};
|
|
544
|
-
const reactivityOption = strandCohortTopicOption(config.reactivity, strandId);
|
|
578
|
+
const reactivityOption = strandCohortTopicOption(config.reactivity, strandId, config.roles.reactivity);
|
|
545
579
|
if (reactivityOption.cohortTopic) {
|
|
546
|
-
log('strand %s: change notifications on', strandId);
|
|
580
|
+
log('strand %s: change notifications on, as %s', strandId, config.roles.reactivity);
|
|
547
581
|
}
|
|
548
582
|
// The party's other machines holding this strand, for the offline queue's gate, each commit's
|
|
549
583
|
// durability record and the redial loop below (`strand-party-machines.ts`). Only a node offering offline mode pays
|
|
@@ -575,8 +609,16 @@ export class StrandInstanceManager {
|
|
|
575
609
|
// sibling recorded is never read as removed. If a peer is ever seen left out of cohorts
|
|
576
610
|
// this way, the row needs a proof that the id it states is the machine's own.
|
|
577
611
|
...(partyMachines && { isNetworkMember: (peerId) => !partyMachines.removed().has(peerId) }),
|
|
612
|
+
// A client registers none of the four storage protocol services, so every other machine
|
|
613
|
+
// classifies it from its identify list as not serving and leaves it out of every cohort,
|
|
614
|
+
// its own view of itself included; its reads and writes go to a coordinator among the
|
|
615
|
+
// strand's serving machines (`../optimystic/docs/internals.md` → "Client nodes"). The
|
|
616
|
+
// serving-only options Optimystic would ignore on a client stay off it below: `storage`
|
|
617
|
+
// is undefined here on a client (`startStrand`), `arachnode` is behind this flag, and
|
|
618
|
+
// `rebalance` is behind `backfillArms`, which the absent store already made false.
|
|
619
|
+
servesBlocks,
|
|
578
620
|
storage: strandStorage,
|
|
579
|
-
fretProfile: config.
|
|
621
|
+
fretProfile: config.roles.overlayTier,
|
|
580
622
|
relay: relayServer.enabled,
|
|
581
623
|
// NOTE: unlike the control node, a strand node has no unauthorized-reservation budget,
|
|
582
624
|
// so with the per-connection cap off any peer that reaches this node can hold one of
|
|
@@ -601,10 +643,15 @@ export class StrandInstanceManager {
|
|
|
601
643
|
servingMachines: config.servingMachines,
|
|
602
644
|
cohortQueryTimeoutMs: declaredCohortReadDeadlineMs(config.network)
|
|
603
645
|
}),
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
646
|
+
// A client builds no Arachnode at all, so the option is not stated for one.
|
|
647
|
+
...(servesBlocks && {
|
|
648
|
+
arachnode: {
|
|
649
|
+
// Follows `alwaysOn`, for the control node's reason (`cadre-node.ts`): the storage
|
|
650
|
+
// rings Ring Zulu hints at are unimplemented, so there is no second role to set.
|
|
651
|
+
enableRingZulu: config.roles.alwaysOn
|
|
652
|
+
}
|
|
653
|
+
}),
|
|
654
|
+
// One join catch-up per node. On an always-on node Optimystic's rebalance growth
|
|
608
655
|
// arm pushes a joiner every block whose cohort it entered, one request per block, and
|
|
609
656
|
// it never hears of the peer-join catch-up's pushes, so each block would go twice. The
|
|
610
657
|
// catch-up pushes every block to every peer it serves, the growth arm's targets
|
|
@@ -637,7 +684,7 @@ export class StrandInstanceManager {
|
|
|
637
684
|
// that fills the bare `/p2p-circuit` slots: otherwise a cohort seed running the relay
|
|
638
685
|
// server takes one as soon as it connects (`relay-reservation.ts`, "WHY LIBP2P'S
|
|
639
686
|
// RELAY DISCOVERY IS SWITCHED OFF").
|
|
640
|
-
...nodeTransportsOption(config.network,
|
|
687
|
+
...nodeTransportsOption(config.network, listenTransports, relayDialAddrs.length > 0),
|
|
641
688
|
...(config.network?.noiseCrypto && { noiseCrypto: config.network.noiseCrypto }),
|
|
642
689
|
// Unconditional, and the same default the control node takes: every node of
|
|
643
690
|
// every party runs the monitor over its connection to a slow phone, so the
|
|
@@ -659,7 +706,8 @@ export class StrandInstanceManager {
|
|
|
659
706
|
// supervisor below fills. That is what gives a NAT'd strand node a reachable relay
|
|
660
707
|
// slot — and works against a party-run relay because the launch path announced
|
|
661
708
|
// this strand's derived peerId to it first (delegate admission; see cadre-node.ts).
|
|
662
|
-
...
|
|
709
|
+
...(listenAddrs && { listenAddrs }),
|
|
710
|
+
...listenTransportNodeOptions(listenTransports),
|
|
663
711
|
// The raw configured gater (open strands), or the revocation-composed
|
|
664
712
|
// gater plus the fail-closed per-stream revoked-peer gate (closed
|
|
665
713
|
// strands) — resolved above, before the try.
|
|
@@ -673,7 +721,14 @@ export class StrandInstanceManager {
|
|
|
673
721
|
// database (`StrandPeer`): a background write that never fails or delays the launch.
|
|
674
722
|
// The seam defers it while a write could fork the party and retries it on cohort
|
|
675
723
|
// growth and from every membership reconciler pass, so a refusal here is not final.
|
|
676
|
-
//
|
|
724
|
+
//
|
|
725
|
+
// Written by EVERY machine, client or serving, and for an open strand as well as a closed
|
|
726
|
+
// one: in a closed strand the row is how a sibling and the party key replacement bind this
|
|
727
|
+
// machine, which a client needs as much as a server, and an open strand's row is what a
|
|
728
|
+
// sibling's offline queue waits for (docs/strands/membership.md → "Binding the party's
|
|
729
|
+
// machines"). Whether this machine serves is the row's role column, which
|
|
730
|
+
// `CadreNode.publishStrandPeer` fills from the node's own role; the one reader that must
|
|
731
|
+
// skip a client filters on it (`strand-party-machines.ts`).
|
|
677
732
|
if (config.partyPeers) {
|
|
678
733
|
void config.partyPeers.publishOwn(node.peerId.toString()).catch((error) => {
|
|
679
734
|
log('Strand %s: publishing this machine\'s StrandPeer row threw (retried later): %o', strandId, error);
|
|
@@ -706,6 +761,18 @@ export class StrandInstanceManager {
|
|
|
706
761
|
}),
|
|
707
762
|
...(partyMachines && { partyMachines: () => partyMachines.machines().map((machine) => machine.strandPeerId) })
|
|
708
763
|
}, strandRedialTimings(config.network?.linkRoundTripMs)));
|
|
764
|
+
// Try a direct WebRTC connection in the background for each member this node ends up
|
|
765
|
+
// reaching through a relay, which on a strand is the normal case: a strand's peers are
|
|
766
|
+
// other parties' machines, so both sides are often behind NAT. Armed here rather than
|
|
767
|
+
// after the database phase, so a direct path can be in place by the time the first sync's
|
|
768
|
+
// reads run. Inert unless the embedder passed a WebRTC transport (`webrtc-upgrade.ts`).
|
|
769
|
+
const webrtcUpgrade = new WebrtcUpgradeService({
|
|
770
|
+
label: strandId,
|
|
771
|
+
node,
|
|
772
|
+
dialTimeoutMs: webrtcUpgradeDialBudgetMs(config.network?.linkRoundTripMs)
|
|
773
|
+
});
|
|
774
|
+
this.webrtcUpgrades.set(strandId, webrtcUpgrade);
|
|
775
|
+
webrtcUpgrade.start();
|
|
709
776
|
const databaseBuild = await this.buildStrandDatabase(instance, config, node);
|
|
710
777
|
if (!this.isCurrentRuntime(instance, node)) {
|
|
711
778
|
// A stop released this runtime during the database phase (`stopStrand` does not
|
|
@@ -741,6 +808,9 @@ export class StrandInstanceManager {
|
|
|
741
808
|
// peer-join-backfill.ts for the strand-side argument (and why the control
|
|
742
809
|
// network, which DOES gate, is different).
|
|
743
810
|
//
|
|
811
|
+
// Never on a client: it holds no blocks to push, and `startStrand` resolved it no store,
|
|
812
|
+
// which is what `backfillArms` reads.
|
|
813
|
+
//
|
|
744
814
|
// NOTE: cost is one PeerJoinBackfill object + one `peer:identify` listener
|
|
745
815
|
// per running strand — linear in strand count, negligible at the handful a
|
|
746
816
|
// device or host runs today. If a node ever hosts strands by the hundred,
|
|
@@ -791,7 +861,7 @@ export class StrandInstanceManager {
|
|
|
791
861
|
// No `lastActivity` stamp: bringing a runtime up is not activity. A check-in marks
|
|
792
862
|
// activity before its resume and must see only what landed while the strand was up.
|
|
793
863
|
instance.status = liveStrandStatus(instance);
|
|
794
|
-
if (databaseBuild === 'awaiting-
|
|
864
|
+
if (databaseBuild === 'awaiting-peer') {
|
|
795
865
|
// Armed only now that the build is over: a retry firing mid-build would find the
|
|
796
866
|
// build in flight.
|
|
797
867
|
this.deferUnreachableJoin(instance);
|
|
@@ -818,10 +888,13 @@ export class StrandInstanceManager {
|
|
|
818
888
|
* {@link buildStrandRuntime} and again by each {@link retryUnreachableJoin}, with a new
|
|
819
889
|
* StrandDatabase per attempt.
|
|
820
890
|
*
|
|
821
|
-
* Returns `'awaiting-
|
|
822
|
-
*
|
|
823
|
-
* other failure throws, with the attempt's database left with its gate for
|
|
891
|
+
* Returns `'awaiting-peer'` when initialize failed only because no machine that can answer for
|
|
892
|
+
* the strand's blocks was reachable: that attempt's database is closed and the node keeps
|
|
893
|
+
* running. Any other failure throws, with the attempt's database left with its gate for
|
|
824
894
|
* {@link releaseRuntime} to close.
|
|
895
|
+
*
|
|
896
|
+
* A client node's database (`roles.strandCohortMember: false`) is published as soon as it
|
|
897
|
+
* initializes, like a founder's: see the first-sync decision below.
|
|
825
898
|
*/
|
|
826
899
|
async buildStrandDatabase(instance, config, node) {
|
|
827
900
|
const strandId = instance.strandId;
|
|
@@ -835,6 +908,7 @@ export class StrandInstanceManager {
|
|
|
835
908
|
strandId,
|
|
836
909
|
sAppConfig: config.sAppConfig,
|
|
837
910
|
libp2pNode: node,
|
|
911
|
+
// Absent on a client, which coordinates no writes; the database then connects without one.
|
|
838
912
|
coordinatedRepo: node.coordinatedRepo,
|
|
839
913
|
// Founder bootstrap inputs: the strand's type drives which membership rows
|
|
840
914
|
// are written, and the PARTY's own key (partyMemberPrivateKey, resolved by the
|
|
@@ -875,13 +949,19 @@ export class StrandInstanceManager {
|
|
|
875
949
|
await strandDb.initialize();
|
|
876
950
|
}
|
|
877
951
|
catch (error) {
|
|
878
|
-
|
|
952
|
+
// The two shapes of "nobody who can answer for this strand's blocks is reachable yet": a
|
|
953
|
+
// cohort member that could not be asked (a joining replica whose seed is silent, a founder
|
|
954
|
+
// whose cohort is), and no coordinator resolvable at all (a client, whose own cohort is
|
|
955
|
+
// empty by construction, so every block falls through to `findCoordinator`). Any other
|
|
956
|
+
// failure — a schema that cannot apply here, a refused signature — fails the launch, which
|
|
957
|
+
// is what matching one error class by type each buys over reading the message.
|
|
958
|
+
if (!isCohortUnreachableRead(error) && !isNoCoordinatorResolved(error)) {
|
|
879
959
|
throw error;
|
|
880
960
|
}
|
|
881
961
|
await this.discardDatabaseAttempt(strandId, gate);
|
|
882
|
-
log('Strand %s: no
|
|
883
|
-
'its runtime stays up and the build is retried every %dms', strandId, describeThrown(error), UNREACHABLE_JOIN_RETRY_MS);
|
|
884
|
-
return 'awaiting-
|
|
962
|
+
log('Strand %s: no machine that can answer for this strand is reachable yet, so this launch ' +
|
|
963
|
+
'cannot build its database (%s); its runtime stays up and the build is retried every %dms', strandId, describeThrown(error), UNREACHABLE_JOIN_RETRY_MS);
|
|
964
|
+
return 'awaiting-peer';
|
|
885
965
|
}
|
|
886
966
|
timing('[buildStrandRuntime:%s] strandDatabase.initialize: %dms', strandId, Math.round(performance.now() - t0));
|
|
887
967
|
if (this.firstSyncGates.get(strandId) !== gate) {
|
|
@@ -912,7 +992,18 @@ export class StrandInstanceManager {
|
|
|
912
992
|
if (awaitPush) {
|
|
913
993
|
log('Strand %s: first join over an empty store; waiting for a member\'s push before the first sync probe', strandId);
|
|
914
994
|
}
|
|
915
|
-
|
|
995
|
+
// A client is treated as synced, like a founder. The gate stops a joining machine inventing a
|
|
996
|
+
// collection while it is the whole cohort for every block; a client is in no cohort, so a
|
|
997
|
+
// write with no serving machine reachable resolves no coordinator and fails instead of
|
|
998
|
+
// committing locally — there is no fork to prevent. Gating it would also be wrong in itself:
|
|
999
|
+
// its probe reads would be remote reads repeated on the backstop (it has no storage change
|
|
1000
|
+
// feed to wake it), and while the database was withheld the app could neither write nor
|
|
1001
|
+
// queue. So on a client `addStrand` resolving means the database is open, not that a member
|
|
1002
|
+
// has been reached: the first read or write fails, retryably, until a serving machine is
|
|
1003
|
+
// reachable (docs/strands/formation.md → "Joining: no writes before the first sync"). The
|
|
1004
|
+
// gate object stays as the handle `releaseRuntime` closes the database through.
|
|
1005
|
+
const client = !config.roles.strandCohortMember;
|
|
1006
|
+
const synced = config.founder === true || client || (!awaitPush && await gate.probeOnce());
|
|
916
1007
|
timing('[buildStrandRuntime:%s] first-sync probe: %dms', strandId, Math.round(performance.now() - t0));
|
|
917
1008
|
if (this.firstSyncGates.get(strandId) !== gate) {
|
|
918
1009
|
// A stop released the runtime during the probe and closed this database through its gate.
|
|
@@ -976,9 +1067,10 @@ export class StrandInstanceManager {
|
|
|
976
1067
|
watchRemovedMachinesInSeed(machines, seedPeers, announced, () => onRemovedMachineInSeed(strandId), strandId);
|
|
977
1068
|
}
|
|
978
1069
|
/**
|
|
979
|
-
* The party's other machines known to
|
|
1070
|
+
* The party's other machines known to STORE `strandId` ({@link StrandPartyMachines.machines},
|
|
1071
|
+
* clients already dropped) with no open connection from its strand
|
|
980
1072
|
* node: what an offline queue reporting `waitingFor: 'cohort'` may be waiting for
|
|
981
|
-
* (`docs/strands.md` → "Waiting for the party's own machines"). Empty for a strand not tracked
|
|
1073
|
+
* (`docs/strands/writes.md` → "Waiting for the party's own machines"). Empty for a strand not tracked
|
|
982
1074
|
* or not running here, and on a launch that tracks no party machines.
|
|
983
1075
|
*/
|
|
984
1076
|
unreachedPartyMachines(strandId) {
|
|
@@ -1020,22 +1112,31 @@ export class StrandInstanceManager {
|
|
|
1020
1112
|
await gate.database.close();
|
|
1021
1113
|
}
|
|
1022
1114
|
/**
|
|
1023
|
-
* Keep a launch `'syncing'` when its database could not be built because no
|
|
1024
|
-
*
|
|
1025
|
-
* runtime already up.
|
|
1115
|
+
* Keep a launch `'syncing'` when its database could not be built because no machine that can
|
|
1116
|
+
* answer for the strand's blocks was reachable, and retry the database build every
|
|
1117
|
+
* {@link UNREACHABLE_JOIN_RETRY_MS} on the runtime already up. Which launches reach here and
|
|
1118
|
+
* why waiting beats refusing: `docs/strands/lifecycle.md` → "A launch with nobody to answer
|
|
1119
|
+
* waits". What makes each of them unable to build:
|
|
1120
|
+
*
|
|
1121
|
+
* - **A joining storage replica whose seed is silent.** Optimystic (since 1.11.0) will not rule
|
|
1122
|
+
* a block never-created while any of a node's `bootstrapNodes` is unheard, so a joiner alone
|
|
1123
|
+
* with an unreachable seed cannot build even the schema catalog: `strandDb.initialize()` fails
|
|
1124
|
+
* `cohort-unreachable`.
|
|
1125
|
+
* - **A founder whose cohort is unreachable.** Its membership writes run inside `initialize()`
|
|
1126
|
+
* and fail the same way. Normally a founder has no seed (no sibling runs the strand yet) and
|
|
1127
|
+
* commits alone, so this is the founder given one.
|
|
1128
|
+
* - **A client** (`roles.strandCohortMember: false`) with no serving machine reachable. Its own
|
|
1129
|
+
* cohort is empty by construction, so every block its launch touches falls through to
|
|
1130
|
+
* `findCoordinator`, which resolves nobody at all: the schema catalog it opens first, and a
|
|
1131
|
+
* client founder's membership writes. A node that serves no storage never coordinates a key,
|
|
1132
|
+
* however isolated it is, so founding alone is not open to it either.
|
|
1026
1133
|
*
|
|
1027
|
-
*
|
|
1028
|
-
* `bootstrapNodes` is unheard, so a joiner alone with an unreachable seed cannot build even
|
|
1029
|
-
* the schema catalog: `strandDb.initialize()` fails with `cohort-unreachable`. A founder
|
|
1030
|
-
* given a seed is refused the same way (normally it has none: no sibling runs the strand yet). Refusing is
|
|
1031
|
-
* right (building it alone would fork the catalog), but failing the launch would drop the
|
|
1032
|
-
* strand until the watcher relaunched it, and `addStrand` would reject with a raw Optimystic
|
|
1033
|
-
* error. Deferring gives a joiner the same contract the first-sync gate gives one that did
|
|
1134
|
+
* Deferring gives every one of them the contract the first-sync gate gives a joiner that did
|
|
1034
1135
|
* build: the strand stays tracked, {@link whenWritable} waits and rejects with the retryable
|
|
1035
|
-
* `StrandAwaitingFirstSyncError`, and the launch proceeds once a
|
|
1136
|
+
* `StrandAwaitingFirstSyncError`, and the launch proceeds once a machine answers.
|
|
1036
1137
|
*
|
|
1037
|
-
* The libp2p node, its connections and the background loops stay up meanwhile. A
|
|
1038
|
-
*
|
|
1138
|
+
* The libp2p node, its connections and the background loops stay up meanwhile. A peer can
|
|
1139
|
+
* answer just after the schema read gave up on it — on a slow link it connects and its
|
|
1039
1140
|
* peer-join backfill delivers the whole store — and the retry then builds the database, and
|
|
1040
1141
|
* runs the first-sync probe, while that peer is still connected.
|
|
1041
1142
|
*/
|
|
@@ -1052,14 +1153,15 @@ export class StrandInstanceManager {
|
|
|
1052
1153
|
* One retry scheduled by {@link deferUnreachableJoin}: the database phase again, on the
|
|
1053
1154
|
* runtime still attached. Skipped when the strand was stopped or released since — a quiesce
|
|
1054
1155
|
* releases it and the resume after rebuilds the whole runtime — or already has a database.
|
|
1055
|
-
* A failure other than an
|
|
1156
|
+
* A failure other than an unreachable machine releases the runtime and marks the strand
|
|
1056
1157
|
* `'error'`, as a failed resume does, unless it is a refusal of a claim's schema the replica
|
|
1057
1158
|
* can fall back from ({@link buildJoinDatabaseOrReplica}).
|
|
1058
1159
|
*/
|
|
1059
1160
|
async retryUnreachableJoin(instance) {
|
|
1060
1161
|
const strandId = instance.strandId;
|
|
1061
1162
|
const config = this.launchConfigs.get(strandId);
|
|
1062
|
-
// Every strand node is built by `buildStrandRuntime`, as a node
|
|
1163
|
+
// Every strand node is built by `buildStrandRuntime`, as a node carrying db-p2p's attachments
|
|
1164
|
+
// (a client's without a coordinated repo).
|
|
1063
1165
|
const node = instance.libp2pNode;
|
|
1064
1166
|
if (!config || !node || !this.isCurrentRuntime(instance, node) || instance.database
|
|
1065
1167
|
|| this.firstSyncGates.has(strandId) || this.isQuiescing(strandId)) {
|
|
@@ -1081,10 +1183,10 @@ export class StrandInstanceManager {
|
|
|
1081
1183
|
});
|
|
1082
1184
|
instance.status = 'error';
|
|
1083
1185
|
instance.error = describeThrown(error);
|
|
1084
|
-
log('Strand %s: building the database of a
|
|
1186
|
+
log('Strand %s: building the database of a launch that was waiting for a reachable machine failed: %s', strandId, instance.error);
|
|
1085
1187
|
return;
|
|
1086
1188
|
}
|
|
1087
|
-
if (build === 'awaiting-
|
|
1189
|
+
if (build === 'awaiting-peer' && this.isCurrentRuntime(instance, node) && !this.isQuiescing(strandId)) {
|
|
1088
1190
|
this.deferUnreachableJoin(instance);
|
|
1089
1191
|
}
|
|
1090
1192
|
}
|
|
@@ -1151,6 +1253,10 @@ export class StrandInstanceManager {
|
|
|
1151
1253
|
}
|
|
1152
1254
|
this.peerRedials.get(instance.strandId)?.stop();
|
|
1153
1255
|
this.peerRedials.delete(instance.strandId);
|
|
1256
|
+
// The WebRTC upgrade service before the node it dials on: its stop() also aborts the attempt
|
|
1257
|
+
// in flight, so a hibernating strand holds no ICE negotiation open.
|
|
1258
|
+
this.webrtcUpgrades.get(instance.strandId)?.stop();
|
|
1259
|
+
this.webrtcUpgrades.delete(instance.strandId);
|
|
1154
1260
|
// The party-machine tracker with the loop and gate that read it; a resume reads afresh.
|
|
1155
1261
|
this.partyMachines.get(instance.strandId)?.stop();
|
|
1156
1262
|
this.partyMachines.delete(instance.strandId);
|
|
@@ -1801,7 +1907,7 @@ export class StrandInstanceManager {
|
|
|
1801
1907
|
return 'already-attached';
|
|
1802
1908
|
}
|
|
1803
1909
|
const sAppInfo = verifiedSAppInfo(strandId, sAppConfig, options.requireSignedSchemas);
|
|
1804
|
-
await checkAppSchema(sAppConfig
|
|
1910
|
+
await checkAppSchema(sAppConfig);
|
|
1805
1911
|
// The check yielded, so a wake or another claim may have started meanwhile: wait out its build
|
|
1806
1912
|
// and read the instance and config again, or the config written below would drop what a
|
|
1807
1913
|
// resume just retained (its fresh `bootstrapNodes`).
|
|
@@ -1879,7 +1985,8 @@ export class StrandInstanceManager {
|
|
|
1879
1985
|
* Whether `strandId` is launched but still waiting for its first sync — a joiner whose
|
|
1880
1986
|
* runtime is up while its database is withheld (status `'syncing'`, or `'idle'` after
|
|
1881
1987
|
* the hibernation manager's idle timer fired on it), including one whose database build
|
|
1882
|
-
* waits for a
|
|
1988
|
+
* waits for a machine that can answer for the strand to be reachable
|
|
1989
|
+
* ({@link deferUnreachableJoin}). `false` for a writable,
|
|
1883
1990
|
* quiesced, or untracked strand. The predicate {@link whenWritable}'s callers gate on.
|
|
1884
1991
|
*/
|
|
1885
1992
|
isAwaitingFirstSync(strandId) {
|
|
@@ -1977,7 +2084,9 @@ export class StrandInstanceManager {
|
|
|
1977
2084
|
// (see the build's end in `buildStrandRuntime`).
|
|
1978
2085
|
instance.lastActivity = new Date();
|
|
1979
2086
|
instance.status = 'active';
|
|
1980
|
-
|
|
2087
|
+
// No reason given here: the gate logs what its probe found when it opens, and a database
|
|
2088
|
+
// published by a deferred build held no Header at all — it had nobody to read one from.
|
|
2089
|
+
log('Strand %s is now writable', strandId);
|
|
1981
2090
|
}
|
|
1982
2091
|
const waiters = this.writableWaiters.get(strandId);
|
|
1983
2092
|
if (waiters) {
|