@optimystic/db-p2p 0.24.2 → 0.25.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 → README.md} +688 -668
- package/dist/src/cluster/block-transfer-service.d.ts +133 -10
- package/dist/src/cluster/block-transfer-service.d.ts.map +1 -1
- package/dist/src/cluster/block-transfer-service.js +155 -9
- package/dist/src/cluster/block-transfer-service.js.map +1 -1
- package/dist/src/cluster/block-transfer.d.ts +67 -7
- package/dist/src/cluster/block-transfer.d.ts.map +1 -1
- package/dist/src/cluster/block-transfer.js +127 -24
- package/dist/src/cluster/block-transfer.js.map +1 -1
- package/dist/src/cluster/certified-claims.d.ts +170 -0
- package/dist/src/cluster/certified-claims.d.ts.map +1 -0
- package/dist/src/cluster/certified-claims.js +200 -0
- package/dist/src/cluster/certified-claims.js.map +1 -0
- package/dist/src/cluster/client-signature-verifier.d.ts +23 -0
- package/dist/src/cluster/client-signature-verifier.d.ts.map +1 -0
- package/dist/src/cluster/client-signature-verifier.js +33 -0
- package/dist/src/cluster/client-signature-verifier.js.map +1 -0
- package/dist/src/cluster/cluster-policy.d.ts +9 -3
- package/dist/src/cluster/cluster-policy.d.ts.map +1 -1
- package/dist/src/cluster/cluster-policy.js +111 -27
- package/dist/src/cluster/cluster-policy.js.map +1 -1
- package/dist/src/cluster/cluster-repo.d.ts +140 -11
- package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
- package/dist/src/cluster/cluster-repo.js +485 -29
- package/dist/src/cluster/cluster-repo.js.map +1 -1
- package/dist/src/cluster/commit-proof.d.ts +134 -0
- package/dist/src/cluster/commit-proof.d.ts.map +1 -0
- package/dist/src/cluster/commit-proof.js +263 -0
- package/dist/src/cluster/commit-proof.js.map +1 -0
- package/dist/src/cluster/quorum-restore.d.ts +95 -8
- package/dist/src/cluster/quorum-restore.d.ts.map +1 -1
- package/dist/src/cluster/quorum-restore.js +113 -14
- package/dist/src/cluster/quorum-restore.js.map +1 -1
- package/dist/src/cluster/rebalance-monitor.d.ts +84 -0
- package/dist/src/cluster/rebalance-monitor.d.ts.map +1 -1
- package/dist/src/cluster/rebalance-monitor.js +207 -5
- package/dist/src/cluster/rebalance-monitor.js.map +1 -1
- package/dist/src/cluster/reconcile-block.d.ts +27 -7
- package/dist/src/cluster/reconcile-block.d.ts.map +1 -1
- package/dist/src/cluster/reconcile-block.js +179 -38
- package/dist/src/cluster/reconcile-block.js.map +1 -1
- package/dist/src/cluster/service.d.ts +13 -4
- package/dist/src/cluster/service.d.ts.map +1 -1
- package/dist/src/cluster/service.js +17 -18
- package/dist/src/cluster/service.js.map +1 -1
- package/dist/src/cluster/spread-on-churn.d.ts +8 -2
- package/dist/src/cluster/spread-on-churn.d.ts.map +1 -1
- package/dist/src/cluster/spread-on-churn.js +7 -7
- 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 -7
- package/dist/src/cohort-topic/host.js.map +1 -1
- package/dist/src/cohort-topic/stream-util.d.ts +7 -6
- package/dist/src/cohort-topic/stream-util.d.ts.map +1 -1
- package/dist/src/cohort-topic/stream-util.js +14 -41
- package/dist/src/cohort-topic/stream-util.js.map +1 -1
- package/dist/src/dispute/cascade.d.ts +7 -8
- package/dist/src/dispute/cascade.d.ts.map +1 -1
- package/dist/src/dispute/cascade.js +24 -7
- package/dist/src/dispute/cascade.js.map +1 -1
- package/dist/src/dispute/dispute-service.d.ts +5 -0
- package/dist/src/dispute/dispute-service.d.ts.map +1 -1
- package/dist/src/dispute/dispute-service.js +13 -3
- package/dist/src/dispute/dispute-service.js.map +1 -1
- package/dist/src/dispute/invalidation.d.ts +33 -15
- package/dist/src/dispute/invalidation.d.ts.map +1 -1
- package/dist/src/dispute/invalidation.js +127 -34
- package/dist/src/dispute/invalidation.js.map +1 -1
- package/dist/src/dispute/service.d.ts.map +1 -1
- package/dist/src/dispute/service.js +2 -1
- package/dist/src/dispute/service.js.map +1 -1
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/libp2p-key-network.d.ts +14 -10
- package/dist/src/libp2p-key-network.d.ts.map +1 -1
- package/dist/src/libp2p-key-network.js +28 -58
- package/dist/src/libp2p-key-network.js.map +1 -1
- package/dist/src/libp2p-node-base.d.ts +38 -7
- package/dist/src/libp2p-node-base.d.ts.map +1 -1
- package/dist/src/libp2p-node-base.js +148 -63
- package/dist/src/libp2p-node-base.js.map +1 -1
- package/dist/src/network/open-protocol-stream.d.ts +56 -0
- package/dist/src/network/open-protocol-stream.d.ts.map +1 -0
- package/dist/src/network/open-protocol-stream.js +60 -0
- package/dist/src/network/open-protocol-stream.js.map +1 -0
- package/dist/src/network/register-protocol-handler.d.ts +66 -0
- package/dist/src/network/register-protocol-handler.d.ts.map +1 -0
- package/dist/src/network/register-protocol-handler.js +51 -0
- package/dist/src/network/register-protocol-handler.js.map +1 -0
- package/dist/src/peer-address-book.d.ts +60 -2
- package/dist/src/peer-address-book.d.ts.map +1 -1
- package/dist/src/peer-address-book.js +89 -1
- package/dist/src/peer-address-book.js.map +1 -1
- package/dist/src/pend-validation.d.ts +65 -0
- package/dist/src/pend-validation.d.ts.map +1 -0
- package/dist/src/pend-validation.js +69 -0
- package/dist/src/pend-validation.js.map +1 -0
- package/dist/src/reactivity/notify-transport.d.ts.map +1 -1
- package/dist/src/reactivity/notify-transport.js +2 -1
- package/dist/src/reactivity/notify-transport.js.map +1 -1
- package/dist/src/reactivity/push-state-gossip.d.ts.map +1 -1
- package/dist/src/reactivity/push-state-gossip.js +2 -1
- package/dist/src/reactivity/push-state-gossip.js.map +1 -1
- package/dist/src/repo/cluster-coordinator.d.ts +32 -6
- package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
- package/dist/src/repo/cluster-coordinator.js +44 -10
- package/dist/src/repo/cluster-coordinator.js.map +1 -1
- package/dist/src/repo/coordinator-repo.d.ts +181 -25
- package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
- package/dist/src/repo/coordinator-repo.js +650 -62
- package/dist/src/repo/coordinator-repo.js.map +1 -1
- package/dist/src/repo/served-repo-proxy.d.ts +30 -0
- package/dist/src/repo/served-repo-proxy.d.ts.map +1 -0
- package/dist/src/repo/served-repo-proxy.js +50 -0
- package/dist/src/repo/served-repo-proxy.js.map +1 -0
- package/dist/src/repo/service.d.ts +16 -1
- package/dist/src/repo/service.d.ts.map +1 -1
- package/dist/src/repo/service.js +18 -16
- package/dist/src/repo/service.js.map +1 -1
- package/dist/src/reputation/types.d.ts +3 -1
- package/dist/src/reputation/types.d.ts.map +1 -1
- package/dist/src/reputation/types.js +3 -1
- package/dist/src/reputation/types.js.map +1 -1
- package/dist/src/rn.d.ts +24 -2
- package/dist/src/rn.d.ts.map +1 -1
- package/dist/src/rn.js +33 -4
- package/dist/src/rn.js.map +1 -1
- package/dist/src/storage/block-archive.d.ts +153 -0
- package/dist/src/storage/block-archive.d.ts.map +1 -0
- package/dist/src/storage/block-archive.js +194 -0
- package/dist/src/storage/block-archive.js.map +1 -0
- package/dist/src/storage/block-latch.d.ts +92 -0
- package/dist/src/storage/block-latch.d.ts.map +1 -0
- package/dist/src/storage/block-latch.js +132 -0
- package/dist/src/storage/block-latch.js.map +1 -0
- package/dist/src/storage/block-storage.d.ts +169 -12
- package/dist/src/storage/block-storage.d.ts.map +1 -1
- package/dist/src/storage/block-storage.js +415 -152
- package/dist/src/storage/block-storage.js.map +1 -1
- package/dist/src/storage/cached-raw-storage.d.ts +5 -1
- package/dist/src/storage/cached-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/cached-raw-storage.js +16 -1
- package/dist/src/storage/cached-raw-storage.js.map +1 -1
- package/dist/src/storage/cached-store-driver.d.ts +14 -4
- package/dist/src/storage/cached-store-driver.d.ts.map +1 -1
- package/dist/src/storage/cached-store-driver.js +39 -5
- package/dist/src/storage/cached-store-driver.js.map +1 -1
- package/dist/src/storage/i-block-storage.d.ts +70 -19
- package/dist/src/storage/i-block-storage.d.ts.map +1 -1
- package/dist/src/storage/i-block-storage.js +21 -1
- package/dist/src/storage/i-block-storage.js.map +1 -1
- package/dist/src/storage/i-raw-storage.d.ts +38 -0
- package/dist/src/storage/i-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/kv-raw-storage.d.ts +14 -8
- package/dist/src/storage/kv-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/kv-raw-storage.js +29 -9
- package/dist/src/storage/kv-raw-storage.js.map +1 -1
- package/dist/src/storage/memory-store-driver.d.ts +4 -1
- package/dist/src/storage/memory-store-driver.d.ts.map +1 -1
- package/dist/src/storage/memory-store-driver.js +22 -2
- package/dist/src/storage/memory-store-driver.js.map +1 -1
- package/dist/src/storage/raw-store-codec.js +2 -2
- package/dist/src/storage/raw-store-driver.d.ts +44 -3
- package/dist/src/storage/raw-store-driver.d.ts.map +1 -1
- package/dist/src/storage/shared-cache-pool.d.ts +60 -3
- package/dist/src/storage/shared-cache-pool.d.ts.map +1 -1
- package/dist/src/storage/shared-cache-pool.js +68 -4
- package/dist/src/storage/shared-cache-pool.js.map +1 -1
- package/dist/src/storage/storage-repo.d.ts +204 -26
- package/dist/src/storage/storage-repo.d.ts.map +1 -1
- package/dist/src/storage/storage-repo.js +422 -119
- package/dist/src/storage/storage-repo.js.map +1 -1
- package/dist/src/storage/store-identity.d.ts +21 -0
- package/dist/src/storage/store-identity.d.ts.map +1 -0
- package/dist/src/storage/store-identity.js +33 -0
- package/dist/src/storage/store-identity.js.map +1 -0
- package/dist/src/storage/struct.d.ts +15 -0
- package/dist/src/storage/struct.d.ts.map +1 -1
- package/dist/src/storage/with-read-cache.d.ts +92 -0
- package/dist/src/storage/with-read-cache.d.ts.map +1 -0
- package/dist/src/storage/with-read-cache.js +132 -0
- package/dist/src/storage/with-read-cache.js.map +1 -0
- package/dist/src/sync/service.d.ts +13 -3
- package/dist/src/sync/service.d.ts.map +1 -1
- package/dist/src/sync/service.js +7 -30
- package/dist/src/sync/service.js.map +1 -1
- package/dist/src/testing/mesh-harness.d.ts +75 -2
- package/dist/src/testing/mesh-harness.d.ts.map +1 -1
- package/dist/src/testing/mesh-harness.js +193 -81
- package/dist/src/testing/mesh-harness.js.map +1 -1
- package/dist/src/testing/raw-storage-conformance.d.ts +8 -0
- package/dist/src/testing/raw-storage-conformance.d.ts.map +1 -1
- package/dist/src/testing/raw-storage-conformance.js +97 -2
- package/dist/src/testing/raw-storage-conformance.js.map +1 -1
- package/package.json +5 -6
- package/src/cluster/block-transfer-service.ts +528 -312
- package/src/cluster/block-transfer.ts +547 -424
- package/src/cluster/certified-claims.ts +319 -0
- package/src/cluster/client-signature-verifier.ts +34 -0
- package/src/cluster/cluster-policy.ts +294 -203
- package/src/cluster/cluster-repo.ts +2501 -2034
- package/src/cluster/commit-proof.ts +344 -0
- package/src/cluster/quorum-restore.ts +348 -223
- package/src/cluster/rebalance-monitor.ts +539 -254
- package/src/cluster/reconcile-block.ts +404 -203
- package/src/cluster/service.ts +23 -20
- package/src/cluster/spread-on-churn.ts +352 -346
- package/src/cohort-topic/host.ts +8 -7
- package/src/cohort-topic/stream-util.ts +14 -43
- package/src/dispute/cascade.ts +31 -15
- package/src/dispute/dispute-service.ts +706 -696
- package/src/dispute/invalidation.ts +162 -52
- package/src/dispute/service.ts +126 -125
- package/src/index.ts +7 -0
- package/src/libp2p-key-network.ts +1204 -1235
- package/src/libp2p-node-base.ts +185 -70
- package/src/network/open-protocol-stream.ts +87 -0
- package/src/network/register-protocol-handler.ts +85 -0
- package/src/peer-address-book.ts +96 -2
- package/src/pend-validation.ts +89 -0
- package/src/reactivity/notify-transport.ts +2 -1
- package/src/reactivity/push-state-gossip.ts +2 -1
- package/src/repo/cluster-coordinator.ts +65 -11
- package/src/repo/coordinator-repo.ts +729 -71
- package/src/repo/served-repo-proxy.ts +55 -0
- package/src/repo/service.ts +25 -16
- package/src/reputation/types.ts +3 -1
- package/src/rn.ts +34 -4
- package/src/storage/block-archive.ts +242 -0
- package/src/storage/block-latch.ts +144 -0
- package/src/storage/block-storage.ts +787 -498
- package/src/storage/cached-raw-storage.ts +21 -1
- package/src/storage/cached-store-driver.ts +898 -859
- package/src/storage/i-block-storage.ts +172 -116
- package/src/storage/i-raw-storage.ts +40 -0
- package/src/storage/kv-raw-storage.ts +34 -9
- package/src/storage/memory-store-driver.ts +26 -2
- package/src/storage/raw-store-codec.ts +42 -42
- package/src/storage/raw-store-driver.ts +45 -3
- package/src/storage/shared-cache-pool.ts +516 -452
- package/src/storage/storage-repo.ts +1421 -1014
- package/src/storage/store-identity.ts +41 -0
- package/src/storage/struct.ts +52 -34
- package/src/storage/with-read-cache.ts +182 -0
- package/src/sync/service.ts +178 -198
- package/src/testing/mesh-harness.ts +524 -344
- package/src/testing/raw-storage-conformance.ts +114 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IRepo, ClusterRecord, ClusterPeers, ITransactionValidator, ClusterConsensusConfig, BlockId, ActionId, ActionRev, CommitCert, InvalidateRequest } from "@optimystic/db-core";
|
|
1
|
+
import type { IRepo, ClusterRecord, ClusterPeers, ITransactionValidator, ClusterConsensusConfig, CommitResult, PendResult, BlockId, ActionId, ActionRev, CommitCert, InvalidateRequest } from "@optimystic/db-core";
|
|
2
2
|
import type { ICluster } from "@optimystic/db-core";
|
|
3
3
|
import type { IPeerNetwork } from "@optimystic/db-core";
|
|
4
4
|
import { type ArbitratorSetRecompute } from "../dispute/invalidation.js";
|
|
@@ -76,6 +76,21 @@ export type ExpectedClusterView = {
|
|
|
76
76
|
export type DeriveExpectedClusterCallback = (blockId: BlockId) => Promise<ExpectedClusterView>;
|
|
77
77
|
/** Stable reject reason a member emits when a declared peer set fails the membership admission gate. */
|
|
78
78
|
export declare const MEMBERSHIP_NOT_ADMITTED = "membership-not-admitted";
|
|
79
|
+
/**
|
|
80
|
+
* Stable reject reason a member emits when its own materialization of a commit's block disagrees
|
|
81
|
+
* with the content digest the transaction author declared (`CommitRequest.blockDigests`). Rides in
|
|
82
|
+
* the reject vote's `rejectReason`, which `clusterVoteSigningPayload` folds into the signed bytes —
|
|
83
|
+
* so the rejection itself is integrity-protected.
|
|
84
|
+
*/
|
|
85
|
+
export declare const CONTENT_DIGEST_MISMATCH = "content-digest-mismatch";
|
|
86
|
+
/**
|
|
87
|
+
* The two stable reject reasons a validator-configured member emits from the shared
|
|
88
|
+
* {@link checkPendValidation}: `PEND_NOT_VALIDATABLE` for a pend carrying no `validation` payload
|
|
89
|
+
* under `ClusterConsensusConfig.unvalidatablePendPolicy: 'reject'`, and `VALIDATOR_FAULT` for a
|
|
90
|
+
* checker that threw. Defined in `pend-validation.ts` (which the storage tier runs too, so both
|
|
91
|
+
* tiers refuse with the same prefixes) and re-exported here next to its siblings above.
|
|
92
|
+
*/
|
|
93
|
+
export { PEND_NOT_VALIDATABLE, VALIDATOR_FAULT } from "../pend-validation.js";
|
|
79
94
|
interface ClusterMemberComponents {
|
|
80
95
|
storageRepo: IRepo;
|
|
81
96
|
peerNetwork: IPeerNetwork;
|
|
@@ -121,6 +136,8 @@ export declare class ClusterMember implements ICluster {
|
|
|
121
136
|
private readonly deriveExpectedCluster?;
|
|
122
137
|
private activeTransactions;
|
|
123
138
|
private executedTransactions;
|
|
139
|
+
private executedPendResults;
|
|
140
|
+
private executedCommitResults;
|
|
124
141
|
private appliedInvalidations;
|
|
125
142
|
private cleanupQueue;
|
|
126
143
|
private pendingUpdates;
|
|
@@ -145,6 +162,9 @@ export declare class ClusterMember implements ICluster {
|
|
|
145
162
|
/** Operator-asserted smallest genuine cohort size, or undefined when unknown. */
|
|
146
163
|
private readonly assumedClusterSize;
|
|
147
164
|
private readonly allowUnvalidatedSmallCluster;
|
|
165
|
+
/** What a validator-configured member does with a pend carrying no `validation` payload — see
|
|
166
|
+
* {@link ClusterConsensusConfig.unvalidatablePendPolicy}. Read once, like the gate parameters. */
|
|
167
|
+
private readonly unvalidatablePendPolicy;
|
|
148
168
|
constructor(storageRepo: IRepo, peerNetwork: IPeerNetwork, peerId: PeerId, privateKey: PrivateKey, protocolPrefix?: string | undefined, _partitionDetector?: PartitionDetector, fretService?: FretService | undefined, validator?: ITransactionValidator | undefined, reputation?: IPeerReputation | undefined, consensusConfig?: ClusterConsensusConfig, stateStore?: ITransactionStateStore | undefined, reconcileBlock?: ReconcileBlockCallback | undefined, onCommitCertificate?: CommitCertificateSink | undefined, onInvalidate?: InvalidationApplySink | undefined, recomputeArbitratorSet?: RecomputeArbitratorSetCapability | undefined, deriveExpectedCluster?: DeriveExpectedClusterCallback | undefined);
|
|
149
169
|
/**
|
|
150
170
|
* The resolved super-majority threshold this member runs on. Exposed so the composition root can
|
|
@@ -163,6 +183,27 @@ export declare class ClusterMember implements ICluster {
|
|
|
163
183
|
* Used by the coordinator to avoid duplicate execution in CoordinatorRepo.
|
|
164
184
|
*/
|
|
165
185
|
wasTransactionExecuted(messageHash: string): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Local storage's verdict for the pend operation this member applied at consensus for
|
|
188
|
+
* `messageHash`, when one was retained. The coordinator reads this so the answer a writer gets
|
|
189
|
+
* is the answer storage gave — the cluster path must not fabricate a success the single-node
|
|
190
|
+
* path (`CoordinatorRepo.pend`'s `peerCount <= 1` short-circuit) would never produce. Absent for
|
|
191
|
+
* transactions carrying no pend operation, for transactions applied before this member restarted
|
|
192
|
+
* (the map is in-memory only; the coordinator then falls back to its fabricated-success shape,
|
|
193
|
+
* with the promise-phase pending check in {@link validatePendOperations} narrowing that window),
|
|
194
|
+
* and after the executed-transaction TTL prunes it.
|
|
195
|
+
*/
|
|
196
|
+
getExecutedPendResult(messageHash: string): PendResult | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* Commit-shaped sibling of {@link getExecutedPendResult}: local storage's verdict for a commit
|
|
199
|
+
* operation applied during consensus, when this member retained one. `CoordinatorRepo.commit`
|
|
200
|
+
* consults it after a locally-executed commit-consensus — a retained refusal whose cause a local
|
|
201
|
+
* re-read confirms as a rival holding the requested revision is returned to the writer as a
|
|
202
|
+
* retryable conflict instead of the fabricated success the ahead-divergence tolerance would
|
|
203
|
+
* otherwise imply. Same availability caveats as the pend accessor: in-memory only, absent for
|
|
204
|
+
* pre-restart applies, pruned on the executed-transaction TTL.
|
|
205
|
+
*/
|
|
206
|
+
getExecutedCommitResult(messageHash: string): CommitResult | undefined;
|
|
166
207
|
/**
|
|
167
208
|
* Handles an incoming cluster update, managing the two-phase commit process
|
|
168
209
|
* and coordinating with the local storage repo
|
|
@@ -228,10 +269,12 @@ export declare class ClusterMember implements ICluster {
|
|
|
228
269
|
private handleConflictVoteNeeded;
|
|
229
270
|
/**
|
|
230
271
|
* The full promise-phase decision for a record: admit the declared membership FIRST, then (only if
|
|
231
|
-
* admitted) validate its pend operations. Failing
|
|
232
|
-
* turns into a `reject` vote.
|
|
233
|
-
* distinct — a `membership-not-admitted` reject is a different signal (feeds the
|
|
234
|
-
* stale-revision / custom-validator reject
|
|
272
|
+
* admitted) validate its pend operations, then its commit operations. Failing any yields a
|
|
273
|
+
* `{ valid:false, reason }` the caller turns into a `reject` vote. Keeping the three separate keeps
|
|
274
|
+
* the reason strings distinct — a `membership-not-admitted` reject is a different signal (feeds the
|
|
275
|
+
* dispute path) than a stale-revision / custom-validator reject, which is different again from a
|
|
276
|
+
* `content-digest-mismatch` (see {@link validateCommitOperations}). A record carries pend OR commit
|
|
277
|
+
* operations, so in practice exactly one of the latter two has anything to inspect.
|
|
235
278
|
*/
|
|
236
279
|
private evaluatePromise;
|
|
237
280
|
/**
|
|
@@ -283,19 +326,99 @@ export declare class ClusterMember implements ICluster {
|
|
|
283
326
|
private admissionFloor;
|
|
284
327
|
/**
|
|
285
328
|
* Derive this member's own view of the record's block cluster via the injected capability, or
|
|
286
|
-
* `undefined` when it cannot (no capability, no coordinating block id,
|
|
287
|
-
*
|
|
288
|
-
* the
|
|
329
|
+
* `undefined` when it cannot (no capability, no coordinating block id, a coordinating block not bound
|
|
330
|
+
* to the record's own operations, or a derivation error — all of which the gate treats as "not
|
|
331
|
+
* confident"). Derived from the record's coordinating block, the same key the coordinator used to
|
|
332
|
+
* select the cluster.
|
|
333
|
+
*
|
|
334
|
+
* Read off `record.message`, NOT a top-level record field: `messageHash` covers the message only, so
|
|
335
|
+
* only the in-message copy is tamper-evident to a relaying peer. (There is no top-level copy any more —
|
|
336
|
+
* see {@link ClusterRecord.message}.)
|
|
289
337
|
*/
|
|
290
338
|
private deriveExpectedClusterView;
|
|
291
339
|
/** |A △ B| over two id lists (order-independent set symmetric difference). */
|
|
292
340
|
private static symmetricDifferenceSize;
|
|
293
341
|
/**
|
|
294
342
|
* Validates pend operations in a cluster record using the transaction validator.
|
|
295
|
-
* Also checks for stale revisions
|
|
343
|
+
* Also checks for stale revisions, and for blocks held by a different unresolved pending
|
|
344
|
+
* action, to prevent consensus on operations that storage would refuse at apply.
|
|
296
345
|
* Returns success if no validator is configured (backwards compatibility).
|
|
297
346
|
*/
|
|
298
347
|
private validatePendOperations;
|
|
348
|
+
/**
|
|
349
|
+
* Promise-round check that a commit record's requested revision is not already committed HERE
|
|
350
|
+
* under a different action. This is the member-side arm that keeps a DEAD rival's re-broadcast
|
|
351
|
+
* commit from assembling consensus: after a race winner commits and members clear its record
|
|
352
|
+
* from the reservation table, a loser's re-driven commit meets no conflict votes — without this
|
|
353
|
+
* check every caught-up member would abstain (the content-digest check below abstains for
|
|
354
|
+
* update-only transforms whose base moved) and the loser could reach commit-consensus for a
|
|
355
|
+
* write no member will ever durably store (its apply is refused stale and tolerated as 'ahead'
|
|
356
|
+
* divergence — see `applyConsensusOperation`).
|
|
357
|
+
*
|
|
358
|
+
* Same "must run on the promise round" rule as {@link validateCommitOperations}: the
|
|
359
|
+
* commit-round vote is deliberately blind, so promise votes are the only ones that carry
|
|
360
|
+
* "I checked this". The four-way rule, per committed block:
|
|
361
|
+
* - no local `latest`, or `latest.rev < commit.rev` → abstain (approve). Preserves the
|
|
362
|
+
* lagging-member tolerance (`coordinator-repo-commit-divergence.spec.ts`): a member behind
|
|
363
|
+
* the commit cannot judge it.
|
|
364
|
+
* - `latest.rev === commit.rev` with the SAME action → abstain (approve). Idempotent
|
|
365
|
+
* redelivery of an already-durable commit; rejecting would make the writer rebase and
|
|
366
|
+
* re-append an action that already landed — a duplicate entry. (Storage's `alreadyDone`
|
|
367
|
+
* partition returns success for this shape at apply.)
|
|
368
|
+
* - `latest.rev === commit.rev` with a DIFFERENT action → reject: a rival took the revision.
|
|
369
|
+
* - `latest.rev > commit.rev` → consult the {@link IRevisionActionReader} capability for who
|
|
370
|
+
* holds `commit.rev`: a different action → reject; the same action → abstain (already
|
|
371
|
+
* durable, history simply moved on); no record / capability absent / read fault → abstain.
|
|
372
|
+
*
|
|
373
|
+
* Never throws out of the vote path: any read fault is an abstain (mirroring the digest check's
|
|
374
|
+
* preview-error arm), because a member that fails to vote at all is worse than one that
|
|
375
|
+
* abstains. Reason stays plain prose — it is fed to computeSigningPayload and carried as
|
|
376
|
+
* Signature.rejectReason, exactly like the stale-revision pend reject.
|
|
377
|
+
*
|
|
378
|
+
* Residual (see the commit-tier handoff): a member that signed the winner's commit but has not
|
|
379
|
+
* yet APPLIED it sits in a window where it holds neither the winner's record (reservation
|
|
380
|
+
* dropped at commit-sign, `shouldPersist = false`) nor the winner's revision (storage still
|
|
381
|
+
* behind) — it abstains here. A capability-less member, or one with history truncated below
|
|
382
|
+
* `latest`, abstains at `latest.rev > commit.rev` too. A rival's commit can therefore still
|
|
383
|
+
* pass the promise round if EVERY member is simultaneously in one of those states — on a fast
|
|
384
|
+
* cohort that window is the COMMON case, not the corner. The backstop is downstream of
|
|
385
|
+
* consensus: every member's apply then refuses the rival as stale, the coordinating node's own
|
|
386
|
+
* member retains that refusal (`getExecutedCommitResult`), and `CoordinatorRepo.commit`
|
|
387
|
+
* confirms the rival against local storage and answers the writer with a retryable conflict
|
|
388
|
+
* instead of a fabricated success. `ConflictRaceLostError` conversion and classified
|
|
389
|
+
* rejections close the re-drive route the same way.
|
|
390
|
+
*/
|
|
391
|
+
private validateCommitRevisions;
|
|
392
|
+
/**
|
|
393
|
+
* Promise-round check of a commit record's declared content digests
|
|
394
|
+
* (`CommitRequest.blockDigests`) against what this member's OWN pended copy of each transform
|
|
395
|
+
* would materialize (`StorageRepo.previewCommitDigest`). This is what makes a promise approval on
|
|
396
|
+
* a commit record MEAN something about content: before this hook, the promise round validated
|
|
397
|
+
* nothing for commits (`validatePendOperations` only inspects pend operations).
|
|
398
|
+
*
|
|
399
|
+
* MUST run on the promise round, not the commit round: the commit-round vote is cast deliberately
|
|
400
|
+
* blind — `getTransactionPhase` signs the commit whenever promise approvals reach super-majority,
|
|
401
|
+
* regardless of this member's own promise vote — so promise approvals are the only votes that
|
|
402
|
+
* carry "I checked this". Do not move it.
|
|
403
|
+
*
|
|
404
|
+
* Checkable/abstain rule, keyed on the member's OWN pended transform (the payload the client
|
|
405
|
+
* authored, delivered at pend — a hostile declarer cannot force or dodge a check by mis-declaring
|
|
406
|
+
* `baseRev`):
|
|
407
|
+
* - transform carries an `insert` → base-independent, ALWAYS check (declared `baseRev` ignored);
|
|
408
|
+
* - `updates` only → check iff this member's local base rev equals the declared `baseRev`
|
|
409
|
+
* (StorageRepo.commit accepts any `latest.rev < request.rev`, so a lagging member applying an
|
|
410
|
+
* update-only transform to an older base legitimately materializes different bytes);
|
|
411
|
+
* - `delete` only / no base / unmaterializable base → materializes nothing to compare, abstain;
|
|
412
|
+
* - no pending transform for the action (this member never saw the pend) → abstain.
|
|
413
|
+
* "Abstain" = contribute no content attestation: approve exactly as before this check existed.
|
|
414
|
+
*
|
|
415
|
+
* Residual: a false digest survives only when the declarer lies AND enough of the cohort is
|
|
416
|
+
* simultaneously unable to check (lagging on update-only blocks, missed pends) that no honest
|
|
417
|
+
* checker is left — any single caught-up honest member rejects. Strictly stronger than before,
|
|
418
|
+
* when commit signatures bound no content at all. Verifying/persisting a durable content proof is
|
|
419
|
+
* later work (persist-block-commit-proof).
|
|
420
|
+
*/
|
|
421
|
+
private validateCommitOperations;
|
|
299
422
|
private handleCommitNeeded;
|
|
300
423
|
/**
|
|
301
424
|
* Executes operations after consensus is reached.
|
|
@@ -463,7 +586,7 @@ export declare class ClusterMember implements ICluster {
|
|
|
463
586
|
private resolveRace;
|
|
464
587
|
/**
|
|
465
588
|
* Aged advisory priority carried by a record's pend operation, clamped to [0, MaxPriority].
|
|
466
|
-
* The multi-collection path carries it on `pend.transaction.priority`; the single-collection
|
|
589
|
+
* The multi-collection path carries it on `pend.validation.transaction.priority`; the single-collection
|
|
467
590
|
* (`Collection.sync`) path carries it as top-level `pend.priority`; a record with neither — a
|
|
468
591
|
* legacy/unversioned coordinator's transaction, or a non-pend operation — is priority 0
|
|
469
592
|
* (backward compatible: such transactions simply never age). Both carriers live inside the signed
|
|
@@ -479,6 +602,13 @@ export declare class ClusterMember implements ICluster {
|
|
|
479
602
|
private recordPriority;
|
|
480
603
|
private operationsConflict;
|
|
481
604
|
private getActionId;
|
|
605
|
+
/**
|
|
606
|
+
* Every block id the message's own operations name. Two consumers, deliberately sharing one
|
|
607
|
+
* definition: conflict detection (which writes must serialize against each other) and the membership
|
|
608
|
+
* admission gate's binding check (the set a legitimate `coordinatingBlockIds[0]` must come from —
|
|
609
|
+
* {@link ClusterMember.deriveExpectedClusterView}). If the two ever disagreed, a coordinator could
|
|
610
|
+
* name a block the record is not judged to touch.
|
|
611
|
+
*/
|
|
482
612
|
private getAffectedBlockIds;
|
|
483
613
|
private propagateIfNeeded;
|
|
484
614
|
private handleExpiration;
|
|
@@ -500,5 +630,4 @@ export declare class ClusterMember implements ICluster {
|
|
|
500
630
|
*/
|
|
501
631
|
wasTransactionExecutedAsync(messageHash: string): Promise<boolean>;
|
|
502
632
|
}
|
|
503
|
-
export {};
|
|
504
633
|
//# sourceMappingURL=cluster-repo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-repo.d.ts","sourceRoot":"","sources":["../../../src/cluster/clu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