@serfab/cadre-core 0.9.0 → 0.11.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 +255 -253
- package/dist/bootstrap-peer-store-file.d.ts +13 -0
- package/dist/bootstrap-peer-store-file.js +42 -0
- package/dist/bootstrap-peer-store-file.js.map +1 -0
- package/dist/bootstrap-peer-store.d.ts +73 -0
- package/dist/bootstrap-peer-store.js +128 -0
- package/dist/bootstrap-peer-store.js.map +1 -0
- package/dist/cadre-node.d.ts +1121 -81
- package/dist/cadre-node.js +2276 -262
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-authorization.d.ts +93 -0
- package/dist/control-authorization.js +57 -0
- package/dist/control-authorization.js.map +1 -0
- package/dist/control-cohort.d.ts +26 -0
- package/dist/control-cohort.js +26 -0
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +959 -54
- package/dist/control-database.js +1421 -148
- package/dist/control-database.js.map +1 -1
- package/dist/control-formation-recorder.d.ts +90 -10
- package/dist/control-formation-recorder.js +130 -14
- package/dist/control-formation-recorder.js.map +1 -1
- package/dist/control-schema.d.ts +1 -1
- package/dist/control-schema.js +651 -72
- package/dist/control-schema.js.map +1 -1
- package/dist/control-stream.d.ts +38 -4
- package/dist/control-stream.js +70 -4
- package/dist/control-stream.js.map +1 -1
- package/dist/control-write-retry.d.ts +161 -0
- package/dist/control-write-retry.js +412 -0
- package/dist/control-write-retry.js.map +1 -0
- package/dist/delegate-admission.d.ts +134 -0
- package/dist/delegate-admission.js +244 -0
- package/dist/delegate-admission.js.map +1 -0
- package/dist/device-token.d.ts +11 -11
- package/dist/device-token.js +14 -13
- package/dist/device-token.js.map +1 -1
- package/dist/ed25519-key.d.ts +26 -0
- package/dist/ed25519-key.js +56 -1
- package/dist/ed25519-key.js.map +1 -1
- package/dist/file-durable-slot.d.ts +20 -0
- package/dist/file-durable-slot.js +53 -0
- package/dist/file-durable-slot.js.map +1 -0
- package/dist/formation-approval.d.ts +157 -0
- package/dist/formation-approval.js +375 -0
- package/dist/formation-approval.js.map +1 -0
- package/dist/fs-atomic.d.ts +38 -0
- package/dist/fs-atomic.js +97 -0
- package/dist/fs-atomic.js.map +1 -0
- package/dist/identity-key.d.ts +49 -0
- package/dist/identity-key.js +81 -0
- package/dist/identity-key.js.map +1 -0
- package/dist/index.d.ts +17 -7
- package/dist/index.js +40 -6
- package/dist/index.js.map +1 -1
- package/dist/key-store-file.d.ts +2 -24
- package/dist/key-store-file.js +10 -77
- package/dist/key-store-file.js.map +1 -1
- package/dist/membership-connection-gater.d.ts +146 -0
- package/dist/membership-connection-gater.js +180 -0
- package/dist/membership-connection-gater.js.map +1 -0
- package/dist/node-local-snapshot.d.ts +109 -0
- package/dist/node-local-snapshot.js +182 -0
- package/dist/node-local-snapshot.js.map +1 -0
- package/dist/peer-addr-book.d.ts +92 -0
- package/dist/peer-addr-book.js +220 -0
- package/dist/peer-addr-book.js.map +1 -0
- package/dist/peer-authorization.d.ts +135 -18
- package/dist/peer-authorization.js +152 -21
- package/dist/peer-authorization.js.map +1 -1
- package/dist/peer-record.d.ts +21 -8
- package/dist/peer-record.js +26 -10
- package/dist/peer-record.js.map +1 -1
- package/dist/relay-addrs.d.ts +45 -0
- package/dist/relay-addrs.js +103 -0
- package/dist/relay-addrs.js.map +1 -0
- package/dist/relay-reservation.d.ts +266 -0
- package/dist/relay-reservation.js +613 -0
- package/dist/relay-reservation.js.map +1 -0
- package/dist/seed-bootstrap.d.ts +228 -56
- package/dist/seed-bootstrap.js +340 -198
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/seed-trust-policy.d.ts +47 -21
- package/dist/seed-trust-policy.js +24 -15
- package/dist/seed-trust-policy.js.map +1 -1
- package/dist/strand-addr-protocol.d.ts +42 -13
- package/dist/strand-addr-protocol.js +58 -52
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-backfill.d.ts +109 -0
- package/dist/strand-backfill.js +279 -0
- package/dist/strand-backfill.js.map +1 -0
- package/dist/strand-cohort.d.ts +4 -37
- package/dist/strand-cohort.js +4 -15
- package/dist/strand-cohort.js.map +1 -1
- package/dist/strand-database.d.ts +11 -16
- package/dist/strand-database.js +19 -7
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-formation-manager.d.ts +36 -7
- package/dist/strand-formation-manager.js +115 -15
- package/dist/strand-formation-manager.js.map +1 -1
- package/dist/strand-formation-protocol.d.ts +103 -4
- package/dist/strand-formation-protocol.js +232 -4
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +88 -19
- package/dist/strand-instance-manager.js +178 -34
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-member-registry.d.ts +5 -5
- package/dist/strand-member-registry.js +18 -10
- package/dist/strand-member-registry.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +484 -88
- package/dist/strand-membership-writer.js +751 -128
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-solicitation.d.ts +99 -33
- package/dist/strand-solicitation.js +100 -52
- package/dist/strand-solicitation.js.map +1 -1
- package/dist/strand-transport-key.d.ts +40 -0
- package/dist/strand-transport-key.js +56 -0
- package/dist/strand-transport-key.js.map +1 -0
- package/dist/strand-wake-protocol.d.ts +9 -7
- package/dist/strand-wake-protocol.js +22 -46
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/strand-watcher.d.ts +17 -2
- package/dist/strand-watcher.js +47 -3
- package/dist/strand-watcher.js.map +1 -1
- package/dist/trusted-owner-store-file.d.ts +12 -0
- package/dist/trusted-owner-store-file.js +39 -0
- package/dist/trusted-owner-store-file.js.map +1 -0
- package/dist/trusted-owner-store.d.ts +64 -0
- package/dist/trusted-owner-store.js +126 -0
- package/dist/trusted-owner-store.js.map +1 -0
- package/dist/types.d.ts +307 -44
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -1
- package/package.json +20 -8
- package/src/arachnode-stub.ts +159 -159
- package/src/bootstrap-peer-store-file.ts +44 -0
- package/src/bootstrap-peer-store.ts +172 -0
- package/src/cadre-node.ts +5158 -2981
- package/src/canonical-json.ts +30 -30
- package/src/control-authorization.ts +114 -0
- package/src/control-cohort.ts +130 -103
- package/src/control-database.ts +2406 -948
- package/src/control-formation-recorder.ts +305 -151
- package/src/control-schema.ts +651 -72
- package/src/control-stream.ts +205 -128
- package/src/control-write-retry.ts +483 -0
- package/src/delegate-admission.ts +302 -0
- package/src/device-token.ts +94 -89
- package/src/diagnostics/connection-path.ts +277 -277
- package/src/diagnostics/webrtc-turn-tracker.ts +222 -222
- package/src/ed25519-key.ts +66 -1
- package/src/enrollment.ts +199 -199
- package/src/file-durable-slot.ts +61 -0
- package/src/formation-approval.ts +604 -0
- package/src/fs-atomic.ts +107 -0
- package/src/hibernation-manager.ts +437 -437
- package/src/identity-key.ts +109 -0
- package/src/index.ts +137 -5
- package/src/key-store-file.ts +132 -203
- package/src/key-store.ts +99 -99
- package/src/membership-connection-gater.ts +204 -0
- package/src/node-local-snapshot.ts +260 -0
- package/src/peer-addr-book.ts +250 -0
- package/src/peer-authorization.ts +259 -81
- package/src/peer-record.ts +164 -146
- package/src/push-credentials.ts +84 -84
- package/src/push-node.ts +64 -64
- package/src/push-notifier-apns.ts +247 -247
- package/src/push-notifier-fcm.ts +220 -220
- package/src/push-notifier-shared.ts +28 -28
- package/src/push-notifier.ts +52 -52
- package/src/relay-addrs.ts +111 -0
- package/src/relay-reservation.ts +823 -0
- package/src/seed-bootstrap.ts +409 -209
- package/src/seed-trust-policy.ts +140 -107
- package/src/strand-addr-protocol.ts +441 -410
- package/src/strand-backfill.ts +366 -0
- package/src/strand-cohort.ts +38 -77
- package/src/strand-database.ts +202 -204
- package/src/strand-formation-manager.ts +491 -368
- package/src/strand-formation-protocol.ts +692 -391
- package/src/strand-instance-manager.ts +201 -46
- package/src/strand-member-key.ts +39 -39
- package/src/strand-member-registry.ts +182 -177
- package/src/strand-membership-writer.ts +938 -146
- package/src/strand-solicitation.ts +472 -407
- package/src/strand-transport-key.ts +58 -0
- package/src/strand-wake-payload.ts +32 -32
- package/src/strand-wake-protocol.ts +314 -331
- package/src/strand-watcher.ts +314 -251
- package/src/trusted-owner-store-file.ts +41 -0
- package/src/trusted-owner-store.ts +171 -0
- package/src/types.ts +1309 -1032
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { Libp2p, PeerId } from '@libp2p/interface';
|
|
2
|
+
import type { IPeerNetwork } from '@optimystic/db-core';
|
|
3
|
+
import { BlockTransferClient, type IRawStorage } from '@optimystic/db-p2p';
|
|
4
|
+
/**
|
|
5
|
+
* The block-transfer protocol's hard cap on one length-prefixed message. Mirrors
|
|
6
|
+
* `MAX_BLOCK_MESSAGE_BYTES` in `@optimystic/db-p2p`'s `protocol-limits.ts` (8 MiB), which
|
|
7
|
+
* that package does not re-export from its index — keep the two in sync if upstream ever
|
|
8
|
+
* changes it or starts exporting it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MAX_BLOCK_MESSAGE_BYTES: number;
|
|
11
|
+
/** Tuning for the per-peer strand catch-up. Every field optional; defaults in {@link DEFAULT_STRAND_BACKFILL}. */
|
|
12
|
+
export interface StrandBackfillConfig {
|
|
13
|
+
/** Default true. False disables the catch-up entirely (the pre-existing behaviour). */
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
/** Settle time after a connection opens before catching that peer up, ms. Default 1000. */
|
|
16
|
+
debounceMs?: number;
|
|
17
|
+
/** Ceiling on blocks copied in one catch-up. Default 10_000. Reaching it is LOGGED, never silent. */
|
|
18
|
+
maxBlocks?: number;
|
|
19
|
+
/** Soft byte budget per push message. Default 1 MiB. Protocol hard cap is {@link MAX_BLOCK_MESSAGE_BYTES} (8 MiB). */
|
|
20
|
+
maxChunkBytes?: number;
|
|
21
|
+
/** Max blocks per push message. Default 64. */
|
|
22
|
+
maxChunkBlocks?: number;
|
|
23
|
+
/** Per-push dial deadline, ms. Default 3000 (matches SpreadOnChurnMonitor). */
|
|
24
|
+
dialTimeoutMs?: number;
|
|
25
|
+
/** Per-push response deadline, ms. Default 10_000 (matches SpreadOnChurnMonitor). */
|
|
26
|
+
responseTimeoutMs?: number;
|
|
27
|
+
}
|
|
28
|
+
/** The resolved defaults every {@link StrandBackfill} starts from. */
|
|
29
|
+
export declare const DEFAULT_STRAND_BACKFILL: Required<StrandBackfillConfig>;
|
|
30
|
+
/**
|
|
31
|
+
* The one capability the catch-up needs from a transfer client. Structural (rather than
|
|
32
|
+
* the concrete `BlockTransferClient`) so unit tests can capture pushes without dialing
|
|
33
|
+
* libp2p — see {@link StrandBackfillDeps.createPushClient}.
|
|
34
|
+
*/
|
|
35
|
+
export type StrandBackfillPushClient = Pick<BlockTransferClient, 'pushBlocks'>;
|
|
36
|
+
export interface StrandBackfillDeps {
|
|
37
|
+
strandId: string;
|
|
38
|
+
/** The STRAND's libp2p node (not the control node) — source of connection events and peer ids. */
|
|
39
|
+
libp2p: Libp2p;
|
|
40
|
+
/** `node.keyNetwork`, the IPeerNetwork BlockTransferClient dials through. */
|
|
41
|
+
peerNetwork: IPeerNetwork;
|
|
42
|
+
/** This strand's own raw block store — the same instance handed to the libp2p node. */
|
|
43
|
+
storage: IRawStorage;
|
|
44
|
+
/** Must equal the prefix the receiver registered its handler under: `/optimystic/strand-<strandId>`. */
|
|
45
|
+
protocolPrefix: string;
|
|
46
|
+
/**
|
|
47
|
+
* Test seam: build the per-peer push client. Defaults to a real
|
|
48
|
+
* `BlockTransferClient` over {@link peerNetwork} + {@link protocolPrefix}.
|
|
49
|
+
*/
|
|
50
|
+
createPushClient?: (peerId: PeerId) => StrandBackfillPushClient;
|
|
51
|
+
}
|
|
52
|
+
/** What one peer's catch-up actually did. Returned for tests and logged at the end of each run. */
|
|
53
|
+
export interface StrandBackfillResult {
|
|
54
|
+
/** Blocks offered: had a committed `latest` AND materialized content locally. */
|
|
55
|
+
offered: number;
|
|
56
|
+
/** Blocks the remote reported it persisted. */
|
|
57
|
+
accepted: number;
|
|
58
|
+
/** Block ids the remote reported in `missing` (parse or persist failure on its side). */
|
|
59
|
+
rejected: string[];
|
|
60
|
+
/** Skipped: metadata has no `latest` (pending-only — not yet a durability claim here). */
|
|
61
|
+
uncommitted: number;
|
|
62
|
+
/** Skipped: `latest` exists but no materialized block is stored for that actionId. */
|
|
63
|
+
unmaterialized: number;
|
|
64
|
+
/** Not attempted because `maxBlocks` was reached. */
|
|
65
|
+
capped: number;
|
|
66
|
+
/** Skipped: a single block whose wire size alone exceeds {@link MAX_BLOCK_MESSAGE_BYTES}. */
|
|
67
|
+
oversized: string[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Copies every block in one strand's own raw store to each peer its libp2p node connects
|
|
71
|
+
* to, so a peer that joined the strand after blocks were committed still ends up holding
|
|
72
|
+
* them physically (the receiver persists each push via `saveReplicatedBlock`, which is
|
|
73
|
+
* monotonic and idempotent — crossing pushes from both ends cannot regress a revision).
|
|
74
|
+
*
|
|
75
|
+
* Best-effort throughout: nothing here throws into a libp2p event handler or into
|
|
76
|
+
* `buildStrandRuntime`; a failed chunk is logged and the run continues. A peer is marked
|
|
77
|
+
* fully caught up ONLY after a run with no thrown chunk and an empty `missing` list, so
|
|
78
|
+
* the next `connection:open` from a peer whose catch-up failed retries it.
|
|
79
|
+
*/
|
|
80
|
+
export declare class StrandBackfill {
|
|
81
|
+
private readonly deps;
|
|
82
|
+
private readonly config;
|
|
83
|
+
private readonly createPushClient;
|
|
84
|
+
private started;
|
|
85
|
+
private stopped;
|
|
86
|
+
/** Peers fully caught up this runtime (never retried until the runtime is rebuilt). */
|
|
87
|
+
private readonly done;
|
|
88
|
+
/** Peers with a catch-up currently running (suppresses concurrent duplicates). */
|
|
89
|
+
private readonly inFlight;
|
|
90
|
+
/** Pending per-peer debounce timers, cleared on stop. */
|
|
91
|
+
private readonly timers;
|
|
92
|
+
private readonly onConnectionOpen;
|
|
93
|
+
private loggedNoListBlockIds;
|
|
94
|
+
constructor(deps: StrandBackfillDeps, config?: StrandBackfillConfig);
|
|
95
|
+
/** Subscribe to connection:open AND schedule a catch-up for peers already connected. */
|
|
96
|
+
start(): void;
|
|
97
|
+
/** Unsubscribe, clear timers; in-flight runs observe the stopped flag and bail. */
|
|
98
|
+
stop(): void;
|
|
99
|
+
/** Debounced entry point for connection churn: one run per peer per settle window. */
|
|
100
|
+
private schedulePeer;
|
|
101
|
+
/**
|
|
102
|
+
* Run one peer's catch-up now, bypassing the debounce. Never rejects. Returns an
|
|
103
|
+
* all-zero result without pushing when the peer is already caught up, already being
|
|
104
|
+
* caught up, or this backfill is stopped.
|
|
105
|
+
*/
|
|
106
|
+
catchUpPeer(peerId: PeerId): Promise<StrandBackfillResult>;
|
|
107
|
+
/** The actual copy. `clean` = every chunk pushed and the remote persisted every block. */
|
|
108
|
+
private runCatchUp;
|
|
109
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { BlockTransferClient } from '@optimystic/db-p2p';
|
|
3
|
+
// NOTE: this copies the WHOLE local store to every newly connected strand peer, which is
|
|
4
|
+
// right while a strand mesh is one party's handful of machines (see docs/architecture.md →
|
|
5
|
+
// Replication cluster size, "On a strand, the machine count is not a party count"). If
|
|
6
|
+
// strand meshes ever get large, filter the pushed set by FRET cohort responsibility for
|
|
7
|
+
// each block id instead of pushing everything.
|
|
8
|
+
//
|
|
9
|
+
// NOTE: this lives in cadre-core only because `../optimystic` is read-only from this repo.
|
|
10
|
+
// If Optimystic ever grows a cohort-join catch-up of its own, delete this module rather
|
|
11
|
+
// than running two.
|
|
12
|
+
//
|
|
13
|
+
// Membership: anything connected on the strand's own libp2p network already receives
|
|
14
|
+
// cohort replicas of new commits, so pushing older blocks to it exposes nothing new. No
|
|
15
|
+
// membership gate here — adding one would diverge from what ordinary replication already
|
|
16
|
+
// does on this network. A peer that does NOT speak this strand's block-transfer protocol
|
|
17
|
+
// (a bare circuit relay or bootstrap node the strand node also connects to) cannot receive
|
|
18
|
+
// anything: the protocol id is namespaced per strand, so the dial fails and the push is
|
|
19
|
+
// dropped.
|
|
20
|
+
//
|
|
21
|
+
// NOTE: that failing case costs one dial timeout per connection:open from such a peer, and
|
|
22
|
+
// is never memoized (only clean runs are). Bounded today by the debounce plus the
|
|
23
|
+
// unreachable-peer bail in `runCatchUp` — one dial per event, not one per chunk. If a strand
|
|
24
|
+
// node ever holds many non-strand connections, or the enumeration ahead of the first chunk
|
|
25
|
+
// gets expensive, pre-check `libp2p.peerStore` for this strand's block-transfer protocol
|
|
26
|
+
// before enumerating.
|
|
27
|
+
//
|
|
28
|
+
// NOTE: a run that fails is retried only when that peer next opens a connection. Over a
|
|
29
|
+
// stable connection a transient push failure therefore leaves the peer partially copied
|
|
30
|
+
// until the next reconnect (read repair still covers reads meanwhile). If strand meshes
|
|
31
|
+
// ever hold long-lived connections where that matters, re-arm the debounce timer with a
|
|
32
|
+
// backoff on a non-clean run instead of waiting for connection:open.
|
|
33
|
+
const log = debug('sereus:cadre:strand-backfill');
|
|
34
|
+
/**
|
|
35
|
+
* The block-transfer protocol's hard cap on one length-prefixed message. Mirrors
|
|
36
|
+
* `MAX_BLOCK_MESSAGE_BYTES` in `@optimystic/db-p2p`'s `protocol-limits.ts` (8 MiB), which
|
|
37
|
+
* that package does not re-export from its index — keep the two in sync if upstream ever
|
|
38
|
+
* changes it or starts exporting it.
|
|
39
|
+
*/
|
|
40
|
+
export const MAX_BLOCK_MESSAGE_BYTES = 8 * 1024 * 1024;
|
|
41
|
+
/** The resolved defaults every {@link StrandBackfill} starts from. */
|
|
42
|
+
export const DEFAULT_STRAND_BACKFILL = {
|
|
43
|
+
enabled: true,
|
|
44
|
+
debounceMs: 1000,
|
|
45
|
+
maxBlocks: 10000,
|
|
46
|
+
maxChunkBytes: 1024 * 1024,
|
|
47
|
+
maxChunkBlocks: 64,
|
|
48
|
+
dialTimeoutMs: 3000,
|
|
49
|
+
responseTimeoutMs: 10000
|
|
50
|
+
};
|
|
51
|
+
function emptyResult() {
|
|
52
|
+
return { offered: 0, accepted: 0, rejected: [], uncommitted: 0, unmaterialized: 0, capped: 0, oversized: [] };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Base64 wire size of a raw buffer — `pushBlocks` base64-encodes each block into the JSON
|
|
56
|
+
* request, so the protocol cap must be judged against the encoded size, not the raw bytes.
|
|
57
|
+
*/
|
|
58
|
+
function base64WireBytes(rawBytes) {
|
|
59
|
+
return Math.ceil(rawBytes / 3) * 4;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Copies every block in one strand's own raw store to each peer its libp2p node connects
|
|
63
|
+
* to, so a peer that joined the strand after blocks were committed still ends up holding
|
|
64
|
+
* them physically (the receiver persists each push via `saveReplicatedBlock`, which is
|
|
65
|
+
* monotonic and idempotent — crossing pushes from both ends cannot regress a revision).
|
|
66
|
+
*
|
|
67
|
+
* Best-effort throughout: nothing here throws into a libp2p event handler or into
|
|
68
|
+
* `buildStrandRuntime`; a failed chunk is logged and the run continues. A peer is marked
|
|
69
|
+
* fully caught up ONLY after a run with no thrown chunk and an empty `missing` list, so
|
|
70
|
+
* the next `connection:open` from a peer whose catch-up failed retries it.
|
|
71
|
+
*/
|
|
72
|
+
export class StrandBackfill {
|
|
73
|
+
constructor(deps, config) {
|
|
74
|
+
this.deps = deps;
|
|
75
|
+
this.started = false;
|
|
76
|
+
this.stopped = false;
|
|
77
|
+
/** Peers fully caught up this runtime (never retried until the runtime is rebuilt). */
|
|
78
|
+
this.done = new Set();
|
|
79
|
+
/** Peers with a catch-up currently running (suppresses concurrent duplicates). */
|
|
80
|
+
this.inFlight = new Set();
|
|
81
|
+
/** Pending per-peer debounce timers, cleared on stop. */
|
|
82
|
+
this.timers = new Map();
|
|
83
|
+
this.loggedNoListBlockIds = false;
|
|
84
|
+
this.config = { ...DEFAULT_STRAND_BACKFILL, ...config };
|
|
85
|
+
this.createPushClient = deps.createPushClient
|
|
86
|
+
?? ((peerId) => new BlockTransferClient(peerId, deps.peerNetwork, deps.protocolPrefix));
|
|
87
|
+
this.onConnectionOpen = (evt) => this.schedulePeer(evt.detail.remotePeer);
|
|
88
|
+
}
|
|
89
|
+
/** Subscribe to connection:open AND schedule a catch-up for peers already connected. */
|
|
90
|
+
start() {
|
|
91
|
+
if (this.started || this.stopped || !this.config.enabled)
|
|
92
|
+
return;
|
|
93
|
+
this.started = true;
|
|
94
|
+
this.deps.libp2p.addEventListener('connection:open', this.onConnectionOpen);
|
|
95
|
+
// A runtime rebuilt over live connections (resumeStrand) never sees their
|
|
96
|
+
// connection:open, so walk what is already connected once.
|
|
97
|
+
const existing = this.deps.libp2p.getConnections();
|
|
98
|
+
for (const connection of existing) {
|
|
99
|
+
this.schedulePeer(connection.remotePeer);
|
|
100
|
+
}
|
|
101
|
+
log('[%s] started (%d peer(s) already connected)', this.deps.strandId, existing.length);
|
|
102
|
+
}
|
|
103
|
+
/** Unsubscribe, clear timers; in-flight runs observe the stopped flag and bail. */
|
|
104
|
+
stop() {
|
|
105
|
+
if (this.stopped)
|
|
106
|
+
return;
|
|
107
|
+
this.stopped = true;
|
|
108
|
+
if (this.started) {
|
|
109
|
+
this.deps.libp2p.removeEventListener('connection:open', this.onConnectionOpen);
|
|
110
|
+
}
|
|
111
|
+
for (const timer of this.timers.values()) {
|
|
112
|
+
clearTimeout(timer);
|
|
113
|
+
}
|
|
114
|
+
this.timers.clear();
|
|
115
|
+
log('[%s] stopped', this.deps.strandId);
|
|
116
|
+
}
|
|
117
|
+
/** Debounced entry point for connection churn: one run per peer per settle window. */
|
|
118
|
+
schedulePeer(peerId) {
|
|
119
|
+
const key = peerId.toString();
|
|
120
|
+
if (this.stopped || this.done.has(key) || this.inFlight.has(key))
|
|
121
|
+
return;
|
|
122
|
+
const existing = this.timers.get(key);
|
|
123
|
+
if (existing)
|
|
124
|
+
clearTimeout(existing);
|
|
125
|
+
this.timers.set(key, setTimeout(() => {
|
|
126
|
+
this.timers.delete(key);
|
|
127
|
+
void this.catchUpPeer(peerId);
|
|
128
|
+
}, this.config.debounceMs));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Run one peer's catch-up now, bypassing the debounce. Never rejects. Returns an
|
|
132
|
+
* all-zero result without pushing when the peer is already caught up, already being
|
|
133
|
+
* caught up, or this backfill is stopped.
|
|
134
|
+
*/
|
|
135
|
+
async catchUpPeer(peerId) {
|
|
136
|
+
const key = peerId.toString();
|
|
137
|
+
if (this.stopped || this.done.has(key) || this.inFlight.has(key)) {
|
|
138
|
+
return emptyResult();
|
|
139
|
+
}
|
|
140
|
+
this.inFlight.add(key);
|
|
141
|
+
try {
|
|
142
|
+
const { result, clean } = await this.runCatchUp(peerId);
|
|
143
|
+
// NOTE: a run that hit `maxBlocks` is still "clean" and still memoizes the peer, so
|
|
144
|
+
// the tail past the ceiling never reaches it. Deliberate: enumeration is not
|
|
145
|
+
// resumable, so not memoizing would re-push the same prefix on every reconnect
|
|
146
|
+
// without ever advancing. Loud in the log below (capped > 0). If a strand's store can
|
|
147
|
+
// realistically exceed maxBlocks, the fix is a resumable cursor, not either policy.
|
|
148
|
+
if (clean && !this.stopped) {
|
|
149
|
+
this.done.add(key);
|
|
150
|
+
}
|
|
151
|
+
log('[%s] catch-up peer=%s offered=%d accepted=%d rejected=%d uncommitted=%d unmaterialized=%d capped=%d oversized=%d done=%s', this.deps.strandId, key, result.offered, result.accepted, result.rejected.length, result.uncommitted, result.unmaterialized, result.capped, result.oversized.length, clean);
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
// runCatchUp already contains a per-chunk catch; this guards the enumeration and
|
|
156
|
+
// metadata reads too — a backfill fault must never surface through a libp2p event.
|
|
157
|
+
log('[%s] catch-up peer=%s failed: %o', this.deps.strandId, key, error);
|
|
158
|
+
return emptyResult();
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
this.inFlight.delete(key);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** The actual copy. `clean` = every chunk pushed and the remote persisted every block. */
|
|
165
|
+
async runCatchUp(peerId) {
|
|
166
|
+
const result = emptyResult();
|
|
167
|
+
const { storage } = this.deps;
|
|
168
|
+
if (!storage.listBlockIds) {
|
|
169
|
+
if (!this.loggedNoListBlockIds) {
|
|
170
|
+
this.loggedNoListBlockIds = true;
|
|
171
|
+
log('[%s] raw storage does not implement listBlockIds(); backfill is inert', this.deps.strandId);
|
|
172
|
+
}
|
|
173
|
+
return { result, clean: false };
|
|
174
|
+
}
|
|
175
|
+
const client = this.createPushClient(peerId);
|
|
176
|
+
const encoder = new TextEncoder();
|
|
177
|
+
let chunk = { ids: [], buffers: [], meta: {}, bytes: 0 };
|
|
178
|
+
let chunkFailed = false;
|
|
179
|
+
let anyChunkDelivered = false;
|
|
180
|
+
/**
|
|
181
|
+
* A peer that has answered no push at all, and failed one, is not reachable on this
|
|
182
|
+
* protocol — abandon rather than spend a dial timeout per remaining chunk. Once ONE
|
|
183
|
+
* push has been answered the peer demonstrably speaks it, so a later failure is a
|
|
184
|
+
* transient blip and the rest of the store is still worth pushing.
|
|
185
|
+
*/
|
|
186
|
+
const peerUnreachable = () => chunkFailed && !anyChunkDelivered;
|
|
187
|
+
const flush = async () => {
|
|
188
|
+
if (chunk.ids.length === 0)
|
|
189
|
+
return;
|
|
190
|
+
const { ids, buffers, meta } = chunk;
|
|
191
|
+
chunk = { ids: [], buffers: [], meta: {}, bytes: 0 };
|
|
192
|
+
try {
|
|
193
|
+
const response = await client.pushBlocks(ids, buffers, 'replication', meta, {
|
|
194
|
+
dialTimeoutMs: this.config.dialTimeoutMs,
|
|
195
|
+
responseTimeoutMs: this.config.responseTimeoutMs
|
|
196
|
+
});
|
|
197
|
+
anyChunkDelivered = true;
|
|
198
|
+
const missing = new Set(response.missing);
|
|
199
|
+
for (const id of ids) {
|
|
200
|
+
if (missing.has(id)) {
|
|
201
|
+
result.rejected.push(id);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
result.accepted += 1;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (response.missing.length > 0) {
|
|
208
|
+
log('[%s] peer=%s rejected %d block(s): %o', this.deps.strandId, peerId.toString(), response.missing.length, response.missing);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
chunkFailed = true;
|
|
213
|
+
log('[%s] push to peer=%s failed for %d block(s): %s', this.deps.strandId, peerId.toString(), ids.length, error.message);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
for await (const blockId of storage.listBlockIds()) {
|
|
217
|
+
if (this.stopped)
|
|
218
|
+
break;
|
|
219
|
+
if (result.offered >= this.config.maxBlocks) {
|
|
220
|
+
// Past the ceiling: count what is left (id enumeration only — no more reads or
|
|
221
|
+
// pushes) so the cap is loud in the end-of-run log rather than silent.
|
|
222
|
+
result.capped += 1;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
const metadata = await storage.getMetadata(blockId);
|
|
226
|
+
const latest = metadata?.latest;
|
|
227
|
+
if (!latest) {
|
|
228
|
+
result.uncommitted += 1;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
// NOTE: a block whose latest revision is a DELETE materializes to nothing (a
|
|
232
|
+
// tombstone), so it is skipped here — a peer that joins after such a delete never
|
|
233
|
+
// receives the tombstone from this path and relies on read repair for it. Fine
|
|
234
|
+
// while nothing deletes whole blocks pre-join; if the whole-store coverage gate in
|
|
235
|
+
// strand-membership-closed-strand-e2e ever reports a tombstone residue, teach this
|
|
236
|
+
// to push the promoted delete transform instead of skipping.
|
|
237
|
+
const block = await storage.getMaterializedBlock(blockId, latest.actionId);
|
|
238
|
+
if (!block) {
|
|
239
|
+
result.unmaterialized += 1;
|
|
240
|
+
log('[%s] block=%s has latest rev %d but no materialized content; skipped', this.deps.strandId, blockId, latest.rev);
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const buffer = encoder.encode(JSON.stringify(block));
|
|
244
|
+
// NOTE: MAX_BLOCK_MESSAGE_BYTES caps the whole framed request, not one block, and
|
|
245
|
+
// this test ignores the request envelope (ids array, blockMeta, JSON punctuation).
|
|
246
|
+
// A lone block within a few KiB of the cap therefore still ships and is rejected by
|
|
247
|
+
// the receiver's length-prefix decoder — a permanent chunk failure for that peer. No
|
|
248
|
+
// block in a strand comes close today; if one ever can, subtract a measured envelope
|
|
249
|
+
// allowance here rather than raising the cap.
|
|
250
|
+
if (base64WireBytes(buffer.length) >= MAX_BLOCK_MESSAGE_BYTES) {
|
|
251
|
+
result.oversized.push(blockId);
|
|
252
|
+
log('[%s] block=%s is %d bytes (%d on the wire) — exceeds the %d-byte protocol cap alone; skipped', this.deps.strandId, blockId, buffer.length, base64WireBytes(buffer.length), MAX_BLOCK_MESSAGE_BYTES);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
// Flush before adding when this block would overflow either budget. A single block
|
|
256
|
+
// larger than maxChunkBytes still ships — alone, in its own chunk.
|
|
257
|
+
if (chunk.ids.length > 0
|
|
258
|
+
&& (chunk.ids.length + 1 > this.config.maxChunkBlocks || chunk.bytes + buffer.length > this.config.maxChunkBytes)) {
|
|
259
|
+
await flush();
|
|
260
|
+
if (this.stopped || peerUnreachable())
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
chunk.ids.push(blockId);
|
|
264
|
+
chunk.buffers.push(buffer);
|
|
265
|
+
chunk.meta[blockId] = { rev: latest.rev, actionId: latest.actionId };
|
|
266
|
+
chunk.bytes += buffer.length;
|
|
267
|
+
result.offered += 1;
|
|
268
|
+
}
|
|
269
|
+
if (!this.stopped && !peerUnreachable()) {
|
|
270
|
+
await flush();
|
|
271
|
+
}
|
|
272
|
+
if (result.capped > 0) {
|
|
273
|
+
log('[%s] peer=%s catch-up CAPPED at %d blocks; %d block id(s) not attempted', this.deps.strandId, peerId.toString(), this.config.maxBlocks, result.capped);
|
|
274
|
+
}
|
|
275
|
+
const clean = !chunkFailed && result.rejected.length === 0;
|
|
276
|
+
return { result, clean };
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=strand-backfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strand-backfill.js","sourceRoot":"","sources":["../src/strand-backfill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,mBAAmB,EAAoB,MAAM,oBAAoB,CAAC;AAE3E,yFAAyF;AACzF,2FAA2F;AAC3F,uFAAuF;AACvF,wFAAwF;AACxF,+CAA+C;AAC/C,EAAE;AACF,2FAA2F;AAC3F,wFAAwF;AACxF,oBAAoB;AACpB,EAAE;AACF,qFAAqF;AACrF,wFAAwF;AACxF,yFAAyF;AACzF,yFAAyF;AACzF,2FAA2F;AAC3F,wFAAwF;AACxF,WAAW;AACX,EAAE;AACF,2FAA2F;AAC3F,kFAAkF;AAClF,6FAA6F;AAC7F,2FAA2F;AAC3F,yFAAyF;AACzF,sBAAsB;AACtB,EAAE;AACF,wFAAwF;AACxF,wFAAwF;AACxF,wFAAwF;AACxF,wFAAwF;AACxF,qEAAqE;AAErE,MAAM,GAAG,GAAG,KAAK,CAAC,8BAA8B,CAAC,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAoBvD,sEAAsE;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAAmC;IACrE,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,KAAM;IACjB,aAAa,EAAE,IAAI,GAAG,IAAI;IAC1B,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,KAAM;CAC1B,CAAC;AA4CF,SAAS,WAAW;IAClB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,cAAc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,CAAC;QACtB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;YACxC,MAAM,KAAK,EAAE,CAAC;QAChB,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,GAAG,CAAC,yEAAyE,EAC3E,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC;QAC3D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF"}
|
package/dist/strand-cohort.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { StrandMode } from './types.js';
|
|
2
1
|
/**
|
|
3
2
|
* A single CadrePeer membership row, as returned by
|
|
4
3
|
* `ControlDatabase.queryCadrePeers()`.
|
|
@@ -8,47 +7,15 @@ export interface CohortPeerRow {
|
|
|
8
7
|
/** Comma-joined list of multiaddr strings; `''` when no addrs were recorded. */
|
|
9
8
|
multiaddr: string | null;
|
|
10
9
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Cohort-derived discovery seed for a strand's libp2p node. `bootstrapNodes`
|
|
13
|
-
* here are **strand-network** addresses resolved on demand from co-cadre
|
|
14
|
-
* siblings (see `collectStrandAddrs` / `STRAND_ADDR_PROTOCOL`), NOT the control
|
|
15
|
-
* addresses stored in `CadrePeer.Multiaddr`.
|
|
16
|
-
*/
|
|
17
|
-
export interface CohortSeed {
|
|
18
|
-
/** Dialable strand-network multiaddr strings for cohort peers other than self (deduplicated). */
|
|
19
|
-
bootstrapNodes: string[];
|
|
20
|
-
/** True when at least one CadrePeer row other than self exists (even if it has no resolvable strand addr). */
|
|
21
|
-
hasOtherPeers: boolean;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Membership-only view of a strand's cohort, derived from the control network's
|
|
25
|
-
* CadrePeer rows. The bootstrap addresses themselves are resolved separately
|
|
26
|
-
* (over the strand-addr RPC) from these peerIds, never from the rows' addr field.
|
|
27
|
-
*/
|
|
28
|
-
export interface CohortMembers {
|
|
29
|
-
/** PeerIds of cohort members other than self — the strand-addr RPC fan-out targets (deduplicated, in row order). */
|
|
30
|
-
otherPeerIds: string[];
|
|
31
|
-
/** True when at least one CadrePeer row other than self exists (even if it has no resolvable strand addr). */
|
|
32
|
-
hasOtherPeers: boolean;
|
|
33
|
-
}
|
|
34
10
|
/**
|
|
35
11
|
* Derive the membership view of a strand's cohort from the control network's
|
|
36
|
-
* CadrePeer rows: the peerIds of members other than `selfPeerId`
|
|
37
|
-
* RPC fan-out targets
|
|
12
|
+
* CadrePeer rows: the peerIds of members other than `selfPeerId` — the
|
|
13
|
+
* strand-addr RPC fan-out targets, deduplicated, in row order.
|
|
38
14
|
*
|
|
39
15
|
* Deliberately does NOT read `CadrePeer.Multiaddr` — that field carries each
|
|
40
16
|
* node's *control*-network address, which must not seed the *strand* mesh
|
|
41
17
|
* (dialing it reaches the remote's control instance, not its strand instance).
|
|
42
18
|
* The strand-network bootstrap addresses are resolved on demand over the control
|
|
43
|
-
* mesh from these peerIds.
|
|
44
|
-
* dialability, so a cohort whose strand addrs are not yet resolvable still
|
|
45
|
-
* selects `networked` mode.
|
|
46
|
-
*/
|
|
47
|
-
export declare function deriveCohortMembers(peers: CohortPeerRow[], selfPeerId?: string): CohortMembers;
|
|
48
|
-
/**
|
|
49
|
-
* Choose the strand mode. An explicit mode (from `addStrand`) always wins. When
|
|
50
|
-
* omitted (the `handleStrandAdded` discovery path, or an `addStrand` caller that
|
|
51
|
-
* leaves it unset), infer: `bootstrap` for a solo/first node (no other peers),
|
|
52
|
-
* `networked` once the cohort has other members.
|
|
19
|
+
* mesh from these peerIds.
|
|
53
20
|
*/
|
|
54
|
-
export declare function
|
|
21
|
+
export declare function deriveCohortMembers(peers: CohortPeerRow[], selfPeerId?: string): string[];
|
package/dist/strand-cohort.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Derive the membership view of a strand's cohort from the control network's
|
|
3
|
-
* CadrePeer rows: the peerIds of members other than `selfPeerId`
|
|
4
|
-
* RPC fan-out targets
|
|
3
|
+
* CadrePeer rows: the peerIds of members other than `selfPeerId` — the
|
|
4
|
+
* strand-addr RPC fan-out targets, deduplicated, in row order.
|
|
5
5
|
*
|
|
6
6
|
* Deliberately does NOT read `CadrePeer.Multiaddr` — that field carries each
|
|
7
7
|
* node's *control*-network address, which must not seed the *strand* mesh
|
|
8
8
|
* (dialing it reaches the remote's control instance, not its strand instance).
|
|
9
9
|
* The strand-network bootstrap addresses are resolved on demand over the control
|
|
10
|
-
* mesh from these peerIds.
|
|
11
|
-
* dialability, so a cohort whose strand addrs are not yet resolvable still
|
|
12
|
-
* selects `networked` mode.
|
|
10
|
+
* mesh from these peerIds.
|
|
13
11
|
*/
|
|
14
12
|
export function deriveCohortMembers(peers, selfPeerId) {
|
|
15
13
|
const otherPeerIds = [];
|
|
@@ -24,15 +22,6 @@ export function deriveCohortMembers(peers, selfPeerId) {
|
|
|
24
22
|
seen.add(peer.peerId);
|
|
25
23
|
otherPeerIds.push(peer.peerId);
|
|
26
24
|
}
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Choose the strand mode. An explicit mode (from `addStrand`) always wins. When
|
|
31
|
-
* omitted (the `handleStrandAdded` discovery path, or an `addStrand` caller that
|
|
32
|
-
* leaves it unset), infer: `bootstrap` for a solo/first node (no other peers),
|
|
33
|
-
* `networked` once the cohort has other members.
|
|
34
|
-
*/
|
|
35
|
-
export function selectStrandMode(explicitMode, hasOtherPeers) {
|
|
36
|
-
return explicitMode ?? (hasOtherPeers ? 'networked' : 'bootstrap');
|
|
25
|
+
return otherPeerIds;
|
|
37
26
|
}
|
|
38
27
|
//# sourceMappingURL=strand-cohort.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-cohort.js","sourceRoot":"","sources":["../src/strand-cohort.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"strand-cohort.js","sourceRoot":"","sources":["../src/strand-cohort.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAsB,EAAE,UAAmB;IAC7E,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YAC3D,SAAS;QACX,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Database } from '@quereus/quereus';
|
|
2
|
+
import type { SereusPluginResult } from '@serfab/quereus-plugin-sereus';
|
|
2
3
|
import type { Libp2p } from '@libp2p/interface';
|
|
3
4
|
import type { IRepo } from '@optimystic/db-core';
|
|
4
|
-
import type {
|
|
5
|
-
import type { SAppConfig, StrandMode } from './types.js';
|
|
5
|
+
import type { SAppConfig } from './types.js';
|
|
6
6
|
export interface StrandDatabaseConfig {
|
|
7
7
|
/** The strand ID */
|
|
8
8
|
strandId: string;
|
|
@@ -12,20 +12,6 @@ export interface StrandDatabaseConfig {
|
|
|
12
12
|
libp2pNode: Libp2p;
|
|
13
13
|
/** Coordinated repo from the libp2p node */
|
|
14
14
|
coordinatedRepo: IRepo;
|
|
15
|
-
/**
|
|
16
|
-
* Lifecycle mode. `'bootstrap'` selects a purely local transactor so the strand
|
|
17
|
-
* can initialize (e.g. apply schema DDL) without network round trips on a solo
|
|
18
|
-
* node. `'networked'` (the default) uses the network transactor.
|
|
19
|
-
*/
|
|
20
|
-
mode?: StrandMode;
|
|
21
|
-
/**
|
|
22
|
-
* Raw storage backing the strand. When mode is `'bootstrap'` this is also used
|
|
23
|
-
* by the optimystic plugin's local transactor so DML lands on the host's
|
|
24
|
-
* persistent storage instead of in-memory. Must be the same instance the
|
|
25
|
-
* libp2p node was created with — sharing the instance avoids cache divergence
|
|
26
|
-
* across the two consumers.
|
|
27
|
-
*/
|
|
28
|
-
rawStorage?: IRawStorage;
|
|
29
15
|
/**
|
|
30
16
|
* Strand type (`'o'` open / `'c'` closed) from the control-network strand row.
|
|
31
17
|
* Drives the founder bootstrap: open strands get a `Header` only; closed strands
|
|
@@ -62,6 +48,7 @@ export interface StrandDatabaseConfig {
|
|
|
62
48
|
export declare class StrandDatabase {
|
|
63
49
|
private db;
|
|
64
50
|
private shutdownStrand;
|
|
51
|
+
private resolvedTransactor;
|
|
65
52
|
private readonly config;
|
|
66
53
|
private initialized;
|
|
67
54
|
constructor(config: StrandDatabaseConfig);
|
|
@@ -91,6 +78,14 @@ export declare class StrandDatabase {
|
|
|
91
78
|
* Get the underlying database for queries
|
|
92
79
|
*/
|
|
93
80
|
getDatabase(): Database;
|
|
81
|
+
/**
|
|
82
|
+
* The Optimystic transactor this strand's connection resolved to — always
|
|
83
|
+
* `'network'` here, since cadre-core passes no `transactor` option and takes
|
|
84
|
+
* the plugin's default. Exposed so a spec measuring or asserting the network
|
|
85
|
+
* path (`strand-solo-write-budget.spec.ts`) can pin the engine it ran on
|
|
86
|
+
* rather than assume it.
|
|
87
|
+
*/
|
|
88
|
+
getTransactor(): SereusPluginResult['transactor'];
|
|
94
89
|
/**
|
|
95
90
|
* Close the database and cleanup resources. Runs the strand-connection
|
|
96
91
|
* shutdown (collection-factory teardown, which also stops the injected node),
|
package/dist/strand-database.js
CHANGED
|
@@ -23,6 +23,7 @@ export class StrandDatabase {
|
|
|
23
23
|
constructor(config) {
|
|
24
24
|
this.db = null;
|
|
25
25
|
this.shutdownStrand = null;
|
|
26
|
+
this.resolvedTransactor = null;
|
|
26
27
|
this.initialized = false;
|
|
27
28
|
this.config = config;
|
|
28
29
|
}
|
|
@@ -37,28 +38,27 @@ export class StrandDatabase {
|
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
const sid = this.config.strandId;
|
|
40
|
-
|
|
41
|
-
log('Initializing StrandDatabase for strand: %s (sApp: %s v%s, mode=%s)', sid, this.config.sAppConfig.id, this.config.sAppConfig.version, mode);
|
|
41
|
+
log('Initializing StrandDatabase for strand: %s (sApp: %s v%s)', sid, this.config.sAppConfig.id, this.config.sAppConfig.version);
|
|
42
42
|
this.db = new Database();
|
|
43
43
|
// Delegate to the shared composition. The node is injected, so:
|
|
44
44
|
// - `connectToStrand` never creates a node (its `createdNode` stays null);
|
|
45
45
|
// `StrandInstanceManager` owns the node lifecycle. Its `shutdown` does
|
|
46
46
|
// still stop the injected node via the collection factory, so the
|
|
47
47
|
// manager's later `node.stop()` is an idempotent second stop;
|
|
48
|
-
// - `storage`
|
|
49
|
-
//
|
|
50
|
-
//
|
|
48
|
+
// - no `storage` is passed: the plugin consumes it only to build a local
|
|
49
|
+
// transactor's raw-storage factory or to create a node it was not given,
|
|
50
|
+
// and cadre-core always injects the node and runs the network transactor.
|
|
51
|
+
// (The plugin keeps its `storage` option for the browser entry point.)
|
|
51
52
|
const t0 = performance.now();
|
|
52
53
|
const result = await connectToStrand(this.db, {
|
|
53
54
|
strandId: sid,
|
|
54
55
|
schema: this.config.sAppConfig.schema,
|
|
55
|
-
mode,
|
|
56
|
-
storage: this.config.rawStorage,
|
|
57
56
|
libp2pNode: this.config.libp2pNode,
|
|
58
57
|
coordinatedRepo: this.config.coordinatedRepo,
|
|
59
58
|
enableCache: true,
|
|
60
59
|
});
|
|
61
60
|
this.shutdownStrand = result.shutdown;
|
|
61
|
+
this.resolvedTransactor = result.transactor;
|
|
62
62
|
timing('[strandDb:%s] connectToStrand: %dms (hydrated tables=%d, indexes=%d)', sid, Math.round(performance.now() - t0), result.hydrated?.tables ?? 0, result.hydrated?.indexes ?? 0);
|
|
63
63
|
// Founder-only: write the one-time membership bootstrap now that the schema is
|
|
64
64
|
// applied (connectToStrand has returned). A throw here propagates out of
|
|
@@ -110,6 +110,17 @@ export class StrandDatabase {
|
|
|
110
110
|
this.ensureInitialized();
|
|
111
111
|
return this.db;
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* The Optimystic transactor this strand's connection resolved to — always
|
|
115
|
+
* `'network'` here, since cadre-core passes no `transactor` option and takes
|
|
116
|
+
* the plugin's default. Exposed so a spec measuring or asserting the network
|
|
117
|
+
* path (`strand-solo-write-budget.spec.ts`) can pin the engine it ran on
|
|
118
|
+
* rather than assume it.
|
|
119
|
+
*/
|
|
120
|
+
getTransactor() {
|
|
121
|
+
this.ensureInitialized();
|
|
122
|
+
return this.resolvedTransactor;
|
|
123
|
+
}
|
|
113
124
|
/**
|
|
114
125
|
* Close the database and cleanup resources. Runs the strand-connection
|
|
115
126
|
* shutdown (collection-factory teardown, which also stops the injected node),
|
|
@@ -125,6 +136,7 @@ export class StrandDatabase {
|
|
|
125
136
|
void this.db.close();
|
|
126
137
|
this.db = null;
|
|
127
138
|
}
|
|
139
|
+
this.resolvedTransactor = null;
|
|
128
140
|
this.initialized = false;
|
|
129
141
|
log('StrandDatabase for strand %s closed', this.config.strandId);
|
|
130
142
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-database.js","sourceRoot":"","sources":["../src/strand-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAA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