@optimystic/db-core 1.26.0 → 1.28.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.
Files changed (77) hide show
  1. package/dist/src/chain/chain.d.ts +4 -0
  2. package/dist/src/chain/chain.d.ts.map +1 -1
  3. package/dist/src/chain/chain.js +15 -3
  4. package/dist/src/chain/chain.js.map +1 -1
  5. package/dist/src/cluster/membership.d.ts +9 -2
  6. package/dist/src/cluster/membership.d.ts.map +1 -1
  7. package/dist/src/cluster/membership.js +51 -11
  8. package/dist/src/cluster/membership.js.map +1 -1
  9. package/dist/src/cluster/structs.d.ts +21 -0
  10. package/dist/src/cluster/structs.d.ts.map +1 -1
  11. package/dist/src/cohort-topic/willingness.d.ts +12 -11
  12. package/dist/src/cohort-topic/willingness.d.ts.map +1 -1
  13. package/dist/src/cohort-topic/willingness.js +21 -11
  14. package/dist/src/cohort-topic/willingness.js.map +1 -1
  15. package/dist/src/collection/collection.d.ts +46 -2
  16. package/dist/src/collection/collection.d.ts.map +1 -1
  17. package/dist/src/collection/collection.js +65 -15
  18. package/dist/src/collection/collection.js.map +1 -1
  19. package/dist/src/collection/segments.d.ts +16 -3
  20. package/dist/src/collection/segments.d.ts.map +1 -1
  21. package/dist/src/collection/segments.js +24 -7
  22. package/dist/src/collection/segments.js.map +1 -1
  23. package/dist/src/collection/write-attempts.d.ts +5 -3
  24. package/dist/src/collection/write-attempts.d.ts.map +1 -1
  25. package/dist/src/collection/write-attempts.js +7 -5
  26. package/dist/src/collection/write-attempts.js.map +1 -1
  27. package/dist/src/collections/tree/tree.d.ts +5 -4
  28. package/dist/src/collections/tree/tree.d.ts.map +1 -1
  29. package/dist/src/collections/tree/tree.js +1 -1
  30. package/dist/src/collections/tree/tree.js.map +1 -1
  31. package/dist/src/network/block-size.d.ts +30 -5
  32. package/dist/src/network/block-size.d.ts.map +1 -1
  33. package/dist/src/network/block-size.js +34 -6
  34. package/dist/src/network/block-size.js.map +1 -1
  35. package/dist/src/network/i-key-network.d.ts +28 -0
  36. package/dist/src/network/i-key-network.d.ts.map +1 -1
  37. package/dist/src/network/i-peer-network.d.ts +5 -0
  38. package/dist/src/network/i-peer-network.d.ts.map +1 -1
  39. package/dist/src/network/i-repo.d.ts +4 -0
  40. package/dist/src/network/i-repo.d.ts.map +1 -1
  41. package/dist/src/network/promise-shortfall-error.d.ts +5 -1
  42. package/dist/src/network/promise-shortfall-error.d.ts.map +1 -1
  43. package/dist/src/network/promise-shortfall-error.js +5 -1
  44. package/dist/src/network/promise-shortfall-error.js.map +1 -1
  45. package/dist/src/network/struct.d.ts +5 -1
  46. package/dist/src/network/struct.d.ts.map +1 -1
  47. package/dist/src/network/struct.js.map +1 -1
  48. package/dist/src/network/transaction-size.d.ts +37 -8
  49. package/dist/src/network/transaction-size.d.ts.map +1 -1
  50. package/dist/src/network/transaction-size.js +36 -7
  51. package/dist/src/network/transaction-size.js.map +1 -1
  52. package/dist/src/transaction/coordinator.d.ts +5 -3
  53. package/dist/src/transaction/coordinator.d.ts.map +1 -1
  54. package/dist/src/transaction/coordinator.js +9 -7
  55. package/dist/src/transaction/coordinator.js.map +1 -1
  56. package/dist/src/transform/helpers.d.ts +12 -2
  57. package/dist/src/transform/helpers.d.ts.map +1 -1
  58. package/dist/src/transform/helpers.js +18 -2
  59. package/dist/src/transform/helpers.js.map +1 -1
  60. package/package.json +1 -1
  61. package/src/chain/chain.ts +15 -3
  62. package/src/cluster/membership.ts +129 -87
  63. package/src/cluster/structs.ts +21 -0
  64. package/src/cohort-topic/willingness.ts +39 -22
  65. package/src/collection/collection.ts +78 -14
  66. package/src/collection/segments.ts +30 -7
  67. package/src/collection/write-attempts.ts +7 -5
  68. package/src/collections/tree/tree.ts +5 -4
  69. package/src/network/block-size.ts +40 -6
  70. package/src/network/i-key-network.ts +30 -0
  71. package/src/network/i-peer-network.ts +6 -0
  72. package/src/network/i-repo.ts +4 -0
  73. package/src/network/promise-shortfall-error.ts +5 -1
  74. package/src/network/struct.ts +5 -1
  75. package/src/network/transaction-size.ts +35 -7
  76. package/src/transaction/coordinator.ts +9 -6
  77. package/src/transform/helpers.ts +19 -2
