@optimystic/db-p2p 1.0.0-beta.3 → 1.1.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/dist/src/cluster/block-transfer-service.d.ts +73 -1
- package/dist/src/cluster/block-transfer-service.d.ts.map +1 -1
- package/dist/src/cluster/block-transfer-service.js +70 -3
- package/dist/src/cluster/block-transfer-service.js.map +1 -1
- package/dist/src/cluster/block-transfer.d.ts +16 -1
- package/dist/src/cluster/block-transfer.d.ts.map +1 -1
- package/dist/src/cluster/block-transfer.js +73 -72
- package/dist/src/cluster/block-transfer.js.map +1 -1
- package/dist/src/cluster/client.d.ts +4 -6
- package/dist/src/cluster/client.d.ts.map +1 -1
- package/dist/src/cluster/client.js +8 -13
- package/dist/src/cluster/client.js.map +1 -1
- package/dist/src/cluster/cluster-policy.d.ts +2 -1
- package/dist/src/cluster/cluster-policy.d.ts.map +1 -1
- package/dist/src/cluster/cluster-policy.js.map +1 -1
- package/dist/src/cluster/cluster-repo.d.ts +155 -9
- package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
- package/dist/src/cluster/cluster-repo.js +446 -58
- package/dist/src/cluster/cluster-repo.js.map +1 -1
- package/dist/src/cluster/commit-proof.js +2 -2
- package/dist/src/cluster/race-resolution.d.ts +51 -7
- package/dist/src/cluster/race-resolution.d.ts.map +1 -1
- package/dist/src/cluster/race-resolution.js +71 -7
- package/dist/src/cluster/race-resolution.js.map +1 -1
- package/dist/src/cluster/rebalance-monitor.d.ts +67 -5
- package/dist/src/cluster/rebalance-monitor.d.ts.map +1 -1
- package/dist/src/cluster/rebalance-monitor.js +120 -26
- package/dist/src/cluster/rebalance-monitor.js.map +1 -1
- package/dist/src/cluster/spread-on-churn.d.ts.map +1 -1
- package/dist/src/cluster/spread-on-churn.js +34 -47
- package/dist/src/cluster/spread-on-churn.js.map +1 -1
- package/dist/src/cohort-topic/host.d.ts.map +1 -1
- package/dist/src/cohort-topic/host.js +8 -6
- package/dist/src/cohort-topic/host.js.map +1 -1
- package/dist/src/cohort-topic/membership-source.js +1 -1
- package/dist/src/cohort-topic/membership-source.js.map +1 -1
- package/dist/src/cohort-topic/peer-codec.d.ts.map +1 -1
- package/dist/src/cohort-topic/peer-codec.js +5 -2
- package/dist/src/cohort-topic/peer-codec.js.map +1 -1
- package/dist/src/cohort-topic/stream-util.d.ts +24 -3
- package/dist/src/cohort-topic/stream-util.d.ts.map +1 -1
- package/dist/src/cohort-topic/stream-util.js +36 -3
- package/dist/src/cohort-topic/stream-util.js.map +1 -1
- package/dist/src/cohort-topic/topic-router.d.ts +9 -0
- package/dist/src/cohort-topic/topic-router.d.ts.map +1 -1
- package/dist/src/cohort-topic/topic-router.js +12 -2
- package/dist/src/cohort-topic/topic-router.js.map +1 -1
- package/dist/src/dispute/client.d.ts.map +1 -1
- package/dist/src/dispute/client.js +15 -3
- package/dist/src/dispute/client.js.map +1 -1
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/libp2p-key-network.d.ts +78 -17
- package/dist/src/libp2p-key-network.d.ts.map +1 -1
- package/dist/src/libp2p-key-network.js +234 -147
- package/dist/src/libp2p-key-network.js.map +1 -1
- package/dist/src/libp2p-node-base.d.ts +35 -1
- package/dist/src/libp2p-node-base.d.ts.map +1 -1
- package/dist/src/libp2p-node-base.js +151 -26
- package/dist/src/libp2p-node-base.js.map +1 -1
- package/dist/src/libp2p-node-rn.d.ts +2 -2
- package/dist/src/libp2p-node-rn.d.ts.map +1 -1
- package/dist/src/libp2p-node-rn.js.map +1 -1
- package/dist/src/libp2p-node.d.ts +2 -2
- package/dist/src/libp2p-node.d.ts.map +1 -1
- package/dist/src/libp2p-node.js.map +1 -1
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/logger.js +6 -1
- package/dist/src/logger.js.map +1 -1
- package/dist/src/matchmaking/query-transport.d.ts +3 -4
- package/dist/src/matchmaking/query-transport.d.ts.map +1 -1
- package/dist/src/matchmaking/query-transport.js +9 -9
- package/dist/src/matchmaking/query-transport.js.map +1 -1
- package/dist/src/network/network-manager-service.d.ts +10 -5
- package/dist/src/network/network-manager-service.d.ts.map +1 -1
- package/dist/src/network/network-manager-service.js +11 -2
- package/dist/src/network/network-manager-service.js.map +1 -1
- package/dist/src/network/relay-reservation.d.ts +170 -0
- package/dist/src/network/relay-reservation.d.ts.map +1 -0
- package/dist/src/network/relay-reservation.js +527 -0
- package/dist/src/network/relay-reservation.js.map +1 -0
- package/dist/src/pend-validation.d.ts +3 -2
- package/dist/src/pend-validation.d.ts.map +1 -1
- package/dist/src/pend-validation.js +3 -2
- package/dist/src/pend-validation.js.map +1 -1
- package/dist/src/protocol-client.d.ts +8 -1
- package/dist/src/protocol-client.d.ts.map +1 -1
- package/dist/src/protocol-client.js +11 -0
- package/dist/src/protocol-client.js.map +1 -1
- package/dist/src/reactivity/forwarder-host.d.ts +2 -1
- package/dist/src/reactivity/forwarder-host.d.ts.map +1 -1
- package/dist/src/reactivity/forwarder-host.js +2 -1
- package/dist/src/reactivity/forwarder-host.js.map +1 -1
- package/dist/src/reactivity/origination-manager.d.ts +3 -3
- package/dist/src/reactivity/origination-manager.js +3 -3
- package/dist/src/reactivity/recover-transport.d.ts +22 -14
- package/dist/src/reactivity/recover-transport.d.ts.map +1 -1
- package/dist/src/reactivity/recover-transport.js +32 -19
- package/dist/src/reactivity/recover-transport.js.map +1 -1
- package/dist/src/reactivity/subscription-manager.d.ts +2 -2
- package/dist/src/reactivity/topic-bytes.d.ts +6 -7
- package/dist/src/reactivity/topic-bytes.d.ts.map +1 -1
- package/dist/src/reactivity/topic-bytes.js +8 -9
- package/dist/src/reactivity/topic-bytes.js.map +1 -1
- package/dist/src/repo/client.d.ts +5 -2
- package/dist/src/repo/client.d.ts.map +1 -1
- package/dist/src/repo/client.js +49 -40
- package/dist/src/repo/client.js.map +1 -1
- package/dist/src/repo/cluster-coordinator.d.ts +96 -11
- package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
- package/dist/src/repo/cluster-coordinator.js +164 -25
- package/dist/src/repo/cluster-coordinator.js.map +1 -1
- package/dist/src/repo/coordinator-repo.d.ts +240 -122
- package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
- package/dist/src/repo/coordinator-repo.js +627 -473
- package/dist/src/repo/coordinator-repo.js.map +1 -1
- package/dist/src/repo/i-under-replication-ledger.d.ts +87 -0
- package/dist/src/repo/i-under-replication-ledger.d.ts.map +1 -0
- package/dist/src/repo/i-under-replication-ledger.js +2 -0
- package/dist/src/repo/i-under-replication-ledger.js.map +1 -0
- package/dist/src/repo/kv-under-replication-ledger.d.ts +91 -0
- package/dist/src/repo/kv-under-replication-ledger.d.ts.map +1 -0
- package/dist/src/repo/kv-under-replication-ledger.js +287 -0
- package/dist/src/repo/kv-under-replication-ledger.js.map +1 -0
- package/dist/src/repo/responsibility.d.ts +37 -0
- package/dist/src/repo/responsibility.d.ts.map +1 -0
- package/dist/src/repo/responsibility.js +37 -0
- package/dist/src/repo/responsibility.js.map +1 -0
- package/dist/src/repo/service.d.ts +44 -15
- package/dist/src/repo/service.d.ts.map +1 -1
- package/dist/src/repo/service.js +64 -27
- package/dist/src/repo/service.js.map +1 -1
- package/dist/src/repo/stuck-reservation.d.ts +127 -0
- package/dist/src/repo/stuck-reservation.d.ts.map +1 -0
- package/dist/src/repo/stuck-reservation.js +179 -0
- package/dist/src/repo/stuck-reservation.js.map +1 -0
- package/dist/src/repo/under-replication-drain.d.ts +208 -0
- package/dist/src/repo/under-replication-drain.d.ts.map +1 -0
- package/dist/src/repo/under-replication-drain.js +461 -0
- package/dist/src/repo/under-replication-drain.js.map +1 -0
- package/dist/src/rn.d.ts +5 -0
- package/dist/src/rn.d.ts.map +1 -1
- package/dist/src/rn.js +5 -0
- package/dist/src/rn.js.map +1 -1
- package/dist/src/storage/block-latch.d.ts +3 -2
- package/dist/src/storage/block-latch.d.ts.map +1 -1
- package/dist/src/storage/block-latch.js +7 -4
- package/dist/src/storage/block-latch.js.map +1 -1
- package/dist/src/storage/block-storage.d.ts +45 -3
- package/dist/src/storage/block-storage.d.ts.map +1 -1
- package/dist/src/storage/block-storage.js +156 -9
- package/dist/src/storage/block-storage.js.map +1 -1
- package/dist/src/storage/i-block-storage.d.ts +57 -5
- package/dist/src/storage/i-block-storage.d.ts.map +1 -1
- package/dist/src/storage/i-block-storage.js.map +1 -1
- package/dist/src/storage/pending-claim.d.ts +167 -0
- package/dist/src/storage/pending-claim.d.ts.map +1 -0
- package/dist/src/storage/pending-claim.js +156 -0
- package/dist/src/storage/pending-claim.js.map +1 -0
- package/dist/src/storage/raw-store-codec.d.ts +13 -0
- package/dist/src/storage/raw-store-codec.d.ts.map +1 -1
- package/dist/src/storage/raw-store-codec.js +24 -3
- package/dist/src/storage/raw-store-codec.js.map +1 -1
- package/dist/src/storage/restoration-coordinator.d.ts.map +1 -1
- package/dist/src/storage/restoration-coordinator.js +2 -1
- package/dist/src/storage/restoration-coordinator.js.map +1 -1
- package/dist/src/storage/ring-shift-coordinator.d.ts.map +1 -1
- package/dist/src/storage/ring-shift-coordinator.js +3 -3
- package/dist/src/storage/ring-shift-coordinator.js.map +1 -1
- package/dist/src/storage/storage-repo.d.ts +122 -5
- package/dist/src/storage/storage-repo.d.ts.map +1 -1
- package/dist/src/storage/storage-repo.js +245 -68
- package/dist/src/storage/storage-repo.js.map +1 -1
- package/dist/src/storage/struct.d.ts +58 -0
- package/dist/src/storage/struct.d.ts.map +1 -1
- package/dist/src/testing/mesh-harness.d.ts +77 -11
- package/dist/src/testing/mesh-harness.d.ts.map +1 -1
- package/dist/src/testing/mesh-harness.js +226 -100
- package/dist/src/testing/mesh-harness.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +27 -3
- package/src/cluster/block-transfer-service.ts +132 -4
- package/src/cluster/block-transfer.ts +79 -84
- package/src/cluster/client.ts +115 -119
- package/src/cluster/cluster-policy.ts +2 -1
- package/src/cluster/cluster-repo.ts +493 -65
- package/src/cluster/commit-proof.ts +2 -2
- package/src/cluster/race-resolution.ts +76 -7
- package/src/cluster/rebalance-monitor.ts +677 -539
- package/src/cluster/spread-on-churn.ts +34 -54
- package/src/cohort-topic/host.ts +8 -6
- package/src/cohort-topic/membership-source.ts +1 -1
- package/src/cohort-topic/peer-codec.ts +34 -31
- package/src/cohort-topic/stream-util.ts +39 -4
- package/src/cohort-topic/topic-router.ts +12 -2
- package/src/dispute/client.ts +17 -7
- package/src/index.ts +64 -59
- package/src/libp2p-key-network.ts +1377 -1260
- package/src/libp2p-node-base.ts +186 -27
- package/src/libp2p-node-rn.ts +31 -30
- package/src/libp2p-node.ts +37 -36
- package/src/logger.ts +6 -1
- package/src/matchmaking/query-transport.ts +9 -9
- package/src/network/network-manager-service.ts +16 -5
- package/src/network/relay-reservation.ts +636 -0
- package/src/pend-validation.ts +3 -2
- package/src/protocol-client.ts +13 -1
- package/src/reactivity/forwarder-host.ts +2 -1
- package/src/reactivity/origination-manager.ts +3 -3
- package/src/reactivity/recover-transport.ts +39 -22
- package/src/reactivity/subscription-manager.ts +2 -2
- package/src/reactivity/topic-bytes.ts +35 -37
- package/src/repo/client.ts +172 -173
- package/src/repo/cluster-coordinator.ts +183 -25
- package/src/repo/coordinator-repo.ts +656 -506
- package/src/repo/i-under-replication-ledger.ts +89 -0
- package/src/repo/kv-under-replication-ledger.ts +302 -0
- package/src/repo/responsibility.ts +48 -0
- package/src/repo/service.ts +76 -39
- package/src/repo/stuck-reservation.ts +224 -0
- package/src/repo/under-replication-drain.ts +582 -0
- package/src/rn.ts +74 -69
- package/src/storage/block-latch.ts +7 -4
- package/src/storage/block-storage.ts +161 -10
- package/src/storage/i-block-storage.ts +60 -5
- package/src/storage/pending-claim.ts +200 -0
- package/src/storage/raw-store-codec.ts +26 -3
- package/src/storage/restoration-coordinator.ts +212 -211
- package/src/storage/ring-shift-coordinator.ts +271 -271
- package/src/storage/storage-repo.ts +280 -72
- package/src/storage/struct.ts +58 -0
- package/src/testing/mesh-harness.ts +293 -112
|
@@ -10,6 +10,64 @@ export type BlockMetadata = {
|
|
|
10
10
|
ranges: RevisionRange[];
|
|
11
11
|
/** Latest revision - present if the repo is not empty */
|
|
12
12
|
latest?: ActionRev;
|
|
13
|
+
/**
|
|
14
|
+
* The lowest revision this node's content at `latest` is KNOWN to derive from: every revision
|
|
15
|
+
* record above it was produced HERE, by applying an update-only transform to the content of the
|
|
16
|
+
* revision before it. So a revision at or above the floor that the revision index names is part
|
|
17
|
+
* of what `latest` was built from, and one the index does not name is provably not.
|
|
18
|
+
*
|
|
19
|
+
* Anything that installs content this node did not derive moves the floor up to that revision,
|
|
20
|
+
* because it says nothing about what the content was built from: a replica or forward tombstone
|
|
21
|
+
* (`saveReplica`/`saveDeletion` — cohort reconcile, churn replication, invalidation), and a
|
|
22
|
+
* commit whose transform carries an `insert`, which replaces the block wholesale. The block's
|
|
23
|
+
* first commit starts the floor at its own revision.
|
|
24
|
+
*
|
|
25
|
+
* Absent on metadata written before the field existed; the next commit then starts it at the
|
|
26
|
+
* revision it built on, which claims nothing about the history below. Read through
|
|
27
|
+
* `IBlockStorage.lineageOf`, never compared by hand.
|
|
28
|
+
*/
|
|
29
|
+
lineageFloor?: number;
|
|
30
|
+
/**
|
|
31
|
+
* The revision each pending record on this block was pended AT, keyed by the record's action id —
|
|
32
|
+
* the `rev` of the `PendRequest` it belongs to. This is what turns a pending record into a
|
|
33
|
+
* *reservation for a slot* rather than a bare "someone is writing": a record the incoming writer
|
|
34
|
+
* has built on — its requested revision is past the slot, or, where the promise vote reads it, its
|
|
35
|
+
* declared base for the block is at or past the slot — is no rival (see `isReservationAgainst` in
|
|
36
|
+
* `pending-claim.ts`),
|
|
37
|
+
* and one claiming a revision this block has already committed can never be promoted here at all.
|
|
38
|
+
*
|
|
39
|
+
* Kept here, beside `latest`, rather than inside the pending record itself, because the raw
|
|
40
|
+
* drivers move a pending record into the committed store byte-for-byte on promotion (a rename on
|
|
41
|
+
* the filesystem backend), so the record's value has to stay a plain transform. The pending
|
|
42
|
+
* NAMESPACE remains the record; this map only says what slot each record claims. An entry whose
|
|
43
|
+
* record is gone is inert — every reader joins it against the namespace
|
|
44
|
+
* (`IBlockStorage.listPendingClaims`) — and is dropped when the record is deleted or when
|
|
45
|
+
* `latest` advances to or past it. A record with no entry (written before the field existed, or
|
|
46
|
+
* pended without a revision) reads as an unknown claim, which is treated as the strongest kind.
|
|
47
|
+
*/
|
|
48
|
+
pendingRevs?: Record<ActionId, number>;
|
|
49
|
+
/**
|
|
50
|
+
* The committed revision each pending record's update operations were computed against, keyed
|
|
51
|
+
* by the record's action id — the pend's `baseRevs[blockId]` (`PendRequest.baseRevs`). Absent for
|
|
52
|
+
* a record whose pend carried no base for this block (inserted, deleted, or unknown to the
|
|
53
|
+
* author) and for records written before the field existed; both read as base-unknown. Kept
|
|
54
|
+
* beside `pendingRevs`, and for the same reason: the raw drivers move a pending record into the
|
|
55
|
+
* committed store byte-for-byte on promotion, so the record's value has to stay a plain
|
|
56
|
+
* transform. Written, dropped and swept in the same metadata writes as `pendingRevs`
|
|
57
|
+
* (`BlockStorage.recordClaim`), so the two can never describe different records.
|
|
58
|
+
*
|
|
59
|
+
* A SIBLING map rather than a change to `pendingRevs`' shape, deliberately: metadata written by
|
|
60
|
+
* the release before this field must stay readable without a migration, and a record with no
|
|
61
|
+
* entry here simply reads as base-unknown. What each apply site does with an unknown base is
|
|
62
|
+
* its own rule — `StorageRepo.internalCommit` falls back to the commit's declaration and then
|
|
63
|
+
* abstains; the read-driven promotion in `StorageRepo.get` declines.
|
|
64
|
+
*
|
|
65
|
+
* NOTE: the two maps are not always co-keyed. A rev-less pend that names a base would leave an
|
|
66
|
+
* entry here and none in `pendingRevs`, which the slot-driven dead-claim sweep cannot see, so it
|
|
67
|
+
* would live until the record is deleted or promoted. Harmless, and no production caller sends a
|
|
68
|
+
* rev-less pend (see the NOTE in `StorageRepo.pend`); if one ever appears, sweep this map too.
|
|
69
|
+
*/
|
|
70
|
+
pendingBases?: Record<ActionId, number>;
|
|
13
71
|
};
|
|
14
72
|
export type ArchiveRevisions = Record<number, {
|
|
15
73
|
action: ActionTransform;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../../src/storage/struct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACnH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG;IAC3B,sBAAsB;IACtB,QAAQ,EAAE,MAAM;IAChB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAE3B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,yDAAyD;IACzD,MAAM,CAAC,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../../src/storage/struct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACnH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG;IAC3B,sBAAsB;IACtB,QAAQ,EAAE,MAAM;IAChB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAE3B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,yDAAyD;IACzD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE;IAC7C,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,2EAA2E;IAC3E,KAAK,EAAE,aAAa,CAAC;IACrB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;CAC7C,CAAA;AAED;mFACmF;AACnF,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAAC"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { PeerId, PrivateKey } from '@libp2p/interface';
|
|
2
|
-
import type { IKeyNetwork, IRepo, BlockId, ITransactor, ITransactionValidator } from '@optimystic/db-core';
|
|
2
|
+
import type { IKeyNetwork, ClusterRecord, IRepo, BlockId, ITransactor, ITransactionValidator } from '@optimystic/db-core';
|
|
3
3
|
import { ClusterMember, type ExpectedClusterView } from '../cluster/cluster-repo.js';
|
|
4
4
|
import { type ClusterPolicyOptions, type ResolvedClusterPolicy } from '../cluster/cluster-policy.js';
|
|
5
5
|
import { StorageRepo } from '../storage/storage-repo.js';
|
|
6
6
|
import type { IRawStorage } from '../storage/i-raw-storage.js';
|
|
7
|
+
import type { CommittedHolders } from '../cluster/rebalance-monitor.js';
|
|
7
8
|
import type { CoordinatorRepo } from '../repo/coordinator-repo.js';
|
|
8
9
|
export interface MeshNode {
|
|
9
10
|
peerId: PeerId;
|
|
10
11
|
privateKey: PrivateKey;
|
|
12
|
+
/**
|
|
13
|
+
* This node's own view of the key network — the harness analogue of a real node's `keyNetwork`
|
|
14
|
+
* attachment, and the instance its coordinator and its member's admission derivation both read. It
|
|
15
|
+
* differs from `Mesh.keyNetwork` only under a simulated partition (`MeshFailureConfig.partitionSides`).
|
|
16
|
+
*/
|
|
17
|
+
keyNetwork: IKeyNetwork;
|
|
11
18
|
storageRepo: StorageRepo;
|
|
12
19
|
clusterMember: ClusterMember;
|
|
13
20
|
coordinatorRepo: CoordinatorRepo;
|
|
@@ -43,9 +50,9 @@ export interface MeshOptions {
|
|
|
43
50
|
/**
|
|
44
51
|
* Per-node member-side cluster derivation for the membership admission gate — the harness
|
|
45
52
|
* analogue of `libp2p-node-base`'s `deriveExpectedCluster` (findCluster + FRET confidence).
|
|
46
|
-
* Omitted → each member gets the production-shaped derivation over its own
|
|
47
|
-
*
|
|
48
|
-
*
|
|
53
|
+
* Omitted → each member gets the production-shaped derivation over its own key-network view
|
|
54
|
+
* (partition-aware, see `MeshFailureConfig.partitionSides`) with confidence from `meshConfidence`
|
|
55
|
+
* (default 1).
|
|
49
56
|
*/
|
|
50
57
|
deriveExpectedCluster?: (node: MeshNode, blockId: BlockId) => Promise<ExpectedClusterView>;
|
|
51
58
|
/**
|
|
@@ -64,7 +71,8 @@ export interface MeshOptions {
|
|
|
64
71
|
*
|
|
65
72
|
* A mesh that arms validators can also set `clusterPolicy.unvalidatablePendPolicy: 'reject'` to
|
|
66
73
|
* refuse pends that carry no `validation` payload (the single-collection `Collection.sync`
|
|
67
|
-
* shape,
|
|
74
|
+
* shape, and the Quereus adapter's legacy multi-tree commit — neither can be re-checked); the
|
|
75
|
+
* default 'accept' admits them unchecked.
|
|
68
76
|
*/
|
|
69
77
|
validatorFactory?: (index: number, peerId: PeerId) => ITransactionValidator;
|
|
70
78
|
/**
|
|
@@ -89,6 +97,13 @@ export interface MeshOptions {
|
|
|
89
97
|
* eventually crosses it. Omitted → random keys.
|
|
90
98
|
*/
|
|
91
99
|
keySeed?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Receives each node's committed-holders reports — from its member after a durable consensus apply
|
|
102
|
+
* and from its coordinator on acknowledging a cohort commit — the harness analogue of the sink
|
|
103
|
+
* `libp2p-node-base` routes to the node's rebalance monitor. The harness builds no monitor; a spec
|
|
104
|
+
* that wants one routes reports to its own. Omitted → nothing is reported.
|
|
105
|
+
*/
|
|
106
|
+
onCommittedHolders?: (node: MeshNode, committed: CommittedHolders) => void;
|
|
92
107
|
}
|
|
93
108
|
export interface MeshFailureConfig {
|
|
94
109
|
/** Peers that should fail on cluster update (simulate unreachable) */
|
|
@@ -115,11 +130,42 @@ export interface MeshFailureConfig {
|
|
|
115
130
|
* it declared, which is already its own side.
|
|
116
131
|
*/
|
|
117
132
|
partitionSides?: Set<string>[];
|
|
133
|
+
/**
|
|
134
|
+
* Observes every REMOTE cluster delivery — promise round, commit round, commit broadcast and
|
|
135
|
+
* scheduled commit retry alike — with the target's peer-id string and the record as sent, BEFORE
|
|
136
|
+
* `failingPeers` is consulted for that delivery. It exists so a spec can change reachability at an
|
|
137
|
+
* exact protocol step rather than between whole transactions: a member that promised and then
|
|
138
|
+
* dropped before voting to commit is set unreachable here, on the delivery that would have carried
|
|
139
|
+
* its commit vote, and that very delivery fails.
|
|
140
|
+
*
|
|
141
|
+
* A coordinator's OWN member is invoked in process, never through this path — as in production,
|
|
142
|
+
* where `ClusterCoordinator.updateMember` calls it directly — so the hook never sees it.
|
|
143
|
+
*/
|
|
144
|
+
onClusterDelivery?: (targetPeerId: string, record: ClusterRecord) => void;
|
|
118
145
|
}
|
|
119
146
|
export interface Mesh {
|
|
120
147
|
nodes: MeshNode[];
|
|
121
148
|
failures: MeshFailureConfig;
|
|
122
149
|
keyNetwork: IKeyNetwork;
|
|
150
|
+
/**
|
|
151
|
+
* Restart one node the way a stopped and relaunched process comes back: same identity, same raw
|
|
152
|
+
* storage, and nothing else. `node`'s storage repo, cluster member and coordinator are rebuilt IN
|
|
153
|
+
* PLACE on the same `MeshNode` object (so a spec's reference to it stays valid), over the
|
|
154
|
+
* `IRawStorage` instance it was built with — for the default `MemoryRawStorage` that is exactly
|
|
155
|
+
* "over its own storage"; a `rawStorageFactory` store is reused as-is, never re-requested.
|
|
156
|
+
*
|
|
157
|
+
* Everything held only in memory goes with the old instance: the member's reservations and
|
|
158
|
+
* executed-transaction memory, the coordinator's in-flight transactions and scheduled commit
|
|
159
|
+
* retries, every read-repair stamp. The harness wires no `ITransactionStateStore`, so nothing is
|
|
160
|
+
* recovered either — a production node built with `transactionStateStore` would resume its
|
|
161
|
+
* persisted commit retries on restart (`ClusterCoordinator.recoverTransactions`). The old instance is made inert rather than merely forgotten —
|
|
162
|
+
* its member is disposed, and every outbound call it would still make (a commit retry whose timer
|
|
163
|
+
* fires later, a cohort consult, an archive fetch) fails the way a stopped process's dial does — so
|
|
164
|
+
* a retry the old process owed cannot quietly deliver after the restart and pass for healing.
|
|
165
|
+
*
|
|
166
|
+
* Reachability (`failures`) is untouched: a node that was unreachable stays unreachable.
|
|
167
|
+
*/
|
|
168
|
+
restart(node: MeshNode): void;
|
|
123
169
|
}
|
|
124
170
|
/**
|
|
125
171
|
* Fold the mesh's operator-facing knobs into the numbers every node runs on, through the SAME
|
|
@@ -139,12 +185,28 @@ export declare function createMesh(nodeCount: number, options: MeshOptions): Pro
|
|
|
139
185
|
* The nodes the key network keeps OUT of `blockId`'s cohort — peers that receive none of the
|
|
140
186
|
* block's cluster traffic, and so hold none of its content until something repairs them.
|
|
141
187
|
*
|
|
142
|
-
*
|
|
143
|
-
* from run to run: in a 3-node `responsibilityK: 1` mesh,
|
|
144
|
-
* peer about a third of the time, and then it receives the
|
|
145
|
-
* needs a genuinely non-responsible node has to ask the routing
|
|
188
|
+
* Unless the mesh is seeded (`keySeed`), peer ids are generated fresh per mesh, so which node is
|
|
189
|
+
* responsible for a given block is random from run to run: in a 3-node `responsibilityK: 1` mesh,
|
|
190
|
+
* `nodes[1]` is the block's sole responsible peer about a third of the time, and then it receives the
|
|
191
|
+
* writer's commit directly. A test that needs a genuinely non-responsible node has to ask the routing
|
|
192
|
+
* layer rather than assume an index.
|
|
146
193
|
*/
|
|
147
194
|
export declare function nonResponsibleNodes(mesh: Mesh, blockId: string): Promise<MeshNode[]>;
|
|
195
|
+
/**
|
|
196
|
+
* The nodes the key network places in `blockId`'s cohort, nearest first — the complement of
|
|
197
|
+
* {@link nonResponsibleNodes}. A node outside this list refuses a write for the block through its own
|
|
198
|
+
* coordinator (`CoordinatorRepo` checks responsibility), so a spec that writes through one node's
|
|
199
|
+
* coordinator directly picks that node from here rather than by index.
|
|
200
|
+
*/
|
|
201
|
+
export declare function responsibleNodes(mesh: Mesh, blockId: string): Promise<MeshNode[]>;
|
|
202
|
+
/**
|
|
203
|
+
* The first `count` ids of the form `${prefix}-${i}` whose cohort includes `node` — for a spec that needs
|
|
204
|
+
* several blocks one node is responsible for (a multi-block pend through that node's coordinator, or
|
|
205
|
+
* sequential writes it coordinates alone). In a `responsibilityK: 1` mesh these are blocks the node is
|
|
206
|
+
* the SOLE responsible peer for. Throws after `maxCandidates` ids rather than looping on a node whose ring
|
|
207
|
+
* arc no id lands in.
|
|
208
|
+
*/
|
|
209
|
+
export declare function blockIdsInCohortOf(mesh: Mesh, node: MeshNode, count: number, prefix: string, maxCandidates?: number): Promise<BlockId[]>;
|
|
148
210
|
export interface BuildTransactorOptions {
|
|
149
211
|
timeoutMs?: number;
|
|
150
212
|
abortOrCancelTimeoutMs?: number;
|
|
@@ -158,14 +220,18 @@ export interface BuildTransactorOptions {
|
|
|
158
220
|
/**
|
|
159
221
|
* Builds a NetworkTransactor over a mesh. All nodes share the same mock
|
|
160
222
|
* infrastructure so a single transactor routes to every peer via `getRepo`.
|
|
223
|
+
* It runs on no node (no `localPeerId`), so a coverage tie between cohort
|
|
224
|
+
* members goes to the nearest — a client-only writer's shape.
|
|
161
225
|
* Suitable for solo-mesh tests; for multi-node tests prefer
|
|
162
226
|
* `buildNetworkTransactors` to label "which node is driving".
|
|
163
227
|
*/
|
|
164
228
|
export declare const buildNetworkTransactor: (mesh: Mesh, options?: BuildTransactorOptions) => ITransactor;
|
|
165
229
|
/**
|
|
166
230
|
* Builds one NetworkTransactor per mesh node, keyed by peer-id string. Each
|
|
167
|
-
* transactor shares the mesh's key network and peer→repo map
|
|
168
|
-
*
|
|
231
|
+
* transactor shares the mesh's key network and peer→repo map, and runs on its
|
|
232
|
+
* node the way a production node's transactor does (`localPeerId`): when that
|
|
233
|
+
* node is in a block's cohort and ties another member on coverage, it
|
|
234
|
+
* coordinates the write itself. Reads and retries still route by proximity.
|
|
169
235
|
*/
|
|
170
236
|
export declare const buildNetworkTransactors: (mesh: Mesh, options?: BuildTransactorOptions) => Map<string, ITransactor>;
|
|
171
237
|
//# sourceMappingURL=mesh-harness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh-harness.d.ts","sourceRoot":"","sources":["../../../src/testing/mesh-harness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"mesh-harness.d.ts","sourceRoot":"","sources":["../../../src/testing/mesh-harness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAA0B,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAkC,MAAM,qBAAqB,CAAC;AAOlL,OAAO,EAAE,aAAa,EAAkF,KAAK,mBAAmB,EAA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