@optimystic/db-p2p 0.25.1 → 0.27.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/certified-claims.d.ts +17 -3
- package/dist/src/cluster/certified-claims.d.ts.map +1 -1
- package/dist/src/cluster/certified-claims.js +5 -3
- package/dist/src/cluster/certified-claims.js.map +1 -1
- package/dist/src/cluster/cluster-repo.d.ts +57 -92
- package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
- package/dist/src/cluster/cluster-repo.js +149 -201
- package/dist/src/cluster/cluster-repo.js.map +1 -1
- package/dist/src/cluster/commit-proof.d.ts +16 -0
- package/dist/src/cluster/commit-proof.d.ts.map +1 -1
- package/dist/src/cluster/commit-proof.js +32 -1
- package/dist/src/cluster/commit-proof.js.map +1 -1
- package/dist/src/cluster/quorum-restore.d.ts +81 -28
- package/dist/src/cluster/quorum-restore.d.ts.map +1 -1
- package/dist/src/cluster/quorum-restore.js +148 -51
- package/dist/src/cluster/quorum-restore.js.map +1 -1
- package/dist/src/cluster/race-resolution.d.ts +89 -0
- package/dist/src/cluster/race-resolution.d.ts.map +1 -0
- package/dist/src/cluster/race-resolution.js +140 -0
- package/dist/src/cluster/race-resolution.js.map +1 -0
- package/dist/src/cluster/reconcile-block.d.ts +9 -4
- package/dist/src/cluster/reconcile-block.d.ts.map +1 -1
- package/dist/src/cluster/reconcile-block.js +28 -11
- package/dist/src/cluster/reconcile-block.js.map +1 -1
- package/dist/src/cluster/record-operations.d.ts +25 -0
- package/dist/src/cluster/record-operations.d.ts.map +1 -0
- package/dist/src/cluster/record-operations.js +56 -0
- package/dist/src/cluster/record-operations.js.map +1 -0
- package/dist/src/cohort-topic/host.d.ts +133 -51
- package/dist/src/cohort-topic/host.d.ts.map +1 -1
- package/dist/src/cohort-topic/host.js +290 -83
- package/dist/src/cohort-topic/host.js.map +1 -1
- package/dist/src/libp2p-node-base.d.ts +13 -4
- package/dist/src/libp2p-node-base.d.ts.map +1 -1
- package/dist/src/libp2p-node-base.js +5 -5
- package/dist/src/libp2p-node-base.js.map +1 -1
- package/dist/src/repo/cluster-coordinator.d.ts +9 -0
- package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
- package/dist/src/repo/cluster-coordinator.js +13 -2
- package/dist/src/repo/cluster-coordinator.js.map +1 -1
- package/dist/src/repo/coordinator-repo.d.ts +34 -2
- package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
- package/dist/src/repo/coordinator-repo.js +57 -3
- package/dist/src/repo/coordinator-repo.js.map +1 -1
- package/dist/src/storage/block-latch.d.ts +5 -4
- package/dist/src/storage/block-latch.d.ts.map +1 -1
- package/dist/src/storage/block-latch.js +5 -4
- package/dist/src/storage/block-latch.js.map +1 -1
- package/dist/src/storage/block-storage.d.ts +1 -1
- package/dist/src/storage/block-storage.d.ts.map +1 -1
- package/dist/src/storage/block-storage.js +11 -3
- package/dist/src/storage/block-storage.js.map +1 -1
- package/dist/src/storage/cached-raw-storage.d.ts +17 -1
- package/dist/src/storage/cached-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/cached-raw-storage.js +8 -1
- package/dist/src/storage/cached-raw-storage.js.map +1 -1
- package/dist/src/storage/cached-store-driver.d.ts +7 -0
- package/dist/src/storage/cached-store-driver.d.ts.map +1 -1
- package/dist/src/storage/cached-store-driver.js +20 -0
- package/dist/src/storage/cached-store-driver.js.map +1 -1
- package/dist/src/storage/i-block-storage.d.ts +45 -2
- package/dist/src/storage/i-block-storage.d.ts.map +1 -1
- package/dist/src/storage/i-block-storage.js +29 -0
- package/dist/src/storage/i-block-storage.js.map +1 -1
- package/dist/src/storage/i-raw-storage.d.ts +16 -0
- package/dist/src/storage/i-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/kv-raw-storage.d.ts +5 -1
- package/dist/src/storage/kv-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/kv-raw-storage.js +8 -1
- package/dist/src/storage/kv-raw-storage.js.map +1 -1
- package/dist/src/storage/raw-store-driver.d.ts +15 -0
- package/dist/src/storage/raw-store-driver.d.ts.map +1 -1
- package/dist/src/storage/shared-cache-pool.d.ts +5 -0
- package/dist/src/storage/shared-cache-pool.d.ts.map +1 -1
- package/dist/src/storage/shared-cache-pool.js +6 -1
- package/dist/src/storage/shared-cache-pool.js.map +1 -1
- package/dist/src/storage/storage-repo.d.ts.map +1 -1
- package/dist/src/storage/storage-repo.js +141 -99
- package/dist/src/storage/storage-repo.js.map +1 -1
- package/dist/src/storage/with-read-cache.d.ts +9 -5
- package/dist/src/storage/with-read-cache.d.ts.map +1 -1
- package/dist/src/storage/with-read-cache.js +16 -6
- package/dist/src/storage/with-read-cache.js.map +1 -1
- package/package.json +2 -2
- package/{README.md → readme.md} +2 -2
- package/src/cluster/certified-claims.ts +22 -9
- package/src/cluster/cluster-repo.ts +199 -212
- package/src/cluster/commit-proof.ts +38 -2
- package/src/cluster/quorum-restore.ts +183 -56
- package/src/cluster/race-resolution.ts +158 -0
- package/src/cluster/reconcile-block.ts +34 -11
- package/src/cluster/record-operations.ts +59 -0
- package/src/cohort-topic/host.ts +423 -118
- package/src/libp2p-node-base.ts +18 -9
- package/src/repo/cluster-coordinator.ts +1039 -1027
- package/src/repo/coordinator-repo.ts +1937 -1855
- package/src/storage/block-latch.ts +5 -4
- package/src/storage/block-storage.ts +11 -3
- package/src/storage/cached-raw-storage.ts +21 -1
- package/src/storage/cached-store-driver.ts +23 -0
- package/src/storage/i-block-storage.ts +47 -2
- package/src/storage/i-raw-storage.ts +17 -0
- package/src/storage/kv-raw-storage.ts +8 -1
- package/src/storage/raw-store-driver.ts +26 -0
- package/src/storage/shared-cache-pool.ts +6 -1
- package/src/storage/storage-repo.ts +143 -103
- package/src/storage/with-read-cache.ts +16 -6
|
@@ -116,9 +116,17 @@ export declare function proofThresholds(superMajorityThreshold: number): ProofTh
|
|
|
116
116
|
* when uncertified and unrepresentable when certified.
|
|
117
117
|
*/
|
|
118
118
|
export type ClaimCertification =
|
|
119
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* The proof certifies `claim` — cap passed, thresholds of valid cohort signatures met.
|
|
121
|
+
* `signerCount` is the proof's distinct signer list size (`proof.peerIds.length`, the same
|
|
122
|
+
* number {@link UnanchoredProofAcceptance} reports): the selection helpers weigh a
|
|
123
|
+
* single-signer certification — routine since solo cohorts self-sign their commits — below
|
|
124
|
+
* multi-peer corroboration, and carrying the count in the verdict keeps the two repair paths
|
|
125
|
+
* from each measuring it off the proof themselves.
|
|
126
|
+
*/
|
|
120
127
|
{
|
|
121
128
|
certified: true;
|
|
129
|
+
signerCount: number;
|
|
122
130
|
}
|
|
123
131
|
/** Classify the reason via {@link isAttributableProofFailure} before penalizing anyone. */
|
|
124
132
|
| {
|
|
@@ -131,20 +139,26 @@ export type ClaimCertification =
|
|
|
131
139
|
* alongside full success) cannot be constructed:
|
|
132
140
|
*/
|
|
133
141
|
export type ContentCertification =
|
|
134
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* Both halves passed: the proof certifies `(blockId, rev, actionId)` AND these exact bytes.
|
|
144
|
+
* `signerCount` as in {@link ClaimCertification} — the selectors weigh it.
|
|
145
|
+
*/
|
|
135
146
|
{
|
|
136
147
|
revCertified: true;
|
|
137
148
|
contentCertified: true;
|
|
149
|
+
signerCount: number;
|
|
138
150
|
}
|
|
139
151
|
/**
|
|
140
152
|
* The claim half passed, the content half did not: `digest-mismatch` (attributable — drop AND
|
|
141
153
|
* penalize the served bytes) or `no-digest-declared` (drop only; the cohort declared nothing to
|
|
142
|
-
* compare against). The `(rev, actionId)` is certified either way
|
|
154
|
+
* compare against). The `(rev, actionId)` is certified either way, with `signerCount` weighing
|
|
155
|
+
* that certified half exactly as on full success.
|
|
143
156
|
*/
|
|
144
157
|
| {
|
|
145
158
|
revCertified: true;
|
|
146
159
|
contentCertified: false;
|
|
147
160
|
failure: 'digest-mismatch' | 'no-digest-declared';
|
|
161
|
+
signerCount: number;
|
|
148
162
|
}
|
|
149
163
|
/** The claim half failed, so nothing is certified. Classify via {@link isAttributableProofFailure}. */
|
|
150
164
|
| {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"certified-claims.d.ts","sourceRoot":"","sources":["../../../src/cluster/certified-claims.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAEN,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAC/E,MAAM,mBAAmB,CAAC;AAK3B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAC/B;IAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEzF,iHAAiH;AACjH,MAAM,MAAM,yBAAyB,GAAG;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,sBAAsB,CAAC;CACpE,CAAC;AAEF,2GAA2G;AAC3G,MAAM,MAAM,cAAc,GAAG;IAC5B,6FAA6F;IAC7F,QAAQ,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IACrD;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,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AA;CAAE;AACrE;;;;;GAKG;GACD;IAAE,YAAY,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,iBAAiB,GAAG,oBAAoB,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;AACzH,uGAAuG;GACrG;IAAE,YAAY,EAAE,KAAK,CAAC;IAAC,gBAAgB,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC;AAE7E;;;;GAIG;AACH,wBAAsB,YAAY,CACjC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,GAAE,cAAmB,GACrG,OAAO,CAAC,kBAAkB,CAAC,CAY7B;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CACnC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EACtF,SAAS,GAAE,cAAmB,GAC5B,OAAO,CAAC,oBAAoB,CAAC,CAc/B"}
|
|
@@ -105,7 +105,9 @@ export async function certifyClaim(proof, claim, thresholds, anchoring = {}) {
|
|
|
105
105
|
return { certified: false, failure: verdict.reason };
|
|
106
106
|
}
|
|
107
107
|
await anchorAcceptedProof(proof, claim, anchoring);
|
|
108
|
-
|
|
108
|
+
// Safe unguarded: the verifier only passes a proof whose peerIds it validated (the same read
|
|
109
|
+
// anchorAcceptedProof just performed).
|
|
110
|
+
return { certified: true, signerCount: proof.peerIds.length };
|
|
109
111
|
}
|
|
110
112
|
/**
|
|
111
113
|
* Certify a claim AND the served block bytes ({@link verifyBlockCommitProofContent}). The two
|
|
@@ -122,11 +124,11 @@ export async function certifyContent(proof, claim, block, thresholds, anchoring
|
|
|
122
124
|
const verdict = await verifyBlockCommitProofContent(proof, claim, block, thresholds);
|
|
123
125
|
if (verdict.ok) {
|
|
124
126
|
await anchorAcceptedProof(proof, claim, anchoring);
|
|
125
|
-
return { revCertified: true, contentCertified: true };
|
|
127
|
+
return { revCertified: true, contentCertified: true, signerCount: proof.peerIds.length };
|
|
126
128
|
}
|
|
127
129
|
if (verdict.reason === 'digest-mismatch' || verdict.reason === 'no-digest-declared') {
|
|
128
130
|
await anchorAcceptedProof(proof, claim, anchoring);
|
|
129
|
-
return { revCertified: true, contentCertified: false, failure: verdict.reason };
|
|
131
|
+
return { revCertified: true, contentCertified: false, failure: verdict.reason, signerCount: proof.peerIds.length };
|
|
130
132
|
}
|
|
131
133
|
return { revCertified: false, contentCertified: false, failure: verdict.reason };
|
|
132
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"certified-claims.js","sourceRoot":"","sources":["../../../src/cluster/certified-claims.ts"],"names":[],"mappings":"AACA,OAAO,EACN,2BAA2B,EAAE,6BAA6B,EAE1D,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,GAAG,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAwE7C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAErC;;;;;;;;;;;;;GAaG;AACH,MAAM,2BAA2B,GAA8C;IAC9E,gGAAgG;IAChG,wCAAwC;IACxC,gBAAgB,EAAE,KAAK;IACvB,oBAAoB,EAAE,KAAK;IAC3B,qBAAqB,EAAE,KAAK;IAC5B,iBAAiB,EAAE,KAAK;IACxB,+FAA+F;IAC/F,eAAe,EAAE,KAAK;IACtB,oGAAoG;IACpG,kBAAkB,EAAE,KAAK;IACzB,gGAAgG;IAChG,iGAAiG;IACjG,qBAAqB;IACrB,oBAAoB,EAAE,KAAK;IAC3B,kGAAkG;IAClG,kGAAkG;IAClG,oFAAoF;IACpF,qBAAqB,EAAE,IAAI;IAC3B,uBAAuB,EAAE,IAAI;IAC7B,kBAAkB,EAAE,IAAI;IACxB,mBAAmB,EAA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usConfig, CommitResult, PendResult, BlockId, ActionId, ActionRev, CommitCert, InvalidateRequest } from "@optimystic/db-core";
|
|
1
|
+
import type { IRepo, ClusterRecord, ClusterPeers, RepoMessage, 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";
|
|
@@ -7,6 +7,7 @@ import type { PartitionDetector } from "./partition-detector.js";
|
|
|
7
7
|
import type { FretService } from "p2p-fret";
|
|
8
8
|
import type { IPeerReputation } from "../reputation/types.js";
|
|
9
9
|
import type { ITransactionStateStore } from "./i-transaction-state-store.js";
|
|
10
|
+
import { type BlockCommitProof } from "./commit-proof.js";
|
|
10
11
|
/**
|
|
11
12
|
* Actively reconciles a block this member committed without having seen the matching
|
|
12
13
|
* pend (cohort drift between the independent pend and commit cluster-transactions).
|
|
@@ -68,10 +69,14 @@ export type ExpectedClusterView = {
|
|
|
68
69
|
* Independently derive this member's own view of a block's responsible cluster. Injected so
|
|
69
70
|
* {@link ClusterMember} stays transport-agnostic — the composition root supplies it from
|
|
70
71
|
* `IKeyNetwork.findCluster` + FRET (mirroring how the coordinator derives the cluster). Absent on nodes
|
|
71
|
-
* that cannot derive a view (no FRET, unit tests): with no
|
|
72
|
+
* that cannot derive a view (no FRET, unit tests): with no capability AND no asserted
|
|
72
73
|
* {@link ClusterConsensusConfig.assumedClusterSize} the gate preserves legacy approve behavior, but an
|
|
73
|
-
* asserted size still lets the gate fail closed on an unjustified downsize.
|
|
74
|
-
*
|
|
74
|
+
* asserted size still lets the gate fail closed on an unjustified downsize.
|
|
75
|
+
*
|
|
76
|
+
* Wiring this capability also arms the record-shape refusals: a member that CAN derive refuses outright
|
|
77
|
+
* (rather than falling back) when the record names no coordinating block, or names one the record's own
|
|
78
|
+
* operations never touch — those are the sender's free choice, not this member's inability. See
|
|
79
|
+
* {@link ClusterViewDerivation} and {@link ClusterMember} admission gate.
|
|
75
80
|
*/
|
|
76
81
|
export type DeriveExpectedClusterCallback = (blockId: BlockId) => Promise<ExpectedClusterView>;
|
|
77
82
|
/** Stable reject reason a member emits when a declared peer set fails the membership admission gate. */
|
|
@@ -113,8 +118,28 @@ interface ClusterMemberComponents {
|
|
|
113
118
|
recomputeArbitratorSet?: RecomputeArbitratorSetCapability;
|
|
114
119
|
/** Member-side cluster derivation for the membership admission gate; see {@link DeriveExpectedClusterCallback}. */
|
|
115
120
|
deriveExpectedCluster?: DeriveExpectedClusterCallback;
|
|
121
|
+
/**
|
|
122
|
+
* Wall clock in unix milliseconds; defaults to `Date.now`. Injectable so a test can age a held
|
|
123
|
+
* reservation past {@link CONFLICT_STALE_THRESHOLD_MS} without sleeping. It governs BOTH sides of
|
|
124
|
+
* the reservation's `lastUpdate` — the stamp and the comparison — so the two can never end up on
|
|
125
|
+
* different time bases.
|
|
126
|
+
*
|
|
127
|
+
* NOTE: partial injection, by design. This clock reaches ONLY `lastUpdate`; `message.expiration`,
|
|
128
|
+
* the promise/resolution timeouts, the periodic expiry sweep and the executed-transaction TTL all
|
|
129
|
+
* still read the real `Date.now`. So an injected clock must share an epoch with real time (seed it
|
|
130
|
+
* from `Date.now()`, then advance) — one starting near zero makes every record look long expired
|
|
131
|
+
* via the un-injected expiration check. Widen the injection if a test needs to drive expiry too.
|
|
132
|
+
*/
|
|
133
|
+
now?: () => number;
|
|
116
134
|
}
|
|
117
135
|
export declare function clusterMember(components: ClusterMemberComponents): ClusterMember;
|
|
136
|
+
/**
|
|
137
|
+
* How long a held reservation may go untouched before the conflict scan ({@link ClusterMember.findConflict})
|
|
138
|
+
* sweeps it. Generous relative to a round-trip: the scan frees an ABANDONED coordinator's blocks, so
|
|
139
|
+
* sweeping too eagerly would drop a live transaction whose next delivery is merely in flight.
|
|
140
|
+
* Exported so a test can advance an injected clock past it without restating the number.
|
|
141
|
+
*/
|
|
142
|
+
export declare const CONFLICT_STALE_THRESHOLD_MS = 2000;
|
|
118
143
|
/**
|
|
119
144
|
* Handles cluster-side operations, managing promises and commits for cluster updates
|
|
120
145
|
* and coordinating with the local storage repo.
|
|
@@ -165,7 +190,9 @@ export declare class ClusterMember implements ICluster {
|
|
|
165
190
|
/** What a validator-configured member does with a pend carrying no `validation` payload — see
|
|
166
191
|
* {@link ClusterConsensusConfig.unvalidatablePendPolicy}. Read once, like the gate parameters. */
|
|
167
192
|
private readonly unvalidatablePendPolicy;
|
|
168
|
-
|
|
193
|
+
/** Clock behind the reservation table's `lastUpdate` — see {@link ClusterMemberComponents.now}. */
|
|
194
|
+
private readonly now;
|
|
195
|
+
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, now?: () => number);
|
|
169
196
|
/**
|
|
170
197
|
* The resolved super-majority threshold this member runs on. Exposed so the composition root can
|
|
171
198
|
* fail-fast if the member and the coordinator would run different thresholds (see the coupling
|
|
@@ -204,6 +231,14 @@ export declare class ClusterMember implements ICluster {
|
|
|
204
231
|
* pre-restart applies, pruned on the executed-transaction TTL.
|
|
205
232
|
*/
|
|
206
233
|
getExecutedCommitResult(messageHash: string): CommitResult | undefined;
|
|
234
|
+
/**
|
|
235
|
+
* Self-sign a one-peer {@link BlockCommitProof} over `message` — a thin delegate to
|
|
236
|
+
* {@link mintSoloCommitProof} with this member's own id and key. Lives here because this class is
|
|
237
|
+
* the key holder: `CoordinatorRepo` (the caller, on its solo-cohort commit short-circuit) knows
|
|
238
|
+
* the local peer id but never sees the private key. Nothing else moves — no record, no consensus
|
|
239
|
+
* state; the mint is a pure signing operation over the message the caller built.
|
|
240
|
+
*/
|
|
241
|
+
mintSoloCommitProof(message: RepoMessage): Promise<BlockCommitProof>;
|
|
207
242
|
/**
|
|
208
243
|
* Handles an incoming cluster update, managing the two-phase commit process
|
|
209
244
|
* and coordinating with the local storage repo
|
|
@@ -292,8 +327,16 @@ export declare class ClusterMember implements ICluster {
|
|
|
292
327
|
* 3. **Consistency with the derived view** — `|D △ E|` within `clusterSizeTolerance·|E|`; honest churn
|
|
293
328
|
* of a peer or two is absorbed, a wholesale-disjoint or half-size set is not.
|
|
294
329
|
*
|
|
295
|
-
* **
|
|
296
|
-
*
|
|
330
|
+
* **Inadmissible records come first.** Before any of that, a member that CAN derive refuses outright a
|
|
331
|
+
* record whose coordinating block is the sender's free choice rather than a fact about the record: one
|
|
332
|
+
* that names no coordinating block at all, or names a block the record's own operations never touch.
|
|
333
|
+
* Those are defects of the SENDER, and no current coordinator produces them; treating them as "cannot
|
|
334
|
+
* derive" would hand a dishonest coordinator the choice of which check every member ran. A member with
|
|
335
|
+
* no derivation capability never reaches this refusal — it has nothing to check against.
|
|
336
|
+
*
|
|
337
|
+
* **Fail-closed posture.** When the member cannot confidently derive `E` — no capability, a bound
|
|
338
|
+
* block whose lookup failed or returned an empty/low-confidence view (low FRET confidence is exactly
|
|
339
|
+
* what a partition induces) — it must refuse any *downsizing* decision — but it
|
|
297
340
|
* needs a size reference to judge "downsize" against, and it may NOT borrow `clusterSize` for that:
|
|
298
341
|
* `clusterSize` is the replication factor (what a cohort should aim for), not a claim about how many
|
|
299
342
|
* peers exist, so a small deployment configured with the default 10 would refuse every write. The
|
|
@@ -325,11 +368,13 @@ export declare class ClusterMember implements ICluster {
|
|
|
325
368
|
*/
|
|
326
369
|
private admissionFloor;
|
|
327
370
|
/**
|
|
328
|
-
* Derive this member's own view of the record's block cluster via the injected capability,
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
371
|
+
* Derive this member's own view of the record's block cluster via the injected capability, reporting
|
|
372
|
+
* *why* when it cannot — see {@link ClusterViewDerivation}. Four outcomes, deliberately not collapsed
|
|
373
|
+
* into one `undefined`: the member has no capability; the lookup failed; the record named no
|
|
374
|
+
* coordinating block; the record named a block its own operations never touch. The last two are the
|
|
375
|
+
* sender's choices and {@link admitMembership} refuses them; the first two are this member's own
|
|
376
|
+
* limitation and stay lenient. Derived from the record's coordinating block, the same key the
|
|
377
|
+
* coordinator used to select the cluster.
|
|
333
378
|
*
|
|
334
379
|
* Read off `record.message`, NOT a top-level record field: `messageHash` covers the message only, so
|
|
335
380
|
* only the in-message copy is tamper-evident to a relaying peer. (There is no top-level copy any more —
|
|
@@ -530,86 +575,6 @@ export declare class ClusterMember implements ICluster {
|
|
|
530
575
|
* entries are swept, and a held transaction that LOSES the race to `record` is cleared.
|
|
531
576
|
*/
|
|
532
577
|
private findConflict;
|
|
533
|
-
/** Number of *approve* promise votes on a record — the count the commit rule uses. */
|
|
534
|
-
private static approvalCount;
|
|
535
|
-
/**
|
|
536
|
-
* Resolve a race between two conflicting transactions. Total and deterministic, so every honest
|
|
537
|
-
* member computes the identical winner (the Theorem 1 Case-2 premise). Order:
|
|
538
|
-
* 1. more *approve* promise signatures wins (progress monotonicity — see safety note below);
|
|
539
|
-
* 2. equal approval counts → higher aged priority wins (fairness — see {@link recordPriority});
|
|
540
|
-
* 3. still tied → higher message hash wins.
|
|
541
|
-
*
|
|
542
|
-
* The count is APPROVALS, not `promises` keys. `promises` is the vote map — a reject occupies a key
|
|
543
|
-
* there exactly as an approve does — so counting keys would treat a rejection as progress, letting a
|
|
544
|
-
* record that can never commit outrank (and therefore block, via {@link findConflict}) a fresh rival
|
|
545
|
-
* for the whole staleness window. Approvals is also the count the invariant below actually needs:
|
|
546
|
-
* the commit rule is `approvedPromises >= superMajority`, which never looks at rejections.
|
|
547
|
-
*
|
|
548
|
-
* Approval count is FIRST so this comparison never displaces a transaction that is further along.
|
|
549
|
-
* That restores the pre-priority safety invariant: a member commits purely on promise supermajority
|
|
550
|
-
* (`handleCommitNeeded` signs whenever `approvedPromises >= superMajority`; the commit path has NO
|
|
551
|
-
* conflict re-check), so `resolveRace` is the ONLY arbiter among concurrently-pending conflicts.
|
|
552
|
-
* With approvals-first, once transaction X holds a promise supermajority every conflicting rival Y has
|
|
553
|
-
* strictly fewer approvals — Y can only match X's count by getting the intersecting quorum member to
|
|
554
|
-
* approve it, but that member already holds X at supermajority and `resolveRace(X, Y)` returns
|
|
555
|
-
* `keep-existing` on X's higher count, so it never does. By quorum intersection any Y-supermajority
|
|
556
|
-
* overlaps X's in ≥1 honest member, and that member rejects Y. One winner (docs/correctness.md
|
|
557
|
-
* Theorem 9). Priority-first would break this: it could displace an already-quorum-reached X for a
|
|
558
|
-
* higher-priority Y with fewer approvals, letting BOTH commit (split brain) — the regression fixed by
|
|
559
|
-
* ticket occ-priority-first-breaks-promise-monotonicity.
|
|
560
|
-
*
|
|
561
|
-
* Priority is now a tie-break that runs only at EQUAL approval counts, which is exactly the
|
|
562
|
-
* concurrent-starvation case aging targets (two fresh rivals, 0 promises each, otherwise coin-flipping
|
|
563
|
-
* on the hash). Priority still breaks those ties deterministically, so aging still solves the stated
|
|
564
|
-
* fairness problem in its common case. It only orders two *concurrently-pending* conflicts; it does NOT
|
|
565
|
-
* defer a fresh pend for an absent aged transaction (that residual — sequential sub-window starvation —
|
|
566
|
-
* is the deferred feat-occ-priority-reservation).
|
|
567
|
-
*
|
|
568
|
-
* NOTE: residual-fairness tripwire. Under approvals-first an aged transaction can still lose to a fresh
|
|
569
|
-
* rival that has *legitimately* gathered even one more approval — that is not the pure-coin-flip
|
|
570
|
-
* starvation aging targets (equal counts, priority wins), it is the monotonicity behaviour we WANT (a
|
|
571
|
-
* more-progressed rival is never displaced). If deeper fairness against a genuinely-more-progressed
|
|
572
|
-
* rival is ever needed, it belongs to feat-occ-priority-reservation (reserve/defer at pend time), NOT
|
|
573
|
-
* to this race tie-break.
|
|
574
|
-
*
|
|
575
|
-
* NOTE: Byzantine self-assert is a fairness DoS, not a safety hole. A coordinator can stamp
|
|
576
|
-
* priority == MaxPriority on every transaction; recordPriority clamps to the cap so it cannot
|
|
577
|
-
* exceed it, and priority never influences validity/operationsHash/stale-read checks — and now sits
|
|
578
|
-
* below the approval count, so it can only break equal-count ties it might have ~50% won anyway,
|
|
579
|
-
* degrading to at-worst-status-quo fairness (the same graceful-degradation class as spam under
|
|
580
|
-
* honest-majority). Binding priority to provable age is out of scope (feat-occ-priority-reservation).
|
|
581
|
-
*
|
|
582
|
-
* NOTE: keep priority a self-contained additive message field + this one comparison key so it
|
|
583
|
-
* composes with — does not block — a future HLC/crdt-sync redesign of this same path
|
|
584
|
-
* (design-hot-log-tail-sharding-guidance).
|
|
585
|
-
*/
|
|
586
|
-
private resolveRace;
|
|
587
|
-
/**
|
|
588
|
-
* Aged advisory priority carried by a record's pend operation, clamped to [0, MaxPriority].
|
|
589
|
-
* The multi-collection path carries it on `pend.validation.transaction.priority`; the single-collection
|
|
590
|
-
* (`Collection.sync`) path carries it as top-level `pend.priority`; a record with neither — a
|
|
591
|
-
* legacy/unversioned coordinator's transaction, or a non-pend operation — is priority 0
|
|
592
|
-
* (backward compatible: such transactions simply never age). Both carriers live inside the signed
|
|
593
|
-
* `message`, so priority is integrity-protected in transit; clamping here bounds a self-asserted
|
|
594
|
-
* out-of-range value to the cap.
|
|
595
|
-
*
|
|
596
|
-
* NOTE: `message` is fixed for a transaction's whole lifecycle (promises/commits accrue in the
|
|
597
|
-
* separate `promises`/`commits` maps, never in `message`), so a transaction keeps its rank through
|
|
598
|
-
* the commit phase — there is no "priority drops to 0 at commit" asymmetry. resolveRace is only
|
|
599
|
-
* consulted at the promise decision (findConflict), i.e. between two still-open conflicting
|
|
600
|
-
* transactions, which is exactly the concurrent-contention case priority is meant to order.
|
|
601
|
-
*/
|
|
602
|
-
private recordPriority;
|
|
603
|
-
private operationsConflict;
|
|
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
|
-
*/
|
|
612
|
-
private getAffectedBlockIds;
|
|
613
578
|
private propagateIfNeeded;
|
|
614
579
|
private handleExpiration;
|
|
615
580
|
private resolveWithPeers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-repo.d.ts","sourceRoot":"","sources":["../../../src/cluster/cluster-repo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"cluster-repo.d.ts","sourceRoot":"","sources":["../../../src/cluster/cluster-repo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,YAAY,EAAa,WAAW,EAAE,qBAAqB,EAAE,sBAAsB,EAA2B,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAiB,UAAU,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACpR,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAiC,KAAK,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGxG,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,y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