@@ -70,10 +70,20 @@ export declare function concatTransforms(...transforms: Transforms[]): Transform
70
70
  * when `updates` ride along) to affect the original Transforms.
71
71
  * @see docs/internals.md "Shallow Copy of Transforms" pitfall
72
72
  *
73
- * NOTE: clones unconditionally, even for read-only callers (e.g. StorageRepo.pend's classify pass);
74
- * if large inserts ever show up in a pend/commit profile, add a non-cloning variant for those callers.
73
+ * NOTE: clones unconditionally, even for read-only callers (the reservation reads in
74
+ * `ClusterMember.reservationRequestOf` and `CoordinatorRepo.corroborateHeldBlocks`, both in cohorts of
75
+ * four and up); if they ever show up in a pend profile, give them {@link sharedTransformForBlockId}.
75
76
  */
76
77
  export declare function transformForBlockId(transform: Transforms, blockId: BlockId): Transform;
78
+ /**
79
+ * The transform for one block, SHARING `transform`'s inserted block and update list rather than
80
+ * copying them: for a caller that only reads the result, or serializes it at once, and keeps nothing
81
+ * of it. `StorageRepo.pend` reads it to classify a block and hands it to storage, which encodes it to
82
+ * JSON before returning. Anything that applies, changes or holds on to the result takes
83
+ * {@link transformForBlockId}, whose copy is what makes that safe.
84
+ * @see docs/internals.md "Functions That Share"
85
+ */
86
+ export declare function sharedTransformForBlockId(transform: Transforms, blockId: BlockId): Transform;
77
87
  export declare function transformsFromTransform(transform: Transform, blockId: BlockId): Transforms;
78
88
  export declare function applyTransformToStore<T extends IBlock>(transform: Transforms, store: BlockStore<T>): void;
79
89
  /** Applies a transform to the given block */
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/transform/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEvH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAA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,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAYxE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAwB1E;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAIhE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,UAAU,EAAE,UAAU,EAAE,GAAG,UAAU,CAExE;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,CAQtF;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,CAM5F;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU,CAM1F;AAED,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,QAYlG;AAED,6CAA6C;AAC7C,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAWlG;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,UAAU,CAE1G"}
@@ -154,8 +154,9 @@ export function concatTransforms(...transforms) {
154
154
  * when `updates` ride along) to affect the original Transforms.
155
155
  * @see docs/internals.md "Shallow Copy of Transforms" pitfall
156
156
  *
157
- * NOTE: clones unconditionally, even for read-only callers (e.g. StorageRepo.pend's classify pass);
158
- * if large inserts ever show up in a pend/commit profile, add a non-cloning variant for those callers.
157
+ * NOTE: clones unconditionally, even for read-only callers (the reservation reads in
158
+ * `ClusterMember.reservationRequestOf` and `CoordinatorRepo.corroborateHeldBlocks`, both in cohorts of
159
+ * four and up); if they ever show up in a pend profile, give them {@link sharedTransformForBlockId}.
159
160
  */
160
161
  export function transformForBlockId(transform, blockId) {
161
162
  return {
@@ -166,6 +167,21 @@ export function transformForBlockId(transform, blockId) {
166
167
  ...(transform.deletes?.includes(blockId) ? { delete: true } : {})
167
168
  };
168
169
  }
170
+ /**
171
+ * The transform for one block, SHARING `transform`'s inserted block and update list rather than
172
+ * copying them: for a caller that only reads the result, or serializes it at once, and keeps nothing
173
+ * of it. `StorageRepo.pend` reads it to classify a block and hands it to storage, which encodes it to
174
+ * JSON before returning. Anything that applies, changes or holds on to the result takes
175
+ * {@link transformForBlockId}, whose copy is what makes that safe.
176
+ * @see docs/internals.md "Functions That Share"
177
+ */
178
+ export function sharedTransformForBlockId(transform, blockId) {
179
+ return {
180
+ ...(transform.inserts && blockId in transform.inserts ? { insert: transform.inserts[blockId] } : {}),
181
+ ...(transform.updates && blockId in transform.updates ? { updates: transform.updates[blockId] } : {}),
182
+ ...(transform.deletes?.includes(blockId) ? { delete: true } : {})
183
+ };
184
+ }
169
185
  export function transformsFromTransform(transform, blockId) {
170
186
  return {
171
187
  inserts: transform.insert ? { [blockId]: transform.insert } : {},
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/transform/helpers.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAiB;IACnG,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,KAAwB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC5F,CAAC;SAAM,CAAC;QACN,KAAwB,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AAE,CAAC,CAAC;QAC3B,CAAC;IACF,CAAC;AACF,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,cAAc,CAAC,KAAyB,EAAE,SAAoB;IAC7E,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;QACtB,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC;IAC1B,CAAC;IACD,IAAI,KAAK,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;QAChC,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,UAAsB,EAAE,OAAgB,EAAE,SAAoB;IAC7F,OAAO,eAAe,CAAC,UAAU,EAAE,uBAAuB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AACjF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimystic/db-core",
3
- "version": "1.26.0",
3
+ "version": "1.28.0",
4
4
  "type": "module",
5
5
  "description": "Core database functionality for Optimystic",
6
6
  "main": "dist/src/index.js",
@@ -163,6 +163,10 @@ export class Chain<TEntry> {
163
163
  * new block afterwards (the log's `priorHash`) nor what a caller writes into an entry after the add
164
164
  * (the log's `blockIds`) — both small against the gap between the target and the most a block may
165
165
  * hold.
166
+ *
167
+ * Nothing is measured that cannot change the answer, since for a large write each measure is a
168
+ * whole pass over row data: a lone entry for an empty block, which takes it whatever its size, and
169
+ * an entry offered to a block already at the target, which takes nothing more.
166
170
  */
167
171
  private takenBy(block: ChainDataNode<TEntry>, entries: readonly TEntry[], start: number): number {
168
172
  const room = Math.max(0, Math.min(EntriesPerBlock - block.entries.length, entries.length - start));
@@ -170,13 +174,21 @@ export class Chain<TEntry> {
170
174
  if (target === undefined || room === 0) {
171
175
  return room;
172
176
  }
173
- // NOTE: serializes the whole tail block once per append, the same order of cost as the commit
174
- // path's digest of every touched block. If appends to large logs ever show this in a profile,
175
- // keep a running byte count for the tail instead of re-measuring it.
177
+ if (block.entries.length === 0 && room === 1) {
178
+ return 1;
179
+ }
180
+ // NOTE: serializes the whole tail block once per append — for a large write, usually the
181
+ // previous large entry — the same order of cost as the commit path's digest of every touched
182
+ // block. If appends to large logs ever show this in a profile, keep a running byte count for the
183
+ // tail instead of re-measuring it.
176
184
  let bytes = jsonEncodedBytes(block);
177
185
  let held = block.entries.length;
178
186
  let taken = 0;
179
187
  for (; taken < room; ++taken) {
188
+ // Any entry adds at least its separating comma, so a block holding one at the target is full.
189
+ if (held > 0 && bytes >= target) {
190
+ break;
191
+ }
180
192
  // Each entry after the first adds its own JSON plus the separating comma.
181
193
  const grown = bytes + jsonEncodedBytes(entries[start + taken]) + (held > 0 ? 1 : 0);
182
194
  if (held > 0 && grown > target) {
@@ -1,87 +1,129 @@
1
- import type { RepoMessage } from "../network/repo-protocol.js";
2
- import type { ClusterPeers, ClusterRecord, Signature } from "./structs.js";
3
- import { sha256 } from "multiformats/hashes/sha2";
4
- import { base58btc } from "multiformats/bases/base58";
5
- import { toString as uint8ArrayToString } from "uint8arrays/to-string";
6
- import { canonicalJson } from "../utility/canonical-json.js";
7
-
8
- /**
9
- * Membership-binding version a new coordinator emits. A record at this version folds a
10
- * {@link membershipDigest} of its peer set into `messageHash` / `promiseHash` / `commitHash`, so the
11
- * responsible peer set is covered by every signature (see `docs/correctness.md` §2). Absent or `1` marks
12
- * a legacy *unbound* record (pre-binding history) whose hashes must verify byte-identically to before
13
- * this change.
14
- */
15
- export const CURRENT_MEMBERSHIP_VERSION = 2 as const;
16
-
17
- /**
18
- * Canonical membership digest for a peer set: `base64url(SHA256(canonicalJson(sorted peer-id list)))`.
19
- *
20
- * Derived from the sorted peer-id list ONLY — not multiaddrs or public keys. Multiaddrs churn and a
21
- * peer's public key is already a function of its id, so folding either in would make identity unstable
22
- * without adding agreement value. The set of ids IS the membership. The digest is therefore independent
23
- * of peer-map key insertion order and of multiaddr / pubkey contents; adding or removing one id changes
24
- * it. `membershipDigest({})` (the empty set) is a fixed constant.
25
- */
26
- export async function membershipDigest(peers: ClusterPeers): Promise<string> {
27
- return membershipDigestFromIds(Object.keys(peers ?? {}));
28
- }
29
-
30
- /**
31
- * Canonical membership digest for an explicit peer-id list — the same digest {@link membershipDigest}
32
- * derives from a peer map's keys. ONE implementation, so a verifier reading a stored `peerIds` list
33
- * (e.g. a persisted block commit proof) and a coordinator reading live `ClusterPeers` can never
34
- * disagree. Sorts a copy; the caller's array is not mutated.
35
- */
36
- export async function membershipDigestFromIds(ids: readonly string[]): Promise<string> {
37
- const sorted = [...ids].sort();
38
- const bytes = new TextEncoder().encode(canonicalJson(sorted));
39
- const hash = await sha256.digest(bytes);
40
- return uint8ArrayToString(hash.digest, 'base64url');
41
- }
42
-
43
- /**
44
- * The membership digest that participates in a record's hashes, or `undefined` for a legacy (v1 /
45
- * unversioned) record. `undefined` selects the pre-binding hashing (empty-string concat is a no-op), so
46
- * a v1 record hashes byte-identically to before this change. A v2 record folds in its declared
47
- * `membershipDigest`.
48
- */
49
- export function recordMembershipDigest(record: Pick<ClusterRecord, 'membershipVersion' | 'membershipDigest'>): string | undefined {
50
- return record.membershipVersion === 2 ? record.membershipDigest : undefined;
51
- }
52
-
53
- /**
54
- * `messageHash` = `base58btc(SHA256(canonicalJson(message) + digest))`.
55
- *
56
- * `digest` `undefined` → legacy v1 preimage (`canonicalJson(message)` only); passing the membership
57
- * digest folds the peer set in (v2). Empty-string concat means the v1 image is byte-identical to the
58
- * pre-binding implementation.
59
- */
60
- export async function computeClusterMessageHash(message: RepoMessage, digest?: string): Promise<string> {
61
- const bytes = new TextEncoder().encode(canonicalJson(message) + (digest ?? ''));
62
- const hash = await sha256.digest(bytes);
63
- return base58btc.encode(hash.digest);
64
- }
65
-
66
- /**
67
- * `promiseHash` = `base64url(SHA256(messageHash + canonicalJson(message) + digest))`.
68
- *
69
- * `digest` `undefined` → legacy v1 preimage; passing it folds the peer set in (v2).
70
- */
71
- export async function computeClusterPromiseHash(messageHash: string, message: RepoMessage, digest?: string): Promise<string> {
72
- const bytes = new TextEncoder().encode(messageHash + canonicalJson(message) + (digest ?? ''));
73
- const hash = await sha256.digest(bytes);
74
- return uint8ArrayToString(hash.digest, 'base64url');
75
- }
76
-
77
- /**
78
- * `commitHash` = `base64url(SHA256(messageHash + canonicalJson(message) + digest + canonicalJson(promises)))`.
79
- *
80
- * `digest` `undefined` → legacy v1 preimage; passing it folds the peer set in (v2). The digest sits
81
- * between the message and the promises image, matching the v2 layout in `docs/correctness.md`.
82
- */
83
- export async function computeClusterCommitHash(messageHash: string, message: RepoMessage, promises: Record<string, Signature>, digest?: string): Promise<string> {
84
- const bytes = new TextEncoder().encode(messageHash + canonicalJson(message) + (digest ?? '') + canonicalJson(promises));
85
- const hash = await sha256.digest(bytes);
86
- return uint8ArrayToString(hash.digest, 'base64url');
87
- }
1
+ import type { RepoMessage } from "../network/repo-protocol.js";
2
+ import type { ClusterPeers, ClusterRecord, Signature } from "./structs.js";
3
+ import { sha256 } from "multiformats/hashes/sha2";
4
+ import { base58btc } from "multiformats/bases/base58";
5
+ import { toString as uint8ArrayToString } from "uint8arrays/to-string";
6
+ import { concat } from "uint8arrays/concat";
7
+ import { canonicalJson } from "../utility/canonical-json.js";
8
+
9
+ /**
10
+ * Membership-binding version a new coordinator emits. A record at this version folds a
11
+ * {@link membershipDigest} of its peer set into `messageHash` / `promiseHash` / `commitHash`, so the
12
+ * responsible peer set is covered by every signature (see `docs/correctness.md` §2). Absent or `1` marks
13
+ * a legacy *unbound* record (pre-binding history) whose hashes must verify byte-identically to before
14
+ * this change.
15
+ */
16
+ export const CURRENT_MEMBERSHIP_VERSION = 2 as const;
17
+
18
+ /**
19
+ * Canonical membership digest for a peer set: `base64url(SHA256(canonicalJson(sorted peer-id list)))`.
20
+ *
21
+ * Derived from the sorted peer-id list ONLY — not multiaddrs or public keys. Multiaddrs churn and a
22
+ * peer's public key is already a function of its id, so folding either in would make identity unstable
23
+ * without adding agreement value. The set of ids IS the membership. The digest is therefore independent
24
+ * of peer-map key insertion order and of multiaddr / pubkey contents; adding or removing one id changes
25
+ * it. `membershipDigest({})` (the empty set) is a fixed constant.
26
+ */
27
+ export async function membershipDigest(peers: ClusterPeers): Promise<string> {
28
+ return membershipDigestFromIds(Object.keys(peers ?? {}));
29
+ }
30
+
31
+ /**
32
+ * Canonical membership digest for an explicit peer-id list — the same digest {@link membershipDigest}
33
+ * derives from a peer map's keys. ONE implementation, so a verifier reading a stored `peerIds` list
34
+ * (e.g. a persisted block commit proof) and a coordinator reading live `ClusterPeers` can never
35
+ * disagree. Sorts a copy; the caller's array is not mutated.
36
+ */
37
+ export async function membershipDigestFromIds(ids: readonly string[]): Promise<string> {
38
+ const sorted = [...ids].sort();
39
+ const bytes = new TextEncoder().encode(canonicalJson(sorted));
40
+ const hash = await sha256.digest(bytes);
41
+ return uint8ArrayToString(hash.digest, 'base64url');
42
+ }
43
+
44
+ /**
45
+ * The membership digest that participates in a record's hashes, or `undefined` for a legacy (v1 /
46
+ * unversioned) record. `undefined` selects the pre-binding hashing (empty-string concat is a no-op), so
47
+ * a v1 record hashes byte-identically to before this change. A v2 record folds in its declared
48
+ * `membershipDigest`.
49
+ */
50
+ export function recordMembershipDigest(record: Pick<ClusterRecord, 'membershipVersion' | 'membershipDigest'>): string | undefined {
51
+ return record.membershipVersion === 2 ? record.membershipDigest : undefined;
52
+ }
53
+
54
+ const encoder = new TextEncoder();
55
+ // The template literal is what keeps a hostile part hashing as the string concatenation did: a record off
56
+ // the wire (a dispute's `originalRecord`, a proof) may carry no `messageHash` or `promises` at all, which
57
+ // the old `+` spelled "undefined", where `TextEncoder.encode(undefined)` would encode nothing. (Two
58
+ // adjacent missing parts the old `+` added to "NaN"; no record that reaches a signer has that shape.)
59
+ const utf8 = (text: string | undefined): Uint8Array => encoder.encode(`${text}`);
60
+
61
+ // NOTE: the memo is sound only because no `RepoMessage` is changed once it has been hashed: a message
62
+ // mutated after its first hash would go on hashing as it was, and a signature would then cover content
63
+ // the record no longer holds. Build a new message (`{ ...message, field }`) rather than assigning into one.
64
+ // NOTE: holds one more copy of each message for as long as the message object lives, which on a member
65
+ // is as long as it keeps the record; if member memory under large writes ever matters, drop the entry
66
+ // once the record is decided. Weak, so it never outlives its message; and a message received off the
67
+ // wire was bounded by the frame cap before it was decoded, so the memo costs no more than the record.
68
+ const messageBytes = new WeakMap<RepoMessage, Uint8Array>();
69
+
70
+ /**
71
+ * The UTF-8 bytes of `canonicalJson(message)`, computed once per message object. A record's `message`
72
+ * is the whole pend or commit, row data included, and one delivery of a record reads it several times —
73
+ * its message, promise and commit hashes, and `mergeRecords`' comparison — so each of those shares these
74
+ * bytes rather than serializing the message again. The bytes are shared: never write to them.
75
+ */
76
+ export function canonicalMessageBytes(message: RepoMessage): Uint8Array {
77
+ const held = messageBytes.get(message);
78
+ if (held !== undefined) return held;
79
+ // A record off the wire is hashed before its shape is checked, so `message` may be no object at all;
80
+ // such a message is never memoized (a WeakMap refuses it as a key), and `utf8` spells `canonicalJson`'s
81
+ // `undefined` for a value JSON cannot encode as the string preimage always did.
82
+ const bytes = utf8(canonicalJson(message));
83
+ if (typeof message === 'object' && message !== null) messageBytes.set(message, bytes);
84
+ return bytes;
85
+ }
86
+
87
+ /**
88
+ * SHA-256 over the preimage `parts` spell, joined: the same bytes as encoding the joined string, so the
89
+ * signed layout of `docs/correctness.md` §2 is unchanged. UTF-8 encoding commutes with concatenation
90
+ * except where a part ending in a high surrogate meets one starting with a low surrogate (joined they
91
+ * are one character, apart two replacement characters). Every boundary in these preimages has a JSON
92
+ * text on one side, which begins and ends with an ASCII character, so that never happens — even for a
93
+ * hostile record whose `messageHash` or digest is not well-formed.
94
+ */
95
+ async function hashParts(parts: Uint8Array[]): Promise<Uint8Array> {
96
+ return (await sha256.digest(concat(parts))).digest;
97
+ }
98
+
99
+ /**
100
+ * `messageHash` = `base58btc(SHA256(canonicalJson(message) + digest))`.
101
+ *
102
+ * `digest` `undefined` → legacy v1 preimage (`canonicalJson(message)` only); passing the membership
103
+ * digest folds the peer set in (v2). An absent digest contributes no bytes, so the v1 image is
104
+ * byte-identical to the pre-binding implementation.
105
+ */
106
+ export async function computeClusterMessageHash(message: RepoMessage, digest?: string): Promise<string> {
107
+ return base58btc.encode(await hashParts([canonicalMessageBytes(message), utf8(digest ?? '')]));
108
+ }
109
+
110
+ /**
111
+ * `promiseHash` = `base64url(SHA256(messageHash + canonicalJson(message) + digest))`.
112
+ *
113
+ * `digest` `undefined` → legacy v1 preimage; passing it folds the peer set in (v2).
114
+ */
115
+ export async function computeClusterPromiseHash(messageHash: string, message: RepoMessage, digest?: string): Promise<string> {
116
+ const hash = await hashParts([utf8(messageHash), canonicalMessageBytes(message), utf8(digest ?? '')]);
117
+ return uint8ArrayToString(hash, 'base64url');
118
+ }
119
+
120
+ /**
121
+ * `commitHash` = `base64url(SHA256(messageHash + canonicalJson(message) + digest + canonicalJson(promises)))`.
122
+ *
123
+ * `digest` `undefined` → legacy v1 preimage; passing it folds the peer set in (v2). The digest sits
124
+ * between the message and the promises image, matching the v2 layout in `docs/correctness.md`.
125
+ */
126
+ export async function computeClusterCommitHash(messageHash: string, message: RepoMessage, promises: Record<string, Signature>, digest?: string): Promise<string> {
127
+ const hash = await hashParts([utf8(messageHash), canonicalMessageBytes(message), utf8(digest ?? ''), utf8(canonicalJson(promises))]);
128
+ return uint8ArrayToString(hash, 'base64url');
129
+ }
@@ -439,6 +439,27 @@ export interface ClusterConsensusConfig {
439
439
  readRepairWindowMs?: number;
440
440
  /** Per-read probability of triggering read-repair in 'lazy' mode even within the window (0..1). Default 0 (no random check). */
441
441
  readRepairSampleRate?: number;
442
+ /**
443
+ * For 'lazy' mode: how long after a consult that heard from every other member of a held block's
444
+ * cohort and found nothing ahead the block may go without another one, while every commit to it
445
+ * needs every member's promise (two or three members at the default threshold), every member has
446
+ * stayed connected to this node, and this node holds no pending record for the block. Default
447
+ * 300 000 (`DEFAULT_READ_REPAIR_QUIET_WINDOW_MS` in db-p2p); `0` turns it off, and so in effect
448
+ * does any value at or below `readRepairWindowMs`. See docs/transactions.md § Lazy read-repair
449
+ * window. On a node, set through `clusterPolicy.readRepairQuietWindowMs`.
450
+ */
451
+ readRepairQuietWindowMs?: number;
452
+ /**
453
+ * For 'lazy' mode: how long, in milliseconds, a consult started behind a read waits for the
454
+ * consults started by other reads, so that all of them ask each cohort peer in one request. The
455
+ * shared round sends this long after its first block joins, or at once when it names 32 blocks
456
+ * (one request's worth). Default 250 (`DEFAULT_READ_REPAIR_COALESCE_MS` in db-p2p); `0` sends each
457
+ * read's background consults on their own, as before. No read waits for it: only consults the read
458
+ * was already answered without join the shared round. It adds up to this long to how soon what a
459
+ * consult learns reaches the reads after it. See docs/transactions.md § Lazy read-repair window. On
460
+ * a node, set through `clusterPolicy.readRepairCoalesceMs`.
461
+ */
462
+ readRepairCoalesceMs?: number;
442
463
  /**
443
464
  * How long ONE cohort peer gets to answer ONE read-path request, in milliseconds (default
444
465
  * {@link DEFAULT_COHORT_QUERY_TIMEOUT_MS} = 1000). It sets BOTH per-peer deadlines on the read
@@ -49,8 +49,8 @@ export interface UnwillingCohortOutcome {
49
49
  * True iff the quorum is short only because cohort members have not gossiped yet: it would be met if
50
50
  * every member this check holds no contribution from turned out willing. A member that has gossiped
51
51
  * *unwilling* counts as heard, so a cohort whose answers are in and short reports `false` — as does an
52
- * unserviceable tier, and a check given no {@link WillingnessDeps.cohortMembers}. The cohort side may hold
53
- * the request briefly for those answers instead of declining (§Cold-start instantiation).
52
+ * unserviceable tier. The cohort side may hold the request briefly for those answers instead of declining
53
+ * (§Cold-start instantiation).
54
54
  */
55
55
  readonly awaitingMembers: boolean;
56
56
  }
@@ -130,13 +130,13 @@ export function backoffRetryMs(attempt: number, config: BackoffConfig = DEFAULT_
130
130
  // --- willingness check ---
131
131
 
132
132
  export interface WillingnessConfig {
133
- /** Cohort size `k` (drives the default quorum). Default 16. */
134
- cohortSize?: number;
135
133
  /**
136
134
  * Members that must be willing to serve a tier for the cohort to take it on (the admission quorum,
137
- * `docs/cohort-topic.md` §Admission quorum). Default: strict majority of `cohortSize`
138
- * ({@link defaultQuorum}). Deliberately not the threshold-signature `minSigs = k − x` — see the doc
139
- * for why the two differ and when to revisit the default.
135
+ * `docs/cohort-topic.md` §Admission quorum). Default: a strict majority ({@link defaultQuorum}) of the
136
+ * cohort as {@link WillingnessDeps.cohortMembers} lists it at each evaluation, so a cohort smaller than
137
+ * `wantK` — every cohort on a network of fewer machines — admits on a majority of the members it has.
138
+ * Deliberately not the threshold-signature `minSigs = k − x` — see the doc for why the two differ and
139
+ * when to revisit the default.
140
140
  */
141
141
  quorum?: number;
142
142
  /** Load bucket at/above which a tier is shed. Default {@link DEFAULT_OVERLOAD_BUCKET} (6). */
@@ -158,11 +158,12 @@ export interface WillingnessDeps {
158
158
  /** This member's own id, base64url (the `fromMember` key) — excluded from the sibling scan. */
159
159
  selfMember: string;
160
160
  /**
161
- * The cohort's current members, base64url (the form {@link selfMember} and the view keys use), read at
162
- * each evaluation. It tells a member that has not gossiped yet apart from one that gossiped unwilling
163
- * ({@link UnwillingCohortOutcome.awaitingMembers}). Absent → no member counts as unheard.
161
+ * The cohort's current members, base64url (the form {@link selfMember} and the view keys use), read once
162
+ * per evaluation. Its size, self counted once whether listed or not, is what the default quorum is a
163
+ * majority of; and it tells a member that has not gossiped yet apart from one that gossiped unwilling
164
+ * ({@link UnwillingCohortOutcome.awaitingMembers}).
164
165
  */
165
- cohortMembers?: () => readonly string[];
166
+ cohortMembers: () => readonly string[];
166
167
  /** Count of topics this member is already `primary` for at `tier` (the budget gate input). */
167
168
  primaryTopicCount: (tier: Tier) => number;
168
169
  /**
@@ -178,8 +179,14 @@ export function defaultQuorum(cohortSize: number): number {
178
179
  return Math.floor(cohortSize / 2) + 1;
179
180
  }
180
181
 
182
+ /** The cohort as one evaluation sees it: every member, self included once, and those not yet heard from. */
183
+ interface CohortReading {
184
+ readonly size: number;
185
+ readonly unheard: number;
186
+ }
187
+
181
188
  class GossipWillingnessCheck implements WillingnessCheck {
182
- private readonly quorum: number;
189
+ private readonly quorumOverride: number | undefined;
183
190
  private readonly overloadBucket: number;
184
191
  private readonly maxPrimaryTopicsPerTier: number;
185
192
  private readonly backoff: BackoffConfig;
@@ -187,8 +194,7 @@ class GossipWillingnessCheck implements WillingnessCheck {
187
194
 
188
195
  constructor(private readonly deps: WillingnessDeps) {
189
196
  const cfg = deps.config ?? {};
190
- const cohortSize = cfg.cohortSize ?? 16;
191
- this.quorum = cfg.quorum ?? defaultQuorum(cohortSize);
197
+ this.quorumOverride = cfg.quorum;
192
198
  this.overloadBucket = cfg.overloadBucket ?? DEFAULT_OVERLOAD_BUCKET;
193
199
  this.maxPrimaryTopicsPerTier = cfg.maxPrimaryTopicsPerTier ?? 2048;
194
200
  this.backoff = cfg.backoff ?? DEFAULT_BACKOFF_CONFIG;
@@ -205,11 +211,13 @@ class GossipWillingnessCheck implements WillingnessCheck {
205
211
  const selfWilling = this.selfLiveWilling(self, tier);
206
212
  const siblings = this.willingSiblings(tier);
207
213
  const willingCount = siblings.length + (selfWilling ? 1 : 0);
214
+ const cohort = this.readCohort();
215
+ const quorum = this.quorumOverride ?? defaultQuorum(cohort.size);
208
216
 
209
217
  // Quorum gate (§Tier ladder): the cohort takes on tier-T duties only if a quorum of members
210
218
  // is willing; otherwise registrations get UnwillingCohort and the caller backs off in time.
211
- if (willingCount < this.quorum) {
212
- return this.declineCohort(reg, willingCount + this.unheardMemberCount() >= this.quorum);
219
+ if (willingCount < quorum) {
220
+ return this.declineCohort(reg, willingCount + cohort.unheard >= quorum);
213
221
  }
214
222
  if (selfWilling) {
215
223
  return { kind: "accepted" };
@@ -222,15 +230,21 @@ class GossipWillingnessCheck implements WillingnessCheck {
222
230
  return { kind: "unwilling_cohort", retryAfterMs: backoffRetryMs(this.attempts(reg), this.backoff), awaitingMembers };
223
231
  }
224
232
 
225
- /** Cohort members other than self this check holds no gossiped contribution from. */
226
- private unheardMemberCount(): number {
227
- const unheard = new Set<string>();
228
- for (const member of this.deps.cohortMembers?.() ?? []) {
233
+ /**
234
+ * Read the cohort once: its size with self counted once (a snapshot that omits self — a root group that
235
+ * rotated past this node — still has self deciding), and the members other than self this check holds
236
+ * no gossiped contribution from.
237
+ */
238
+ private readCohort(): CohortReading {
239
+ const members = new Set<string>(this.deps.cohortMembers());
240
+ members.add(this.deps.selfMember);
241
+ let unheard = 0;
242
+ for (const member of members) {
229
243
  if (member !== this.deps.selfMember && this.deps.view.get(member) === undefined) {
230
- unheard.add(member);
244
+ unheard++;
231
245
  }
232
246
  }
233
- return unheard.size;
247
+ return { size: members.size, unheard };
234
248
  }
235
249
 
236
250
  /** Live willingness of *this* member for `tier`: profile ∧ load-under-threshold ∧ under budget. */
@@ -244,6 +258,9 @@ class GossipWillingnessCheck implements WillingnessCheck {
244
258
 
245
259
  /** Sibling member keys (base64url) whose *gossiped* willingness vector serves `tier`. */
246
260
  private willingSiblings(tier: Tier): string[] {
261
+ // NOTE: counts every member the view holds a contribution from, including one no longer in `cohortMembers`,
262
+ // against a quorum taken over `cohortMembers`; if admissions or `unwilling_member` candidates are seen resting
263
+ // on members that left the cohort, count only siblings in the list `readCohort` read.
247
264
  const out: string[] = [];
248
265
  for (const [member, contribution] of this.deps.view.all()) {
249
266
  if (member === this.deps.selfMember) continue; // self counted via live willingness