@serfab/cadre-core 1.22.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 +159 -53
- package/dist/cadre-node.js +276 -89
- 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 +6 -3
- package/dist/membership-view.js.map +1 -1
- 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 +134 -42
- package/dist/strand-instance-manager.js +331 -76
- 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 +127 -57
- 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 -12252
- 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 -144
- 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 +381 -85
- 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 -3112
- package/src/webrtc-upgrade.ts +439 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The party's other machines known to
|
|
3
|
-
* for them (`docs/strands.md` → Waiting for the party's own machines).
|
|
2
|
+
* The party's other machines known to STORE one strand, and the offline queue's gate that waits
|
|
3
|
+
* for them (`docs/strands/writes.md` → Waiting for the party's own machines).
|
|
4
4
|
*
|
|
5
5
|
* Why. Optimystic's own reachability gate (`KeyNetworkCohortReachability` in db-p2p) knows only
|
|
6
6
|
* the peers this strand node has itself met and seen serve the network. A sibling of the party
|
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
* the gate answers "genuinely alone" and a queued transaction is committed by this machine
|
|
9
9
|
* alone. The party's control database knows better: every machine that runs the strand has
|
|
10
10
|
* written a `CadreControl.StrandPeer` row for it (`strand-party-peers.ts`), so the machines a
|
|
11
|
-
* queued transaction must not be committed without are the live, trusted machines
|
|
12
|
-
*
|
|
11
|
+
* queued transaction must not be committed without are the live, trusted machines whose row
|
|
12
|
+
* says they serve the strand.
|
|
13
|
+
*
|
|
14
|
+
* A client's row is read and skipped ({@link PartyStrandPeer.serves} false). A client stores no
|
|
15
|
+
* blocks and is in no cluster, so this machine can never stop being "alone in the cohort"
|
|
16
|
+
* without it, and a transaction that waited for one would wait forever. That is the only reader
|
|
17
|
+
* of the role: every other reader of the row set binds machines, and a client needs its binding
|
|
18
|
+
* like any other machine.
|
|
13
19
|
*
|
|
14
20
|
* What it does. {@link StrandPartyMachines} keeps the last good read of those machines, read
|
|
15
21
|
* through the launch's `PartyStrandPeerSource` at bring-up and again whenever the control
|
|
@@ -30,8 +36,9 @@ import { routingKeyForBlock } from '@optimystic/db-core';
|
|
|
30
36
|
import { describeThrown } from './describe-thrown.js';
|
|
31
37
|
const log = debug('sereus:cadre:strand-party-machines');
|
|
32
38
|
/**
|
|
33
|
-
* The party's other machines known to
|
|
34
|
-
* database
|
|
39
|
+
* The party's other machines known to store one strand, from the last good read of the control
|
|
40
|
+
* database — the live machines whose `StrandPeer` row says they serve it, clients dropped.
|
|
41
|
+
* Built per runtime build, before the strand's node, and stopped with the runtime.
|
|
35
42
|
*
|
|
36
43
|
* NOTE: a machine that stops running the strand but stays in the cadre (its filter changed, its
|
|
37
44
|
* app was removed, `stopStrand`) keeps its `StrandPeer` row, so it keeps counting here until it
|
|
@@ -84,7 +91,7 @@ export class StrandPartyMachines {
|
|
|
84
91
|
settled() {
|
|
85
92
|
return this.firstRead;
|
|
86
93
|
}
|
|
87
|
-
/** The last good read's live machines; empty before one. */
|
|
94
|
+
/** The last good read's live SERVING machines; empty before one. */
|
|
88
95
|
machines() {
|
|
89
96
|
return this.last;
|
|
90
97
|
}
|
|
@@ -96,7 +103,11 @@ export class StrandPartyMachines {
|
|
|
96
103
|
lastReadFailed() {
|
|
97
104
|
return this.failed;
|
|
98
105
|
}
|
|
99
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* Called only when the serving machines or the removed ids change. Returns an idempotent
|
|
108
|
+
* unsubscribe. A client's row arriving changes neither and wakes nobody, which is right: the
|
|
109
|
+
* gate's answer cannot turn on it.
|
|
110
|
+
*/
|
|
100
111
|
onChange(listener) {
|
|
101
112
|
if (this.stopped) {
|
|
102
113
|
return () => undefined;
|
|
@@ -126,12 +137,16 @@ export class StrandPartyMachines {
|
|
|
126
137
|
return;
|
|
127
138
|
}
|
|
128
139
|
this.failed = false;
|
|
129
|
-
|
|
140
|
+
// Clients out (module doc): everything downstream of `machines()` — the composed gate, the
|
|
141
|
+
// unreached-machines report, a commit's awaited machines, the redial loop's party machines —
|
|
142
|
+
// then sees serving machines only.
|
|
143
|
+
const serving = peers.live.filter((peer) => peer.serves);
|
|
144
|
+
if (this.stopped || (sameMachines(this.last, serving) && sameIds(this.lastRemoved, peers.removed))) {
|
|
130
145
|
return;
|
|
131
146
|
}
|
|
132
|
-
this.last =
|
|
147
|
+
this.last = serving;
|
|
133
148
|
this.lastRemoved = new Set(peers.removed);
|
|
134
|
-
log('strand %s: the party has %d other machine(s) holding the strand and %d removed', this.deps.label,
|
|
149
|
+
log('strand %s: the party has %d other machine(s) holding the strand and %d removed', this.deps.label, serving.length, peers.removed.length);
|
|
135
150
|
for (const { listener } of [...this.listeners]) {
|
|
136
151
|
try {
|
|
137
152
|
listener();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-party-machines.js","sourceRoot":"","sources":["../src/strand-party-machines.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"strand-party-machines.js","sourceRoot":"","sources":["../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,CAAC,QAAQ,CAAC,CAAC;YAChD,MAAM,eAAe,GAAG,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACpD,OAAO,GAAG,EAAE;gBACV,YAAY,EAAE,EAAE,CAAC;gBACjB,eAAe,EAAE,CAAC;YACpB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -5,17 +5,25 @@
|
|
|
5
5
|
* statement of its peer id in the strand), the live `CadrePeer` rows judged by this node's
|
|
6
6
|
* membership predicate, and the `CadrePeer` tombstones.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* party's
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* (`docs/strands.md` →
|
|
8
|
+
* Three readers, two of which bind and read {@link PartyStrandPeers.live} whole, clients
|
|
9
|
+
* included; only the third cares which machines serve.
|
|
10
|
+
*
|
|
11
|
+
* The closed-strand membership reconciler (`strand-membership-reconciler.ts`) binds every live
|
|
12
|
+
* sibling under the party's current member key and clears a removed machine's binding, so a
|
|
13
|
+
* sibling that was offline when the party's key changed is already bound when it returns, and a
|
|
14
|
+
* machine wrongly bound under a key is cleared. Who binds whom is stated in
|
|
15
|
+
* `docs/strands/membership.md` → Binding the party's machines. The same loop reads the party's
|
|
16
|
+
* pending key through this seam ({@link PartyStrandPeerSource.pendingKey}): while the party is
|
|
17
|
+
* moving to another key in the strand, a staged invitation is redeemed under that key rather
|
|
18
|
+
* than the current one (`docs/strands/keys.md` → Replacing the party's key).
|
|
19
|
+
*
|
|
20
|
+
* The party key rotation driver (`strand-party-key-rotation.ts`, step 3) binds the same live
|
|
21
|
+
* machines under the key the party is moving to, through `CadreNode`'s `readSiblingPeerIds`.
|
|
22
|
+
*
|
|
23
|
+
* On a node offering offline mode, `strand-party-machines.ts` reads the live machines of every
|
|
24
|
+
* strand, open or closed, and keeps the ones that SERVE the strand as the machines a queued
|
|
25
|
+
* transaction must not be committed without (`docs/strands/writes.md` → Waiting for the party's
|
|
26
|
+
* own machines).
|
|
19
27
|
*/
|
|
20
28
|
import type { OpenedPendingPartyKey } from './strand-party-key-rotation.js';
|
|
21
29
|
import type { CadreMachine, RevocationRow, StrandPeerRow } from './types.js';
|
|
@@ -38,6 +46,14 @@ export interface PartyStrandPeer {
|
|
|
38
46
|
readonly peerId: string;
|
|
39
47
|
/** Its peer id in this strand's network. */
|
|
40
48
|
readonly strandPeerId: string;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the machine stores the strand's blocks: the row's role is not `'client'`. Only the
|
|
51
|
+
* offline queue's machine tracker (`strand-party-machines.ts`) reads it, to leave a client out
|
|
52
|
+
* of the machines a queued transaction waits for. Fixed at the machine's first publish for the
|
|
53
|
+
* strand, since the row is immutable (`docs/strands/membership.md` → "Limits and accepted
|
|
54
|
+
* tradeoffs").
|
|
55
|
+
*/
|
|
56
|
+
readonly serves: boolean;
|
|
41
57
|
}
|
|
42
58
|
/** The party's machines' peer ids in one strand, as {@link partitionPartyStrandPeers} sorts them. */
|
|
43
59
|
export interface PartyStrandPeers {
|
|
@@ -45,6 +61,11 @@ export interface PartyStrandPeers {
|
|
|
45
61
|
* The party's live machines other than this one: each has a `StrandPeer` row and a live
|
|
46
62
|
* `CadrePeer` row that passes the membership predicate (`CadreMachine.trusted`, which is false
|
|
47
63
|
* for this node itself). One entry per strand peer id.
|
|
64
|
+
*
|
|
65
|
+
* Clients are in this list, with {@link PartyStrandPeer.serves} false: a closed strand's
|
|
66
|
+
* bindings must cover every machine of the party, serving or not, or a client is refused once
|
|
67
|
+
* the key it was bound under leaves (`docs/strands/membership.md` → "Binding the party's
|
|
68
|
+
* machines"). The one reader that must skip them filters on `serves` itself.
|
|
48
69
|
*/
|
|
49
70
|
live: readonly PartyStrandPeer[];
|
|
50
71
|
/**
|
|
@@ -94,8 +115,9 @@ export interface PartyStrandPeerSource {
|
|
|
94
115
|
* Sort a strand's `StrandPeer` rows into the party's live siblings and its removed machines
|
|
95
116
|
* ({@link PartyStrandPeers}). A row whose machine has a live `CadrePeer` row is a live sibling
|
|
96
117
|
* when that row passes the membership predicate and is ignored otherwise (this node's own row,
|
|
97
|
-
* or a machine this node's anchor does not trust).
|
|
98
|
-
*
|
|
99
|
-
* row
|
|
118
|
+
* or a machine this node's anchor does not trust). The row's role becomes the sibling's
|
|
119
|
+
* {@link PartyStrandPeer.serves}; no row is dropped for its role. A row whose machine has no
|
|
120
|
+
* live `CadrePeer` row is a removed machine only when a `CadrePeer` tombstone names it;
|
|
121
|
+
* otherwise the machine's row has simply not replicated here yet, and the row is ignored.
|
|
100
122
|
*/
|
|
101
123
|
export declare function partitionPartyStrandPeers(rows: readonly StrandPeerRow[], machines: readonly CadreMachine[], tombstones: readonly RevocationRow[]): PartyStrandPeers;
|
|
@@ -5,25 +5,34 @@
|
|
|
5
5
|
* statement of its peer id in the strand), the live `CadrePeer` rows judged by this node's
|
|
6
6
|
* membership predicate, and the `CadrePeer` tombstones.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* party's
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* (`docs/strands.md` →
|
|
8
|
+
* Three readers, two of which bind and read {@link PartyStrandPeers.live} whole, clients
|
|
9
|
+
* included; only the third cares which machines serve.
|
|
10
|
+
*
|
|
11
|
+
* The closed-strand membership reconciler (`strand-membership-reconciler.ts`) binds every live
|
|
12
|
+
* sibling under the party's current member key and clears a removed machine's binding, so a
|
|
13
|
+
* sibling that was offline when the party's key changed is already bound when it returns, and a
|
|
14
|
+
* machine wrongly bound under a key is cleared. Who binds whom is stated in
|
|
15
|
+
* `docs/strands/membership.md` → Binding the party's machines. The same loop reads the party's
|
|
16
|
+
* pending key through this seam ({@link PartyStrandPeerSource.pendingKey}): while the party is
|
|
17
|
+
* moving to another key in the strand, a staged invitation is redeemed under that key rather
|
|
18
|
+
* than the current one (`docs/strands/keys.md` → Replacing the party's key).
|
|
19
|
+
*
|
|
20
|
+
* The party key rotation driver (`strand-party-key-rotation.ts`, step 3) binds the same live
|
|
21
|
+
* machines under the key the party is moving to, through `CadreNode`'s `readSiblingPeerIds`.
|
|
22
|
+
*
|
|
23
|
+
* On a node offering offline mode, `strand-party-machines.ts` reads the live machines of every
|
|
24
|
+
* strand, open or closed, and keeps the ones that SERVE the strand as the machines a queued
|
|
25
|
+
* transaction must not be committed without (`docs/strands/writes.md` → Waiting for the party's
|
|
26
|
+
* own machines).
|
|
19
27
|
*/
|
|
20
28
|
/**
|
|
21
29
|
* Sort a strand's `StrandPeer` rows into the party's live siblings and its removed machines
|
|
22
30
|
* ({@link PartyStrandPeers}). A row whose machine has a live `CadrePeer` row is a live sibling
|
|
23
31
|
* when that row passes the membership predicate and is ignored otherwise (this node's own row,
|
|
24
|
-
* or a machine this node's anchor does not trust).
|
|
25
|
-
*
|
|
26
|
-
* row
|
|
32
|
+
* or a machine this node's anchor does not trust). The row's role becomes the sibling's
|
|
33
|
+
* {@link PartyStrandPeer.serves}; no row is dropped for its role. A row whose machine has no
|
|
34
|
+
* live `CadrePeer` row is a removed machine only when a `CadrePeer` tombstone names it;
|
|
35
|
+
* otherwise the machine's row has simply not replicated here yet, and the row is ignored.
|
|
27
36
|
*/
|
|
28
37
|
export function partitionPartyStrandPeers(rows, machines, tombstones) {
|
|
29
38
|
const liveMachines = new Map(machines.map((machine) => [machine.peerId, machine]));
|
|
@@ -34,7 +43,7 @@ export function partitionPartyStrandPeers(rows, machines, tombstones) {
|
|
|
34
43
|
const machine = liveMachines.get(row.peerId);
|
|
35
44
|
if (machine !== undefined) {
|
|
36
45
|
if (machine.trusted && !live.has(row.strandPeerId)) {
|
|
37
|
-
live.set(row.strandPeerId, { peerId: row.peerId, strandPeerId: row.strandPeerId });
|
|
46
|
+
live.set(row.strandPeerId, { peerId: row.peerId, strandPeerId: row.strandPeerId, serves: row.role !== 'client' });
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
else if (removedMachines.has(row.peerId)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-party-peers.js","sourceRoot":"","sources":["../src/strand-party-peers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"strand-party-peers.js","sourceRoot":"","sources":["../src/strand-party-peers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA0FH;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CACvC,IAA8B,EAC9B,QAAiC,EACjC,UAAoC;IAEpC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACnF,MAAM,eAAe,GAAG,IAAI,GAAG,CAC7B,UAAU,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,KAAK,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAC3G,CAAC;IACF,MAAM,IAAI,GAAG,IAAI,GAAG,EAA2B,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;gBACnD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC,CAAC;YACpH,CAAC;QACH,CAAC;aAAM,IAAI,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IACD,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* - no member connected and none known: likewise nothing (a founder alone, a storage replica
|
|
27
27
|
* before anyone arrives).
|
|
28
28
|
* - no member connected and some known: dial every known member at once
|
|
29
|
-
* ({@link dialPeerAddrs}, direct addresses
|
|
29
|
+
* ({@link dialPeerAddrs}, direct addresses first, then relayed, then WebRTC), each address with the
|
|
30
30
|
* relayed-dial budget. A round that connects to one goes back to watching; one that does
|
|
31
31
|
* not waits a backoff starting at that budget and doubling to
|
|
32
32
|
* {@link STRAND_REDIAL_MAX_BACKOFF_MS}.
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* - no member connected and none known: likewise nothing (a founder alone, a storage replica
|
|
27
27
|
* before anyone arrives).
|
|
28
28
|
* - no member connected and some known: dial every known member at once
|
|
29
|
-
* ({@link dialPeerAddrs}, direct addresses
|
|
29
|
+
* ({@link dialPeerAddrs}, direct addresses first, then relayed, then WebRTC), each address with the
|
|
30
30
|
* relayed-dial budget. A round that connects to one goes back to watching; one that does
|
|
31
31
|
* not waits a backoff starting at that budget and doubling to
|
|
32
32
|
* {@link STRAND_REDIAL_MAX_BACKOFF_MS}.
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
* (`NodeOptions.cohortTopic` in `@optimystic/db-p2p`): a node built with it announces every
|
|
4
4
|
* commit whose collection log tail it applied, and gives the strand's tables tagged
|
|
5
5
|
* `"optimystic.network_watch" = true` a network watch, so an app on another machine is woken
|
|
6
|
-
* by a commit instead of polling. Off unless the operator turns it on; `docs/strands.md` →
|
|
7
|
-
* "Change notifications
|
|
6
|
+
* by a commit instead of polling. Off unless the operator turns it on; `docs/strands/app-schema.md` →
|
|
7
|
+
* "Change notifications" says what turning it on costs and exposes.
|
|
8
8
|
*
|
|
9
|
-
* "Cohort topic" is Optimystic's name for the substrate and stays inside this module
|
|
10
|
-
*
|
|
9
|
+
* "Cohort topic" is Optimystic's name for the substrate and stays inside this module. Cadre
|
|
10
|
+
* splits it into two settings: `strandReactivity` turns it on, per strand, and the node's
|
|
11
|
+
* {@link ReactivityRole} says whether this machine then carries other subscribers'
|
|
12
|
+
* notifications or only receives its own (`node-roles.ts`).
|
|
11
13
|
*/
|
|
14
|
+
import { type NodeProfile } from '@optimystic/db-core';
|
|
15
|
+
import type { ReactivityRole } from './node-roles.js';
|
|
12
16
|
/** Node-local, operator-supplied; never read from the control database, a strand row, or a peer. */
|
|
13
17
|
export interface StrandReactivityConfig {
|
|
14
18
|
/** Master switch. Anything but `true` leaves every strand node exactly as before. */
|
|
@@ -17,25 +21,24 @@ export interface StrandReactivityConfig {
|
|
|
17
21
|
strandIds?: string[];
|
|
18
22
|
}
|
|
19
23
|
/**
|
|
20
|
-
* The `createLibp2pNode` options slice for one strand: `{ cohortTopic: { enabled: true } }`
|
|
21
|
-
* `config.enabled === true` and (`strandIds` is absent, an empty array, or contains
|
|
22
|
-
* exactly); otherwise `{}` — no `cohortTopic` key at all, never `{ enabled: false }`,
|
|
23
|
-
* takes its "absent" path unchanged.
|
|
24
|
+
* The `createLibp2pNode` options slice for one strand: `{ cohortTopic: { enabled: true, host } }`
|
|
25
|
+
* when `config.enabled === true` and (`strandIds` is absent, an empty array, or contains
|
|
26
|
+
* `strandId` exactly); otherwise `{}` — no `cohortTopic` key at all, never `{ enabled: false }`,
|
|
27
|
+
* so db-p2p takes its "absent" path unchanged.
|
|
24
28
|
*
|
|
25
29
|
* Fails closed on a JS embedder's mistake: an `enabled` that is not the boolean `true`, or a
|
|
26
30
|
* `strandIds` that is present but not an array, enables nothing.
|
|
27
31
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* NOTE: with no `host.profile`, db-p2p builds every host as core (forwarder-eligible, 30 s
|
|
33
|
-
* renewal), a `'transaction'` phone included — it does not follow `fretProfile`. If phone-side
|
|
34
|
-
* forwarding load shows up, pass `host: { profile: edgeProfile() }` for transaction nodes, after
|
|
35
|
-
* confirming an edge host still serves its part of a tail block's root group.
|
|
32
|
+
* The only host tuning is `profile`, from the node's {@link ReactivityRole}. Deliberately no
|
|
33
|
+
* `wantK` and no `minSigs`: a reactivity root is the tail block's storage group (`clusterSize`
|
|
34
|
+
* wide), verified at the consensus super-majority, and neither option governs it; the tiers
|
|
35
|
+
* below the root keep db-p2p's defaults.
|
|
36
36
|
*/
|
|
37
|
-
export declare function strandCohortTopicOption(config: StrandReactivityConfig | undefined, strandId: string): {
|
|
37
|
+
export declare function strandCohortTopicOption(config: StrandReactivityConfig | undefined, strandId: string, reactivity: ReactivityRole): {
|
|
38
38
|
cohortTopic?: {
|
|
39
39
|
enabled: true;
|
|
40
|
+
host: {
|
|
41
|
+
profile: NodeProfile;
|
|
42
|
+
};
|
|
40
43
|
};
|
|
41
44
|
};
|
|
@@ -3,35 +3,48 @@
|
|
|
3
3
|
* (`NodeOptions.cohortTopic` in `@optimystic/db-p2p`): a node built with it announces every
|
|
4
4
|
* commit whose collection log tail it applied, and gives the strand's tables tagged
|
|
5
5
|
* `"optimystic.network_watch" = true` a network watch, so an app on another machine is woken
|
|
6
|
-
* by a commit instead of polling. Off unless the operator turns it on; `docs/strands.md` →
|
|
7
|
-
* "Change notifications
|
|
6
|
+
* by a commit instead of polling. Off unless the operator turns it on; `docs/strands/app-schema.md` →
|
|
7
|
+
* "Change notifications" says what turning it on costs and exposes.
|
|
8
8
|
*
|
|
9
|
-
* "Cohort topic" is Optimystic's name for the substrate and stays inside this module
|
|
10
|
-
*
|
|
9
|
+
* "Cohort topic" is Optimystic's name for the substrate and stays inside this module. Cadre
|
|
10
|
+
* splits it into two settings: `strandReactivity` turns it on, per strand, and the node's
|
|
11
|
+
* {@link ReactivityRole} says whether this machine then carries other subscribers'
|
|
12
|
+
* notifications or only receives its own (`node-roles.ts`).
|
|
11
13
|
*/
|
|
14
|
+
import { coreProfile, edgeProfile } from '@optimystic/db-core';
|
|
12
15
|
/**
|
|
13
|
-
* The `createLibp2pNode` options slice for one strand: `{ cohortTopic: { enabled: true } }`
|
|
14
|
-
* `config.enabled === true` and (`strandIds` is absent, an empty array, or contains
|
|
15
|
-
* exactly); otherwise `{}` — no `cohortTopic` key at all, never `{ enabled: false }`,
|
|
16
|
-
* takes its "absent" path unchanged.
|
|
16
|
+
* The `createLibp2pNode` options slice for one strand: `{ cohortTopic: { enabled: true, host } }`
|
|
17
|
+
* when `config.enabled === true` and (`strandIds` is absent, an empty array, or contains
|
|
18
|
+
* `strandId` exactly); otherwise `{}` — no `cohortTopic` key at all, never `{ enabled: false }`,
|
|
19
|
+
* so db-p2p takes its "absent" path unchanged.
|
|
17
20
|
*
|
|
18
21
|
* Fails closed on a JS embedder's mistake: an `enabled` that is not the boolean `true`, or a
|
|
19
22
|
* `strandIds` that is present but not an array, enables nothing.
|
|
20
23
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* NOTE: with no `host.profile`, db-p2p builds every host as core (forwarder-eligible, 30 s
|
|
26
|
-
* renewal), a `'transaction'` phone included — it does not follow `fretProfile`. If phone-side
|
|
27
|
-
* forwarding load shows up, pass `host: { profile: edgeProfile() }` for transaction nodes, after
|
|
28
|
-
* confirming an edge host still serves its part of a tail block's root group.
|
|
24
|
+
* The only host tuning is `profile`, from the node's {@link ReactivityRole}. Deliberately no
|
|
25
|
+
* `wantK` and no `minSigs`: a reactivity root is the tail block's storage group (`clusterSize`
|
|
26
|
+
* wide), verified at the consensus super-majority, and neither option governs it; the tiers
|
|
27
|
+
* below the root keep db-p2p's defaults.
|
|
29
28
|
*/
|
|
30
|
-
export function strandCohortTopicOption(config, strandId) {
|
|
29
|
+
export function strandCohortTopicOption(config, strandId, reactivity) {
|
|
31
30
|
return config?.enabled === true && strandSelected(config.strandIds, strandId)
|
|
32
|
-
? { cohortTopic: { enabled: true } }
|
|
31
|
+
? { cohortTopic: { enabled: true, host: { profile: hostProfile(reactivity) } } }
|
|
33
32
|
: {};
|
|
34
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The cohort-topic node profile a reactivity role is built with. `'forwarder'` passes
|
|
36
|
+
* `coreProfile()` EXPLICITLY, which is also db-p2p's own default when no profile is given — so
|
|
37
|
+
* the forwarder path is today's behaviour by construction, not by agreement with a default.
|
|
38
|
+
*
|
|
39
|
+
* Exhaustive on purpose: a role added to {@link ReactivityRole} has to decide its profile here
|
|
40
|
+
* rather than inherit one.
|
|
41
|
+
*/
|
|
42
|
+
function hostProfile(reactivity) {
|
|
43
|
+
switch (reactivity) {
|
|
44
|
+
case 'forwarder': return coreProfile();
|
|
45
|
+
case 'subscriber': return edgeProfile();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
35
48
|
function strandSelected(strandIds, strandId) {
|
|
36
49
|
if (strandIds === undefined) {
|
|
37
50
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-reactivity.js","sourceRoot":"","sources":["../src/strand-reactivity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"strand-reactivity.js","sourceRoot":"","sources":["../src/strand-reactivity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAoB,MAAM,qBAAqB,CAAC;AAWjF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAA0C,EAC1C,QAAgB,EAChB,UAA0B;IAE1B,OAAO,MAAM,EAAE,OAAO,KAAK,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC;QAC3E,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE;QAChF,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,WAAW,CAAC,UAA0B;IAC7C,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,WAAW,CAAC,CAAC,OAAO,WAAW,EAAE,CAAC;QACvC,KAAK,YAAY,CAAC,CAAC,OAAO,WAAW,EAAE,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,SAAkB,EAAE,QAAgB;IAC1D,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -164,7 +164,7 @@ export declare const REVOCATION_REFRESH_RETRY_MS = 30000;
|
|
|
164
164
|
* How soon a strand with more distinct bound peer ids than its cluster size is
|
|
165
165
|
* refreshed again after a successful refresh. On such a strand this node may be
|
|
166
166
|
* outside a membership block's cohort, so it takes in no storage event for a
|
|
167
|
-
* removal (`docs/
|
|
167
|
+
* removal (`docs/cadre/control-convergence.md` → "Table change subscriptions").
|
|
168
168
|
*/
|
|
169
169
|
export declare const REVOCATION_WIDE_STRAND_REFRESH_MS = 30000;
|
|
170
170
|
/**
|
|
@@ -416,7 +416,7 @@ export declare class StrandRevocationEnforcer {
|
|
|
416
416
|
* the removed party's now unreachable machines and had to downsize to the
|
|
417
417
|
* live holders first. It
|
|
418
418
|
* recovers on its own, so this is a latency cost, not a defect, and it is
|
|
419
|
-
* stated for app authors in `docs/strands.md` → Removing
|
|
419
|
+
* stated for app authors in `docs/strands/membership.md` → Removing members. If it ever
|
|
420
420
|
* stops recovering — a write that never commits, or `cluster-fetch:no-quorum` —
|
|
421
421
|
* that is an upstream (Optimystic) conversation, not a workaround here.
|
|
422
422
|
*/
|
|
@@ -451,7 +451,7 @@ export type StrandRevocationJudge = Pick<StrandRevocationEnforcer, 'isRevoked'>;
|
|
|
451
451
|
* which keeps Optimystic from wasting a dial timeout on a peer this node
|
|
452
452
|
* will not talk to anyway.
|
|
453
453
|
* - `denyInboundRelayReservation`: deny iff revoked — matters when the strand
|
|
454
|
-
* node runs the relay server (the
|
|
454
|
+
* node runs the relay server (the default on a `'server'` node), where admitting
|
|
455
455
|
* the reservation would let a removed party keep using this node's
|
|
456
456
|
* forwarding capacity.
|
|
457
457
|
*
|
|
@@ -165,7 +165,7 @@ export const REVOCATION_REFRESH_RETRY_MS = 30000;
|
|
|
165
165
|
* How soon a strand with more distinct bound peer ids than its cluster size is
|
|
166
166
|
* refreshed again after a successful refresh. On such a strand this node may be
|
|
167
167
|
* outside a membership block's cohort, so it takes in no storage event for a
|
|
168
|
-
* removal (`docs/
|
|
168
|
+
* removal (`docs/cadre/control-convergence.md` → "Table change subscriptions").
|
|
169
169
|
*/
|
|
170
170
|
export const REVOCATION_WIDE_STRAND_REFRESH_MS = 30000;
|
|
171
171
|
/** Every `Strand.MemberPeer` binding — live-membered and orphaned alike. */
|
|
@@ -402,7 +402,7 @@ export class StrandRevocationEnforcer {
|
|
|
402
402
|
* the removed party's now unreachable machines and had to downsize to the
|
|
403
403
|
* live holders first. It
|
|
404
404
|
* recovers on its own, so this is a latency cost, not a defect, and it is
|
|
405
|
-
* stated for app authors in `docs/strands.md` → Removing
|
|
405
|
+
* stated for app authors in `docs/strands/membership.md` → Removing members. If it ever
|
|
406
406
|
* stops recovering — a write that never commits, or `cluster-fetch:no-quorum` —
|
|
407
407
|
* that is an upstream (Optimystic) conversation, not a workaround here.
|
|
408
408
|
*/
|
|
@@ -537,7 +537,7 @@ function deriveRevokedPeerIds(rows) {
|
|
|
537
537
|
* which keeps Optimystic from wasting a dial timeout on a peer this node
|
|
538
538
|
* will not talk to anyway.
|
|
539
539
|
* - `denyInboundRelayReservation`: deny iff revoked — matters when the strand
|
|
540
|
-
* node runs the relay server (the
|
|
540
|
+
* node runs the relay server (the default on a `'server'` node), where admitting
|
|
541
541
|
* the reservation would let a removed party keep using this node's
|
|
542
542
|
* forwarding capacity.
|
|
543
543
|
*
|
|
@@ -41,13 +41,19 @@ export declare const WAKE_PROTOCOL = "/sereus/strand-wake/1.0.0";
|
|
|
41
41
|
* inside this deadline and is not counted. In steady state those reads touch only held blocks and do not consult the
|
|
42
42
|
* cohort. If a wake or address request is seen timing out while the receiver's membership read
|
|
43
43
|
* is consulting, count one membership decision in this deadline or answer the check from the
|
|
44
|
-
* materialized authorized-peer snapshot. See docs/
|
|
45
|
-
* Optimystic's
|
|
44
|
+
* materialized authorized-peer snapshot. See docs/network/deadlines.md → "Deadlines over
|
|
45
|
+
* Optimystic's reads and commits".
|
|
46
46
|
*/
|
|
47
47
|
export declare const DEFAULT_WAKE_TIMEOUT_MS: number;
|
|
48
48
|
/**
|
|
49
|
-
* Whole attempts one {@link dialWake} call budgets for: a stale
|
|
49
|
+
* Whole attempts one {@link dialWake} call budgets for: a stale relayed address, then the
|
|
50
50
|
* direct address that works.
|
|
51
|
+
*
|
|
52
|
+
* Two RELAYED OR DIRECT attempts. {@link dialWake} moves every address that needs ICE after its
|
|
53
|
+
* relay hop behind them ({@link webrtcLast}), because such an address answers nothing for about
|
|
54
|
+
* 23 s when ICE cannot connect — so without that ordering one of these two attempts could be
|
|
55
|
+
* spent on an address nothing is waiting for, and a target whose first relay reservation has
|
|
56
|
+
* rotated would never be reached at its second relay.
|
|
51
57
|
*/
|
|
52
58
|
export declare const WAKE_DIAL_ATTEMPTS = 2;
|
|
53
59
|
/**
|
|
@@ -66,7 +72,7 @@ export declare const WAKE_DIAL_ATTEMPTS = 2;
|
|
|
66
72
|
* `DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS` in `peer-dial.ts`, though not the same
|
|
67
73
|
* count: that one is sized to fit several dead addresses ahead of a working one,
|
|
68
74
|
* while a wake target is expected to be awake and reachable on its first or second
|
|
69
|
-
* address. Two whole attempts so a reachable peer whose
|
|
75
|
+
* address. Two whole attempts so a reachable peer whose relayed address is stale
|
|
70
76
|
* still gets a genuine try at its direct one; a peer needing longer than that is
|
|
71
77
|
* not "asleep and reachable", which is the only case a wake is for. The last
|
|
72
78
|
* attempt inside the budget gets whatever remains of it, so the call returns at
|
|
@@ -190,24 +196,30 @@ export interface DialWakeOptions {
|
|
|
190
196
|
* Sender side: dial a target's control-network address(es), send a
|
|
191
197
|
* {@link WakeRequest} over `WAKE_PROTOCOL`, and return the peer's {@link WakeAck}.
|
|
192
198
|
*
|
|
193
|
-
* Tries each candidate address in order (
|
|
199
|
+
* Tries each candidate address in order (relayed first, as produced by
|
|
194
200
|
* `CadreNode.resolvePeerAddrs`) until one dials, so a NAT'd peer is reachable via
|
|
195
201
|
* its circuit-relay address. Each attempt is bounded by `timeoutMs` and the call
|
|
196
202
|
* as a whole by `budgetMs` (see {@link DEFAULT_WAKE_DIAL_BUDGET_MS}); a candidate
|
|
197
203
|
* the budget leaves no room for is reported as untried rather than silently
|
|
198
204
|
* dropped.
|
|
199
205
|
*
|
|
206
|
+
* The caller's order is kept but for one rule enforced here, at the site that owns the budget:
|
|
207
|
+
* an address that needs ICE after its relay hop goes last ({@link webrtcLast}), whatever order
|
|
208
|
+
* the caller gave. Only that rule is applied — unlike `dialPeerAddrs`, this does NOT hoist
|
|
209
|
+
* direct addresses ahead of relayed ones, because a hibernating machine is usually reachable
|
|
210
|
+
* only through its relay and its direct addresses blackhole.
|
|
211
|
+
*
|
|
200
212
|
* Throws if no address is dialable — with an error naming EVERY candidate and
|
|
201
213
|
* why it failed, not merely the last one ({@link tryAddrsInTurn}). That
|
|
202
214
|
* distinction is not cosmetic: with only the last candidate's message the
|
|
203
|
-
* failure that mattered (usually the
|
|
215
|
+
* failure that mattered (usually the relayed address, tried first) is
|
|
204
216
|
* invisible outside a debug log, and the surfaced message points at whichever
|
|
205
217
|
* address happened to be tried last.
|
|
206
218
|
*
|
|
207
219
|
* The candidate loop is deliberately explicit rather than one
|
|
208
220
|
* `dialProtocol(addrs)` call. libp2p sorts any multi-address dial with
|
|
209
221
|
* `defaultAddressSorter`, whose `circuitRelayAddressesLast` pass would demote
|
|
210
|
-
* exactly the
|
|
222
|
+
* exactly the relayed address this ordering puts first — silently inverting
|
|
211
223
|
* it, with no per-dial sorter override to opt out of. For the same reason this
|
|
212
224
|
* does not use `dialPeerAddrs`, which puts relayed addresses last.
|
|
213
225
|
*
|