@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
|
@@ -8,6 +8,7 @@ import type { StrandCommitDurability, StrandCommitHeld } from './strand-commit-d
|
|
|
8
8
|
import type { StrandOfflineConfig, StrandOfflineListeners, StrandOfflineMode } from './strand-offline.js';
|
|
9
9
|
import type { StrandAppSchemaListeners } from './strand-app-schema-report.js';
|
|
10
10
|
import { PeerJoinBackfill, type PeerJoinBackfillConfig } from './peer-join-backfill.js';
|
|
11
|
+
import { WebrtcUpgradeService } from './webrtc-upgrade.js';
|
|
11
12
|
import { strandNetworkStatePersistence, type StrandNetworkStateStore } from './strand-network-state.js';
|
|
12
13
|
import {
|
|
13
14
|
StrandRevocationEnforcer,
|
|
@@ -38,7 +39,6 @@ import type {
|
|
|
38
39
|
StorageConfig,
|
|
39
40
|
NetworkConfig,
|
|
40
41
|
LatencyHint,
|
|
41
|
-
NodeProfile,
|
|
42
42
|
SAppConfig,
|
|
43
43
|
SAppInfo,
|
|
44
44
|
RawStorageProvider,
|
|
@@ -46,21 +46,23 @@ import type {
|
|
|
46
46
|
} from './types.js';
|
|
47
47
|
import { DEFAULT_CONNECTION_MONITOR, resolveStrandClusterSize, strandClusterPolicy } from './types.js';
|
|
48
48
|
import { strandNodeAddrs } from './strand-network-config.js';
|
|
49
|
+
import { listenTransportNodeOptions } from './relay-addrs.js';
|
|
49
50
|
import { nodeTransportsOption } from './node-transports.js';
|
|
50
51
|
import { resolveRelayServer } from './relay-server.js';
|
|
52
|
+
import type { NodeRoles } from './node-roles.js';
|
|
51
53
|
import { strandCohortTopicOption, type StrandReactivityConfig } from './strand-reactivity.js';
|
|
52
54
|
import { superviseRelayReservation, type RelayReservationSupervisor } from './relay-reservation.js';
|
|
53
55
|
import { strandRedialTimings, superviseStrandPeerRedial, type StrandPeerRedial } from './strand-peer-redial.js';
|
|
54
56
|
import { groupAddrsByPeerId } from './peer-addr-book.js';
|
|
55
|
-
import { isCohortUnreachableRead } from './control-read-retry.js';
|
|
56
|
-
import { declaredCohortReadDeadlineMs, optimysticDialLimits, peerJoinPushBudget, relayReservationBudgetMs, resolveLinkRoundTripMs } from './link-budget.js';
|
|
57
|
+
import { isCohortUnreachableRead, isNoCoordinatorResolved } from './control-read-retry.js';
|
|
58
|
+
import { declaredCohortReadDeadlineMs, optimysticDialLimits, peerJoinPushBudget, relayReservationBudgetMs, resolveLinkRoundTripMs, webrtcUpgradeDialBudgetMs } from './link-budget.js';
|
|
57
59
|
import { describeThrown } from './describe-thrown.js';
|
|
58
60
|
|
|
59
61
|
const log = debug('sereus:cadre:strand-manager');
|
|
60
62
|
|
|
61
63
|
/**
|
|
62
|
-
* How often a
|
|
63
|
-
*
|
|
64
|
+
* How often a launch that could not build its database, because no machine that can answer for
|
|
65
|
+
* the strand's blocks was reachable, retries the build on its running libp2p node
|
|
64
66
|
* (`StrandInstanceManager.deferUnreachableJoin`). Each attempt composes a fresh database and
|
|
65
67
|
* re-reads the schema catalog over the network, so it is spaced well above the first-sync
|
|
66
68
|
* gate's probe cadence.
|
|
@@ -73,10 +75,15 @@ export const UNREACHABLE_JOIN_RETRY_MS = 5_000;
|
|
|
73
75
|
|
|
74
76
|
/**
|
|
75
77
|
* How one database build of a runtime ended ({@link StrandInstanceManager.buildStrandDatabase}):
|
|
76
|
-
* published or held by the first-sync gate; failed only because no
|
|
77
|
-
* or overtaken by a release of the runtime it was
|
|
78
|
+
* published or held by the first-sync gate; failed only because no machine that can answer for
|
|
79
|
+
* the strand's blocks was reachable yet; or overtaken by a release of the runtime it was
|
|
80
|
+
* building on.
|
|
81
|
+
*
|
|
82
|
+
* `'awaiting-peer'` rather than "awaiting seed": the peer a launch waits for is a seed for a
|
|
83
|
+
* joining storage replica, but for a client (`roles.strandCohortMember: false`) it is any
|
|
84
|
+
* serving machine, which it may reach by a dial rather than through a seed.
|
|
78
85
|
*/
|
|
79
|
-
type StrandDatabaseBuild = 'built' | 'awaiting-
|
|
86
|
+
type StrandDatabaseBuild = 'built' | 'awaiting-peer' | 'released';
|
|
80
87
|
|
|
81
88
|
const timing = debug('sereus:cadre:timing');
|
|
82
89
|
|
|
@@ -142,7 +149,15 @@ export interface StartStrandConfig {
|
|
|
142
149
|
sAppConfig?: SAppConfig;
|
|
143
150
|
storage?: StorageConfig;
|
|
144
151
|
network?: NetworkConfig;
|
|
145
|
-
|
|
152
|
+
/**
|
|
153
|
+
* What this node does, resolved once by the owning {@link CadreNode} (`node-roles.ts`).
|
|
154
|
+
* Retained with the launch config, so a strand woken from hibernation is rebuilt with the
|
|
155
|
+
* same roles. Read here for the FRET tier, Ring Zulu, the relay-server default, the
|
|
156
|
+
* cohort-topic host profile, and — `strandCohortMember` — whether the strand node stores
|
|
157
|
+
* the strand's blocks or is built as a client that reads and writes through the machines
|
|
158
|
+
* that do (`buildStrandRuntime`; `startStrand` resolves no store for a client).
|
|
159
|
+
*/
|
|
160
|
+
roles: NodeRoles;
|
|
146
161
|
defaultLatencyHint: LatencyHint;
|
|
147
162
|
privateKey?: PrivateKey;
|
|
148
163
|
/** Cohort-derived discovery seed (multiaddr strings). Defaults to [] when omitted. */
|
|
@@ -358,7 +373,7 @@ export interface StartStrandConfig {
|
|
|
358
373
|
onCommitHeld?: (event: StrandCommitHeld) => void;
|
|
359
374
|
|
|
360
375
|
/**
|
|
361
|
-
* Offline mode for this strand (docs/strands.md → "Offline mode"), forwarded from
|
|
376
|
+
* Offline mode for this strand (docs/strands/writes.md → "Offline mode"), forwarded from
|
|
362
377
|
* `CadreNodeConfig.strandOffline`, with where each database built for the launch reports its
|
|
363
378
|
* queue (`CadreNode` emits them as events). Absent: no database gets an offline queue. The mode
|
|
364
379
|
* itself is the manager's, per strand ({@link StrandInstanceManager.setOfflineMode}).
|
|
@@ -366,8 +381,9 @@ export interface StartStrandConfig {
|
|
|
366
381
|
offline?: StrandOfflineConfig & StrandOfflineListeners;
|
|
367
382
|
|
|
368
383
|
/**
|
|
369
|
-
* Where each database built for the launch reports an `App` schema apply it held back
|
|
370
|
-
* (`CadreNode` emits
|
|
384
|
+
* Where each database built for the launch reports an `App` schema apply it held back, and a
|
|
385
|
+
* higher App schema version another member recorded (`CadreNode` emits the first as events and
|
|
386
|
+
* stops the strand on the second). Retained and isolated like {@link onCommitDurability}.
|
|
371
387
|
*/
|
|
372
388
|
appSchema?: StrandAppSchemaListeners;
|
|
373
389
|
|
|
@@ -505,6 +521,7 @@ function verifiedSAppInfo(strandId: string, sAppConfig: SAppConfig, requireSigne
|
|
|
505
521
|
return {
|
|
506
522
|
id: sAppConfig.id,
|
|
507
523
|
version: sAppConfig.version,
|
|
524
|
+
schemaVersion: sAppConfig.schemaVersion,
|
|
508
525
|
schema: sAppConfig.schema,
|
|
509
526
|
signature: sAppConfig.signature
|
|
510
527
|
};
|
|
@@ -524,7 +541,7 @@ export class StrandInstanceManager {
|
|
|
524
541
|
/**
|
|
525
542
|
* Retained launch config per strand, captured in `startStrand` and cleared in
|
|
526
543
|
* `stopStrand`. `resumeStrand` reuses it to rebuild a quiesced strand's runtime
|
|
527
|
-
* without the caller re-threading storage/network/
|
|
544
|
+
* without the caller re-threading storage/network/node-class/key/sApp config.
|
|
528
545
|
*/
|
|
529
546
|
private launchConfigs: Map<string, StartStrandConfig> = new Map();
|
|
530
547
|
/**
|
|
@@ -590,6 +607,13 @@ export class StrandInstanceManager {
|
|
|
590
607
|
* nobody and a resume redials over the new node.
|
|
591
608
|
*/
|
|
592
609
|
private peerRedials: Map<string, StrandPeerRedial> = new Map();
|
|
610
|
+
/**
|
|
611
|
+
* The per-strand background WebRTC upgrade of relayed connections (`webrtc-upgrade.ts`), keyed
|
|
612
|
+
* by strand id. Same lifecycle as {@link peerRedials}: started in `buildStrandRuntime` once
|
|
613
|
+
* the libp2p node exists, stopped first in `releaseRuntime`, so a hibernating strand dials no
|
|
614
|
+
* upgrade and a resume judges the new node's connections with no backoff carried over.
|
|
615
|
+
*/
|
|
616
|
+
private webrtcUpgrades: Map<string, WebrtcUpgradeService> = new Map();
|
|
593
617
|
/**
|
|
594
618
|
* The party's other machines known to hold each strand (`strand-party-machines.ts`), keyed
|
|
595
619
|
* by strand id, on a node offering offline mode for a launch with a party-machine seam. Same
|
|
@@ -645,7 +669,8 @@ export class StrandInstanceManager {
|
|
|
645
669
|
private transitions: Map<string, RuntimeTransition> = new Map();
|
|
646
670
|
/**
|
|
647
671
|
* The pending database retry per strand id of a launch whose database could not be built
|
|
648
|
-
* because no
|
|
672
|
+
* because no machine that can answer for the strand's blocks was reachable yet
|
|
673
|
+
* ({@link deferUnreachableJoin}). Cleared by
|
|
649
674
|
* {@link releaseRuntime}, so a stop or a quiesce cancels it.
|
|
650
675
|
*/
|
|
651
676
|
private unreachableJoinRetries: Map<string, unknown> = new Map();
|
|
@@ -698,6 +723,11 @@ export class StrandInstanceManager {
|
|
|
698
723
|
return this.instances.has(strandId);
|
|
699
724
|
}
|
|
700
725
|
|
|
726
|
+
/** The sApp config the tracked strand's next build applies (its retained launch config's), or `undefined` for a replica or an untracked strand. */
|
|
727
|
+
launchedSAppConfig(strandId: string): SAppConfig | undefined {
|
|
728
|
+
return this.launchConfigs.get(strandId)?.sAppConfig;
|
|
729
|
+
}
|
|
730
|
+
|
|
701
731
|
/**
|
|
702
732
|
* Start a new strand instance.
|
|
703
733
|
*
|
|
@@ -753,9 +783,19 @@ export class StrandInstanceManager {
|
|
|
753
783
|
// function is provided, it is called with the strandId to create strand-specific
|
|
754
784
|
// storage (e.g. strand-isolated directories). A provider that throws therefore
|
|
755
785
|
// fails the launch alongside the schema-signature check, leaving nothing tracked.
|
|
756
|
-
|
|
786
|
+
//
|
|
787
|
+
// Never on a client (`roles.strandCohortMember: false`, built so in `buildStrandRuntime`):
|
|
788
|
+
// it stores no blocks, and the provider call itself has a side effect — a per-strand
|
|
789
|
+
// database on a phone, a per-strand directory on a node — so it is not made. Nothing is
|
|
790
|
+
// recorded in `strandStorages`, and every reader of that map (the join catch-up, the
|
|
791
|
+
// first-join test, the storage dispose) already handles the absent store.
|
|
792
|
+
const strandStorage = config.roles.strandCohortMember
|
|
793
|
+
? resolveStrandStorage(config.storage?.provider, strandId)
|
|
794
|
+
: undefined;
|
|
757
795
|
if (strandStorage) {
|
|
758
796
|
log('Strand %s using provided storage provider', strandId);
|
|
797
|
+
} else if (!config.roles.strandCohortMember) {
|
|
798
|
+
log('Strand %s runs as a client: no store is resolved, its blocks live on the serving machines', strandId);
|
|
759
799
|
}
|
|
760
800
|
|
|
761
801
|
// Determine latency hint: sApp config > default
|
|
@@ -835,15 +875,15 @@ export class StrandInstanceManager {
|
|
|
835
875
|
* Build (or rebuild) the libp2p node + StrandDatabase for an instance and
|
|
836
876
|
* attach them, transitioning it to `active`. Shared by `startStrand` (fresh
|
|
837
877
|
* launch) and `resumeStrand` (rehydrating a quiesced instance). Reads all
|
|
838
|
-
* volatile inputs (bootstrapNodes, servingMachines, network,
|
|
878
|
+
* volatile inputs (bootstrapNodes, servingMachines, network, roles,
|
|
839
879
|
* privateKey, sApp config) from `config`, so the caller controls the
|
|
840
880
|
* cohort-derived values. Storage is the
|
|
841
881
|
* one input it does NOT re-read from `config`: that belongs to the instance and
|
|
842
882
|
* comes from `strandStorages`.
|
|
843
883
|
*
|
|
844
|
-
* A database that cannot be built because no
|
|
845
|
-
* build: the runtime comes up `'syncing'` without it and the
|
|
846
|
-
* retried on the same node ({@link deferUnreachableJoin}).
|
|
884
|
+
* A database that cannot be built because no machine that can answer for the strand's blocks
|
|
885
|
+
* was reachable does not fail the build: the runtime comes up `'syncing'` without it and the
|
|
886
|
+
* database phase alone is retried on the same node ({@link deferUnreachableJoin}).
|
|
847
887
|
*/
|
|
848
888
|
private async buildStrandRuntime(instance: StrandInstance, config: StartStrandConfig): Promise<void> {
|
|
849
889
|
const strandId = instance.strandId;
|
|
@@ -854,6 +894,12 @@ export class StrandInstanceManager {
|
|
|
854
894
|
// surface later inside a path that logs and carries on. `link-budget.ts`.
|
|
855
895
|
resolveLinkRoundTripMs(config.network?.linkRoundTripMs);
|
|
856
896
|
|
|
897
|
+
// Whether this strand node stores and signs the strand's blocks, or is a CLIENT that reads
|
|
898
|
+
// and writes through the machines that do (`NodeRoles.strandCohortMember`). The one place
|
|
899
|
+
// the role is turned into a node: everything below that differs on a client follows from
|
|
900
|
+
// this binding, and `startStrand` resolved no store for one, so `strandStorage` is undefined
|
|
901
|
+
// there and `backfillArms` is false with it.
|
|
902
|
+
const servesBlocks = config.roles.strandCohortMember;
|
|
857
903
|
// The store the instance OWNS (resolved once in `startStrand`), not a fresh
|
|
858
904
|
// resolution: a rebuild must reach the same backend through the same warm cache.
|
|
859
905
|
const strandStorage = this.strandStorages.get(strandId);
|
|
@@ -871,7 +917,7 @@ export class StrandInstanceManager {
|
|
|
871
917
|
|
|
872
918
|
// Whether this node runs the circuit-relay server, and its init — the same
|
|
873
919
|
// resolution the control node takes from the same config (`relay-server.ts`).
|
|
874
|
-
const relayServer = resolveRelayServer(config.network, config.
|
|
920
|
+
const relayServer = resolveRelayServer(config.network, config.roles);
|
|
875
921
|
// The strand-node VIEW of the machine's one `NetworkConfig`, not the control
|
|
876
922
|
// node's resolution: fixed direct listen ports become ephemeral (two nodes cannot
|
|
877
923
|
// bind one port), the announce config is dropped (it names the control node's
|
|
@@ -883,8 +929,10 @@ export class StrandInstanceManager {
|
|
|
883
929
|
// `strand-network-config.ts` for all three, and `relay-reservation.ts`.
|
|
884
930
|
//
|
|
885
931
|
// `relayAddrs` is destructured OFF: it is not a `createLibp2pNode` option, and
|
|
886
|
-
// spreading it would hand db-p2p a key it does not know.
|
|
887
|
-
|
|
932
|
+
// spreading it would hand db-p2p a key it does not know. `listenTransports` is split out
|
|
933
|
+
// for the same reason — `wsPort` is db-p2p's switch but the WebRTC ICE servers beside it
|
|
934
|
+
// are read only by `network.defaultTransports` (`listenTransportNodeOptions` drops them).
|
|
935
|
+
const { relayAddrs: relayDialAddrs = [], listenAddrs, ...listenTransports } = strandNodeAddrs(config.network);
|
|
888
936
|
|
|
889
937
|
// Bound once, before anything is built — so, like the round-trip check above, a
|
|
890
938
|
// rejected clusterSize fails the build with nothing to release. The breadth is also
|
|
@@ -946,9 +994,9 @@ export class StrandInstanceManager {
|
|
|
946
994
|
? { connectionGater: config.network.connectionGater }
|
|
947
995
|
: {};
|
|
948
996
|
|
|
949
|
-
const reactivityOption = strandCohortTopicOption(config.reactivity, strandId);
|
|
997
|
+
const reactivityOption = strandCohortTopicOption(config.reactivity, strandId, config.roles.reactivity);
|
|
950
998
|
if (reactivityOption.cohortTopic) {
|
|
951
|
-
log('strand %s: change notifications on', strandId);
|
|
999
|
+
log('strand %s: change notifications on, as %s', strandId, config.roles.reactivity);
|
|
952
1000
|
}
|
|
953
1001
|
|
|
954
1002
|
// The party's other machines holding this strand, for the offline queue's gate, each commit's
|
|
@@ -982,8 +1030,16 @@ export class StrandInstanceManager {
|
|
|
982
1030
|
// sibling recorded is never read as removed. If a peer is ever seen left out of cohorts
|
|
983
1031
|
// this way, the row needs a proof that the id it states is the machine's own.
|
|
984
1032
|
...(partyMachines && { isNetworkMember: (peerId: string) => !partyMachines.removed().has(peerId) }),
|
|
1033
|
+
// A client registers none of the four storage protocol services, so every other machine
|
|
1034
|
+
// classifies it from its identify list as not serving and leaves it out of every cohort,
|
|
1035
|
+
// its own view of itself included; its reads and writes go to a coordinator among the
|
|
1036
|
+
// strand's serving machines (`../optimystic/docs/internals.md` → "Client nodes"). The
|
|
1037
|
+
// serving-only options Optimystic would ignore on a client stay off it below: `storage`
|
|
1038
|
+
// is undefined here on a client (`startStrand`), `arachnode` is behind this flag, and
|
|
1039
|
+
// `rebalance` is behind `backfillArms`, which the absent store already made false.
|
|
1040
|
+
servesBlocks,
|
|
985
1041
|
storage: strandStorage,
|
|
986
|
-
fretProfile: config.
|
|
1042
|
+
fretProfile: config.roles.overlayTier,
|
|
987
1043
|
relay: relayServer.enabled,
|
|
988
1044
|
// NOTE: unlike the control node, a strand node has no unauthorized-reservation budget,
|
|
989
1045
|
// so with the per-connection cap off any peer that reaches this node can hold one of
|
|
@@ -1008,10 +1064,15 @@ export class StrandInstanceManager {
|
|
|
1008
1064
|
servingMachines: config.servingMachines,
|
|
1009
1065
|
cohortQueryTimeoutMs: declaredCohortReadDeadlineMs(config.network)
|
|
1010
1066
|
}),
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1067
|
+
// A client builds no Arachnode at all, so the option is not stated for one.
|
|
1068
|
+
...(servesBlocks && {
|
|
1069
|
+
arachnode: {
|
|
1070
|
+
// Follows `alwaysOn`, for the control node's reason (`cadre-node.ts`): the storage
|
|
1071
|
+
// rings Ring Zulu hints at are unimplemented, so there is no second role to set.
|
|
1072
|
+
enableRingZulu: config.roles.alwaysOn
|
|
1073
|
+
}
|
|
1074
|
+
}),
|
|
1075
|
+
// One join catch-up per node. On an always-on node Optimystic's rebalance growth
|
|
1015
1076
|
// arm pushes a joiner every block whose cohort it entered, one request per block, and
|
|
1016
1077
|
// it never hears of the peer-join catch-up's pushes, so each block would go twice. The
|
|
1017
1078
|
// catch-up pushes every block to every peer it serves, the growth arm's targets
|
|
@@ -1044,7 +1105,7 @@ export class StrandInstanceManager {
|
|
|
1044
1105
|
// that fills the bare `/p2p-circuit` slots: otherwise a cohort seed running the relay
|
|
1045
1106
|
// server takes one as soon as it connects (`relay-reservation.ts`, "WHY LIBP2P'S
|
|
1046
1107
|
// RELAY DISCOVERY IS SWITCHED OFF").
|
|
1047
|
-
...nodeTransportsOption(config.network,
|
|
1108
|
+
...nodeTransportsOption(config.network, listenTransports, relayDialAddrs.length > 0),
|
|
1048
1109
|
...(config.network?.noiseCrypto && { noiseCrypto: config.network.noiseCrypto }),
|
|
1049
1110
|
// Unconditional, and the same default the control node takes: every node of
|
|
1050
1111
|
// every party runs the monitor over its connection to a slow phone, so the
|
|
@@ -1066,7 +1127,8 @@ export class StrandInstanceManager {
|
|
|
1066
1127
|
// supervisor below fills. That is what gives a NAT'd strand node a reachable relay
|
|
1067
1128
|
// slot — and works against a party-run relay because the launch path announced
|
|
1068
1129
|
// this strand's derived peerId to it first (delegate admission; see cadre-node.ts).
|
|
1069
|
-
...
|
|
1130
|
+
...(listenAddrs && { listenAddrs }),
|
|
1131
|
+
...listenTransportNodeOptions(listenTransports),
|
|
1070
1132
|
// The raw configured gater (open strands), or the revocation-composed
|
|
1071
1133
|
// gater plus the fail-closed per-stream revoked-peer gate (closed
|
|
1072
1134
|
// strands) — resolved above, before the try.
|
|
@@ -1082,7 +1144,14 @@ export class StrandInstanceManager {
|
|
|
1082
1144
|
// database (`StrandPeer`): a background write that never fails or delays the launch.
|
|
1083
1145
|
// The seam defers it while a write could fork the party and retries it on cohort
|
|
1084
1146
|
// growth and from every membership reconciler pass, so a refusal here is not final.
|
|
1085
|
-
//
|
|
1147
|
+
//
|
|
1148
|
+
// Written by EVERY machine, client or serving, and for an open strand as well as a closed
|
|
1149
|
+
// one: in a closed strand the row is how a sibling and the party key replacement bind this
|
|
1150
|
+
// machine, which a client needs as much as a server, and an open strand's row is what a
|
|
1151
|
+
// sibling's offline queue waits for (docs/strands/membership.md → "Binding the party's
|
|
1152
|
+
// machines"). Whether this machine serves is the row's role column, which
|
|
1153
|
+
// `CadreNode.publishStrandPeer` fills from the node's own role; the one reader that must
|
|
1154
|
+
// skip a client filters on it (`strand-party-machines.ts`).
|
|
1086
1155
|
if (config.partyPeers) {
|
|
1087
1156
|
void config.partyPeers.publishOwn(node.peerId.toString()).catch((error) => {
|
|
1088
1157
|
log('Strand %s: publishing this machine\'s StrandPeer row threw (retried later): %o', strandId, error);
|
|
@@ -1117,6 +1186,19 @@ export class StrandInstanceManager {
|
|
|
1117
1186
|
...(partyMachines && { partyMachines: () => partyMachines.machines().map((machine) => machine.strandPeerId) })
|
|
1118
1187
|
}, strandRedialTimings(config.network?.linkRoundTripMs)));
|
|
1119
1188
|
|
|
1189
|
+
// Try a direct WebRTC connection in the background for each member this node ends up
|
|
1190
|
+
// reaching through a relay, which on a strand is the normal case: a strand's peers are
|
|
1191
|
+
// other parties' machines, so both sides are often behind NAT. Armed here rather than
|
|
1192
|
+
// after the database phase, so a direct path can be in place by the time the first sync's
|
|
1193
|
+
// reads run. Inert unless the embedder passed a WebRTC transport (`webrtc-upgrade.ts`).
|
|
1194
|
+
const webrtcUpgrade = new WebrtcUpgradeService({
|
|
1195
|
+
label: strandId,
|
|
1196
|
+
node,
|
|
1197
|
+
dialTimeoutMs: webrtcUpgradeDialBudgetMs(config.network?.linkRoundTripMs)
|
|
1198
|
+
});
|
|
1199
|
+
this.webrtcUpgrades.set(strandId, webrtcUpgrade);
|
|
1200
|
+
webrtcUpgrade.start();
|
|
1201
|
+
|
|
1120
1202
|
const databaseBuild = await this.buildStrandDatabase(instance, config, node);
|
|
1121
1203
|
if (!this.isCurrentRuntime(instance, node)) {
|
|
1122
1204
|
// A stop released this runtime during the database phase (`stopStrand` does not
|
|
@@ -1154,6 +1236,9 @@ export class StrandInstanceManager {
|
|
|
1154
1236
|
// peer-join-backfill.ts for the strand-side argument (and why the control
|
|
1155
1237
|
// network, which DOES gate, is different).
|
|
1156
1238
|
//
|
|
1239
|
+
// Never on a client: it holds no blocks to push, and `startStrand` resolved it no store,
|
|
1240
|
+
// which is what `backfillArms` reads.
|
|
1241
|
+
//
|
|
1157
1242
|
// NOTE: cost is one PeerJoinBackfill object + one `peer:identify` listener
|
|
1158
1243
|
// per running strand — linear in strand count, negligible at the handful a
|
|
1159
1244
|
// device or host runs today. If a node ever hosts strands by the hundred,
|
|
@@ -1205,7 +1290,7 @@ export class StrandInstanceManager {
|
|
|
1205
1290
|
// No `lastActivity` stamp: bringing a runtime up is not activity. A check-in marks
|
|
1206
1291
|
// activity before its resume and must see only what landed while the strand was up.
|
|
1207
1292
|
instance.status = liveStrandStatus(instance);
|
|
1208
|
-
if (databaseBuild === 'awaiting-
|
|
1293
|
+
if (databaseBuild === 'awaiting-peer') {
|
|
1209
1294
|
// Armed only now that the build is over: a retry firing mid-build would find the
|
|
1210
1295
|
// build in flight.
|
|
1211
1296
|
this.deferUnreachableJoin(instance);
|
|
@@ -1231,10 +1316,13 @@ export class StrandInstanceManager {
|
|
|
1231
1316
|
* {@link buildStrandRuntime} and again by each {@link retryUnreachableJoin}, with a new
|
|
1232
1317
|
* StrandDatabase per attempt.
|
|
1233
1318
|
*
|
|
1234
|
-
* Returns `'awaiting-
|
|
1235
|
-
*
|
|
1236
|
-
* other failure throws, with the attempt's database left with its gate for
|
|
1319
|
+
* Returns `'awaiting-peer'` when initialize failed only because no machine that can answer for
|
|
1320
|
+
* the strand's blocks was reachable: that attempt's database is closed and the node keeps
|
|
1321
|
+
* running. Any other failure throws, with the attempt's database left with its gate for
|
|
1237
1322
|
* {@link releaseRuntime} to close.
|
|
1323
|
+
*
|
|
1324
|
+
* A client node's database (`roles.strandCohortMember: false`) is published as soon as it
|
|
1325
|
+
* initializes, like a founder's: see the first-sync decision below.
|
|
1238
1326
|
*/
|
|
1239
1327
|
private async buildStrandDatabase(
|
|
1240
1328
|
instance: StrandInstance,
|
|
@@ -1252,6 +1340,7 @@ export class StrandInstanceManager {
|
|
|
1252
1340
|
strandId,
|
|
1253
1341
|
sAppConfig: config.sAppConfig,
|
|
1254
1342
|
libp2pNode: node,
|
|
1343
|
+
// Absent on a client, which coordinates no writes; the database then connects without one.
|
|
1255
1344
|
coordinatedRepo: node.coordinatedRepo,
|
|
1256
1345
|
// Founder bootstrap inputs: the strand's type drives which membership rows
|
|
1257
1346
|
// are written, and the PARTY's own key (partyMemberPrivateKey, resolved by the
|
|
@@ -1291,14 +1380,20 @@ export class StrandInstanceManager {
|
|
|
1291
1380
|
try {
|
|
1292
1381
|
await strandDb.initialize();
|
|
1293
1382
|
} catch (error) {
|
|
1294
|
-
|
|
1383
|
+
// The two shapes of "nobody who can answer for this strand's blocks is reachable yet": a
|
|
1384
|
+
// cohort member that could not be asked (a joining replica whose seed is silent, a founder
|
|
1385
|
+
// whose cohort is), and no coordinator resolvable at all (a client, whose own cohort is
|
|
1386
|
+
// empty by construction, so every block falls through to `findCoordinator`). Any other
|
|
1387
|
+
// failure — a schema that cannot apply here, a refused signature — fails the launch, which
|
|
1388
|
+
// is what matching one error class by type each buys over reading the message.
|
|
1389
|
+
if (!isCohortUnreachableRead(error) && !isNoCoordinatorResolved(error)) {
|
|
1295
1390
|
throw error;
|
|
1296
1391
|
}
|
|
1297
1392
|
await this.discardDatabaseAttempt(strandId, gate);
|
|
1298
|
-
log('Strand %s: no
|
|
1299
|
-
'its runtime stays up and the build is retried every %dms',
|
|
1393
|
+
log('Strand %s: no machine that can answer for this strand is reachable yet, so this launch ' +
|
|
1394
|
+
'cannot build its database (%s); its runtime stays up and the build is retried every %dms',
|
|
1300
1395
|
strandId, describeThrown(error), UNREACHABLE_JOIN_RETRY_MS);
|
|
1301
|
-
return 'awaiting-
|
|
1396
|
+
return 'awaiting-peer';
|
|
1302
1397
|
}
|
|
1303
1398
|
timing('[buildStrandRuntime:%s] strandDatabase.initialize: %dms', strandId, Math.round(performance.now() - t0));
|
|
1304
1399
|
if (this.firstSyncGates.get(strandId) !== gate) {
|
|
@@ -1330,7 +1425,18 @@ export class StrandInstanceManager {
|
|
|
1330
1425
|
if (awaitPush) {
|
|
1331
1426
|
log('Strand %s: first join over an empty store; waiting for a member\'s push before the first sync probe', strandId);
|
|
1332
1427
|
}
|
|
1333
|
-
|
|
1428
|
+
// A client is treated as synced, like a founder. The gate stops a joining machine inventing a
|
|
1429
|
+
// collection while it is the whole cohort for every block; a client is in no cohort, so a
|
|
1430
|
+
// write with no serving machine reachable resolves no coordinator and fails instead of
|
|
1431
|
+
// committing locally — there is no fork to prevent. Gating it would also be wrong in itself:
|
|
1432
|
+
// its probe reads would be remote reads repeated on the backstop (it has no storage change
|
|
1433
|
+
// feed to wake it), and while the database was withheld the app could neither write nor
|
|
1434
|
+
// queue. So on a client `addStrand` resolving means the database is open, not that a member
|
|
1435
|
+
// has been reached: the first read or write fails, retryably, until a serving machine is
|
|
1436
|
+
// reachable (docs/strands/formation.md → "Joining: no writes before the first sync"). The
|
|
1437
|
+
// gate object stays as the handle `releaseRuntime` closes the database through.
|
|
1438
|
+
const client = !config.roles.strandCohortMember;
|
|
1439
|
+
const synced = config.founder === true || client || (!awaitPush && await gate.probeOnce());
|
|
1334
1440
|
timing('[buildStrandRuntime:%s] first-sync probe: %dms', strandId, Math.round(performance.now() - t0));
|
|
1335
1441
|
if (this.firstSyncGates.get(strandId) !== gate) {
|
|
1336
1442
|
// A stop released the runtime during the probe and closed this database through its gate.
|
|
@@ -1402,9 +1508,10 @@ export class StrandInstanceManager {
|
|
|
1402
1508
|
}
|
|
1403
1509
|
|
|
1404
1510
|
/**
|
|
1405
|
-
* The party's other machines known to
|
|
1511
|
+
* The party's other machines known to STORE `strandId` ({@link StrandPartyMachines.machines},
|
|
1512
|
+
* clients already dropped) with no open connection from its strand
|
|
1406
1513
|
* node: what an offline queue reporting `waitingFor: 'cohort'` may be waiting for
|
|
1407
|
-
* (`docs/strands.md` → "Waiting for the party's own machines"). Empty for a strand not tracked
|
|
1514
|
+
* (`docs/strands/writes.md` → "Waiting for the party's own machines"). Empty for a strand not tracked
|
|
1408
1515
|
* or not running here, and on a launch that tracks no party machines.
|
|
1409
1516
|
*/
|
|
1410
1517
|
unreachedPartyMachines(strandId: string): readonly PartyStrandPeer[] {
|
|
@@ -1447,22 +1554,31 @@ export class StrandInstanceManager {
|
|
|
1447
1554
|
}
|
|
1448
1555
|
|
|
1449
1556
|
/**
|
|
1450
|
-
* Keep a launch `'syncing'` when its database could not be built because no
|
|
1451
|
-
*
|
|
1452
|
-
* runtime already up.
|
|
1557
|
+
* Keep a launch `'syncing'` when its database could not be built because no machine that can
|
|
1558
|
+
* answer for the strand's blocks was reachable, and retry the database build every
|
|
1559
|
+
* {@link UNREACHABLE_JOIN_RETRY_MS} on the runtime already up. Which launches reach here and
|
|
1560
|
+
* why waiting beats refusing: `docs/strands/lifecycle.md` → "A launch with nobody to answer
|
|
1561
|
+
* waits". What makes each of them unable to build:
|
|
1562
|
+
*
|
|
1563
|
+
* - **A joining storage replica whose seed is silent.** Optimystic (since 1.11.0) will not rule
|
|
1564
|
+
* a block never-created while any of a node's `bootstrapNodes` is unheard, so a joiner alone
|
|
1565
|
+
* with an unreachable seed cannot build even the schema catalog: `strandDb.initialize()` fails
|
|
1566
|
+
* `cohort-unreachable`.
|
|
1567
|
+
* - **A founder whose cohort is unreachable.** Its membership writes run inside `initialize()`
|
|
1568
|
+
* and fail the same way. Normally a founder has no seed (no sibling runs the strand yet) and
|
|
1569
|
+
* commits alone, so this is the founder given one.
|
|
1570
|
+
* - **A client** (`roles.strandCohortMember: false`) with no serving machine reachable. Its own
|
|
1571
|
+
* cohort is empty by construction, so every block its launch touches falls through to
|
|
1572
|
+
* `findCoordinator`, which resolves nobody at all: the schema catalog it opens first, and a
|
|
1573
|
+
* client founder's membership writes. A node that serves no storage never coordinates a key,
|
|
1574
|
+
* however isolated it is, so founding alone is not open to it either.
|
|
1453
1575
|
*
|
|
1454
|
-
*
|
|
1455
|
-
* `bootstrapNodes` is unheard, so a joiner alone with an unreachable seed cannot build even
|
|
1456
|
-
* the schema catalog: `strandDb.initialize()` fails with `cohort-unreachable`. A founder
|
|
1457
|
-
* given a seed is refused the same way (normally it has none: no sibling runs the strand yet). Refusing is
|
|
1458
|
-
* right (building it alone would fork the catalog), but failing the launch would drop the
|
|
1459
|
-
* strand until the watcher relaunched it, and `addStrand` would reject with a raw Optimystic
|
|
1460
|
-
* error. Deferring gives a joiner the same contract the first-sync gate gives one that did
|
|
1576
|
+
* Deferring gives every one of them the contract the first-sync gate gives a joiner that did
|
|
1461
1577
|
* build: the strand stays tracked, {@link whenWritable} waits and rejects with the retryable
|
|
1462
|
-
* `StrandAwaitingFirstSyncError`, and the launch proceeds once a
|
|
1578
|
+
* `StrandAwaitingFirstSyncError`, and the launch proceeds once a machine answers.
|
|
1463
1579
|
*
|
|
1464
|
-
* The libp2p node, its connections and the background loops stay up meanwhile. A
|
|
1465
|
-
*
|
|
1580
|
+
* The libp2p node, its connections and the background loops stay up meanwhile. A peer can
|
|
1581
|
+
* answer just after the schema read gave up on it — on a slow link it connects and its
|
|
1466
1582
|
* peer-join backfill delivers the whole store — and the retry then builds the database, and
|
|
1467
1583
|
* runs the first-sync probe, while that peer is still connected.
|
|
1468
1584
|
*/
|
|
@@ -1480,14 +1596,15 @@ export class StrandInstanceManager {
|
|
|
1480
1596
|
* One retry scheduled by {@link deferUnreachableJoin}: the database phase again, on the
|
|
1481
1597
|
* runtime still attached. Skipped when the strand was stopped or released since — a quiesce
|
|
1482
1598
|
* releases it and the resume after rebuilds the whole runtime — or already has a database.
|
|
1483
|
-
* A failure other than an
|
|
1599
|
+
* A failure other than an unreachable machine releases the runtime and marks the strand
|
|
1484
1600
|
* `'error'`, as a failed resume does, unless it is a refusal of a claim's schema the replica
|
|
1485
1601
|
* can fall back from ({@link buildJoinDatabaseOrReplica}).
|
|
1486
1602
|
*/
|
|
1487
1603
|
private async retryUnreachableJoin(instance: StrandInstance): Promise<void> {
|
|
1488
1604
|
const strandId = instance.strandId;
|
|
1489
1605
|
const config = this.launchConfigs.get(strandId);
|
|
1490
|
-
// Every strand node is built by `buildStrandRuntime`, as a node
|
|
1606
|
+
// Every strand node is built by `buildStrandRuntime`, as a node carrying db-p2p's attachments
|
|
1607
|
+
// (a client's without a coordinated repo).
|
|
1491
1608
|
const node = instance.libp2pNode as Libp2pNodeWithRepo | undefined;
|
|
1492
1609
|
if (!config || !node || !this.isCurrentRuntime(instance, node) || instance.database
|
|
1493
1610
|
|| this.firstSyncGates.has(strandId) || this.isQuiescing(strandId)) {
|
|
@@ -1508,10 +1625,11 @@ export class StrandInstanceManager {
|
|
|
1508
1625
|
});
|
|
1509
1626
|
instance.status = 'error';
|
|
1510
1627
|
instance.error = describeThrown(error);
|
|
1511
|
-
log('Strand %s: building the database of a
|
|
1628
|
+
log('Strand %s: building the database of a launch that was waiting for a reachable machine failed: %s',
|
|
1629
|
+
strandId, instance.error);
|
|
1512
1630
|
return;
|
|
1513
1631
|
}
|
|
1514
|
-
if (build === 'awaiting-
|
|
1632
|
+
if (build === 'awaiting-peer' && this.isCurrentRuntime(instance, node) && !this.isQuiescing(strandId)) {
|
|
1515
1633
|
this.deferUnreachableJoin(instance);
|
|
1516
1634
|
}
|
|
1517
1635
|
}
|
|
@@ -1584,6 +1702,10 @@ export class StrandInstanceManager {
|
|
|
1584
1702
|
}
|
|
1585
1703
|
this.peerRedials.get(instance.strandId)?.stop();
|
|
1586
1704
|
this.peerRedials.delete(instance.strandId);
|
|
1705
|
+
// The WebRTC upgrade service before the node it dials on: its stop() also aborts the attempt
|
|
1706
|
+
// in flight, so a hibernating strand holds no ICE negotiation open.
|
|
1707
|
+
this.webrtcUpgrades.get(instance.strandId)?.stop();
|
|
1708
|
+
this.webrtcUpgrades.delete(instance.strandId);
|
|
1587
1709
|
// The party-machine tracker with the loop and gate that read it; a resume reads afresh.
|
|
1588
1710
|
this.partyMachines.get(instance.strandId)?.stop();
|
|
1589
1711
|
this.partyMachines.delete(instance.strandId);
|
|
@@ -2282,7 +2404,7 @@ export class StrandInstanceManager {
|
|
|
2282
2404
|
return 'already-attached';
|
|
2283
2405
|
}
|
|
2284
2406
|
const sAppInfo = verifiedSAppInfo(strandId, sAppConfig, options.requireSignedSchemas);
|
|
2285
|
-
await checkAppSchema(sAppConfig
|
|
2407
|
+
await checkAppSchema(sAppConfig);
|
|
2286
2408
|
// The check yielded, so a wake or another claim may have started meanwhile: wait out its build
|
|
2287
2409
|
// and read the instance and config again, or the config written below would drop what a
|
|
2288
2410
|
// resume just retained (its fresh `bootstrapNodes`).
|
|
@@ -2365,7 +2487,8 @@ export class StrandInstanceManager {
|
|
|
2365
2487
|
* Whether `strandId` is launched but still waiting for its first sync — a joiner whose
|
|
2366
2488
|
* runtime is up while its database is withheld (status `'syncing'`, or `'idle'` after
|
|
2367
2489
|
* the hibernation manager's idle timer fired on it), including one whose database build
|
|
2368
|
-
* waits for a
|
|
2490
|
+
* waits for a machine that can answer for the strand to be reachable
|
|
2491
|
+
* ({@link deferUnreachableJoin}). `false` for a writable,
|
|
2369
2492
|
* quiesced, or untracked strand. The predicate {@link whenWritable}'s callers gate on.
|
|
2370
2493
|
*/
|
|
2371
2494
|
isAwaitingFirstSync(strandId: string): boolean {
|
|
@@ -2468,7 +2591,9 @@ export class StrandInstanceManager {
|
|
|
2468
2591
|
// (see the build's end in `buildStrandRuntime`).
|
|
2469
2592
|
instance.lastActivity = new Date();
|
|
2470
2593
|
instance.status = 'active';
|
|
2471
|
-
|
|
2594
|
+
// No reason given here: the gate logs what its probe found when it opens, and a database
|
|
2595
|
+
// published by a deferred build held no Header at all — it had nobody to read one from.
|
|
2596
|
+
log('Strand %s is now writable', strandId);
|
|
2472
2597
|
}
|
|
2473
2598
|
const waiters = this.writableWaiters.get(strandId);
|
|
2474
2599
|
if (waiters) {
|