@optimystic/db-core 1.22.0 → 1.23.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 +8 -4
- package/dist/src/collection/action.d.ts +7 -4
- package/dist/src/collection/action.d.ts.map +1 -1
- package/dist/src/collection/action.js +13 -5
- package/dist/src/collection/action.js.map +1 -1
- package/dist/src/collection/collection.d.ts +134 -46
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +207 -70
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collection/struct.d.ts +38 -8
- package/dist/src/collection/struct.d.ts.map +1 -1
- package/dist/src/collection/struct.js.map +1 -1
- package/dist/src/collection/write-attempts.d.ts +138 -34
- package/dist/src/collection/write-attempts.d.ts.map +1 -1
- package/dist/src/collection/write-attempts.js +168 -101
- package/dist/src/collection/write-attempts.js.map +1 -1
- package/dist/src/collections/diary/diary.d.ts.map +1 -1
- package/dist/src/collections/diary/diary.js +5 -1
- package/dist/src/collections/diary/diary.js.map +1 -1
- package/dist/src/collections/tree/tree.d.ts +15 -9
- package/dist/src/collections/tree/tree.d.ts.map +1 -1
- package/dist/src/collections/tree/tree.js +6 -4
- package/dist/src/collections/tree/tree.js.map +1 -1
- package/dist/src/hlc/clock-store.d.ts +63 -0
- package/dist/src/hlc/clock-store.d.ts.map +1 -0
- package/dist/src/hlc/clock-store.js +49 -0
- package/dist/src/hlc/clock-store.js.map +1 -0
- package/dist/src/hlc/clock.d.ts +64 -0
- package/dist/src/hlc/clock.d.ts.map +1 -0
- package/dist/src/hlc/clock.js +171 -0
- package/dist/src/hlc/clock.js.map +1 -0
- package/dist/src/hlc/hlc.d.ts +38 -0
- package/dist/src/hlc/hlc.d.ts.map +1 -0
- package/dist/src/hlc/hlc.js +41 -0
- package/dist/src/hlc/hlc.js.map +1 -0
- package/dist/src/hlc/index.d.ts +5 -0
- package/dist/src/hlc/index.d.ts.map +1 -0
- package/dist/src/hlc/index.js +5 -0
- package/dist/src/hlc/index.js.map +1 -0
- package/dist/src/hlc/skew.d.ts +35 -0
- package/dist/src/hlc/skew.d.ts.map +1 -0
- package/dist/src/hlc/skew.js +35 -0
- package/dist/src/hlc/skew.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lane/index.d.ts +2 -0
- package/dist/src/lane/index.d.ts.map +1 -0
- package/dist/src/lane/index.js +2 -0
- package/dist/src/lane/index.js.map +1 -0
- package/dist/src/lane/lane.d.ts +46 -0
- package/dist/src/lane/lane.d.ts.map +1 -0
- package/dist/src/lane/lane.js +26 -0
- package/dist/src/lane/lane.js.map +1 -0
- package/dist/src/log/log.d.ts +50 -22
- package/dist/src/log/log.d.ts.map +1 -1
- package/dist/src/log/log.js +21 -13
- package/dist/src/log/log.js.map +1 -1
- package/dist/src/log/struct.d.ts +61 -1
- package/dist/src/log/struct.d.ts.map +1 -1
- package/dist/src/log/struct.js +24 -0
- package/dist/src/log/struct.js.map +1 -1
- package/dist/src/network/i-repo.d.ts +10 -0
- package/dist/src/network/i-repo.d.ts.map +1 -1
- package/dist/src/network/stale-failure.d.ts +20 -7
- package/dist/src/network/stale-failure.d.ts.map +1 -1
- package/dist/src/network/stale-failure.js +29 -7
- package/dist/src/network/stale-failure.js.map +1 -1
- package/dist/src/network/struct.d.ts +35 -0
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/network/struct.js.map +1 -1
- package/dist/src/offline/entry.d.ts +14 -0
- package/dist/src/offline/entry.d.ts.map +1 -1
- package/dist/src/offline/entry.js +2 -0
- package/dist/src/offline/entry.js.map +1 -1
- package/dist/src/offline/journal.d.ts +10 -0
- package/dist/src/offline/journal.d.ts.map +1 -1
- package/dist/src/offline/queue.d.ts +10 -0
- package/dist/src/offline/queue.d.ts.map +1 -1
- package/dist/src/offline/queue.js +29 -3
- package/dist/src/offline/queue.js.map +1 -1
- package/dist/src/offline/status.d.ts +7 -0
- package/dist/src/offline/status.d.ts.map +1 -1
- package/dist/src/offline/status.js.map +1 -1
- package/dist/src/testing/test-transactor.d.ts +9 -1
- package/dist/src/testing/test-transactor.d.ts.map +1 -1
- package/dist/src/testing/test-transactor.js +6 -1
- package/dist/src/testing/test-transactor.js.map +1 -1
- package/dist/src/transaction/actions-engine.d.ts +3 -0
- package/dist/src/transaction/actions-engine.d.ts.map +1 -1
- package/dist/src/transaction/actions-engine.js +3 -0
- package/dist/src/transaction/actions-engine.js.map +1 -1
- package/dist/src/transaction/coordinator.d.ts +10 -5
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +197 -48
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transaction/entry-commit.d.ts +45 -10
- package/dist/src/transaction/entry-commit.d.ts.map +1 -1
- package/dist/src/transaction/entry-commit.js +20 -7
- package/dist/src/transaction/entry-commit.js.map +1 -1
- package/dist/src/transaction/errors.d.ts +69 -1
- package/dist/src/transaction/errors.d.ts.map +1 -1
- package/dist/src/transaction/errors.js +70 -1
- package/dist/src/transaction/errors.js.map +1 -1
- package/dist/src/transaction/index.d.ts +1 -1
- package/dist/src/transaction/index.d.ts.map +1 -1
- package/dist/src/transaction/index.js +1 -1
- package/dist/src/transaction/index.js.map +1 -1
- package/dist/src/transaction/session.d.ts.map +1 -1
- package/dist/src/transaction/session.js +18 -5
- package/dist/src/transaction/session.js.map +1 -1
- package/dist/src/transaction/transaction.d.ts +74 -15
- package/dist/src/transaction/transaction.d.ts.map +1 -1
- package/dist/src/transaction/transaction.js +35 -15
- package/dist/src/transaction/transaction.js.map +1 -1
- package/dist/src/transaction/validator.d.ts +25 -4
- package/dist/src/transaction/validator.d.ts.map +1 -1
- package/dist/src/transaction/validator.js +45 -5
- package/dist/src/transaction/validator.js.map +1 -1
- package/dist/src/transactor/block-floors.d.ts +12 -1
- package/dist/src/transactor/block-floors.d.ts.map +1 -1
- package/dist/src/transactor/block-floors.js +14 -1
- package/dist/src/transactor/block-floors.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts +8 -0
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +8 -4
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/dist/src/transactor/transactor-source.d.ts +11 -0
- package/dist/src/transactor/transactor-source.d.ts.map +1 -1
- package/dist/src/transactor/transactor-source.js +5 -1
- package/dist/src/transactor/transactor-source.js.map +1 -1
- package/dist/src/transactor/transactor.d.ts +8 -0
- package/dist/src/transactor/transactor.d.ts.map +1 -1
- package/dist/src/transform/cache-source.d.ts +7 -0
- package/dist/src/transform/cache-source.d.ts.map +1 -1
- package/dist/src/transform/cache-source.js +14 -18
- package/dist/src/transform/cache-source.js.map +1 -1
- package/package.json +1 -1
- package/src/collection/action.ts +13 -5
- package/src/collection/collection.ts +250 -76
- package/src/collection/struct.ts +38 -8
- package/src/collection/write-attempts.ts +213 -109
- package/src/collections/diary/diary.ts +5 -1
- package/src/collections/tree/tree.ts +18 -11
- package/src/hlc/clock-store.ts +68 -0
- package/src/hlc/clock.ts +196 -0
- package/src/hlc/hlc.ts +56 -0
- package/src/hlc/index.ts +4 -0
- package/src/hlc/skew.ts +55 -0
- package/src/index.ts +2 -0
- package/src/lane/index.ts +1 -0
- package/src/lane/lane.ts +54 -0
- package/src/log/log.ts +341 -310
- package/src/log/struct.ts +62 -1
- package/src/network/i-repo.ts +11 -1
- package/src/network/stale-failure.ts +31 -7
- package/src/network/struct.ts +805 -770
- package/src/offline/entry.ts +16 -0
- package/src/offline/journal.ts +10 -0
- package/src/offline/queue.ts +38 -4
- package/src/offline/status.ts +7 -0
- package/src/testing/test-transactor.ts +1065 -1053
- package/src/transaction/actions-engine.ts +3 -0
- package/src/transaction/coordinator.ts +229 -54
- package/src/transaction/entry-commit.ts +56 -14
- package/src/transaction/errors.ts +60 -0
- package/src/transaction/index.ts +1 -1
- package/src/transaction/session.ts +18 -5
- package/src/transaction/transaction.ts +90 -17
- package/src/transaction/validator.ts +46 -5
- package/src/transactor/block-floors.ts +15 -1
- package/src/transactor/network-transactor.ts +15 -4
- package/src/transactor/transactor-source.ts +15 -1
- package/src/transactor/transactor.ts +9 -0
- package/src/transform/cache-source.ts +15 -17
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hybrid logical clock (HLC) value: the Kulkarni-Demirbas construction docs/crdt-sync.md
|
|
3
|
+
* §HLC Generation and Causal Tracking describes, as one plain JSON-safe object, since it travels
|
|
4
|
+
* inside log blocks and pend requests, both plain JSON on the wire.
|
|
5
|
+
*
|
|
6
|
+
* Only `HlcClock` mints one. The other constructors are {@link legacyHlc}, for a record written
|
|
7
|
+
* before the field existed, and test fixtures.
|
|
8
|
+
*/
|
|
9
|
+
export type Hlc = {
|
|
10
|
+
/** Wall-clock milliseconds, or higher: the max of the issuer's clock and the highest HLC it had observed. */
|
|
11
|
+
readonly wallMs: number;
|
|
12
|
+
/** Breaks ties among HLCs issued within one `wallMs`. 0 whenever `wallMs` moved. */
|
|
13
|
+
readonly logical: number;
|
|
14
|
+
/** The issuing node's peer id string. `''` means legacy: an entry written before the field existed. */
|
|
15
|
+
readonly nodeId: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The total order on HLCs: `wallMs`, then `logical`, then `nodeId` by plain string (code unit)
|
|
19
|
+
* comparison. Two HLCs from one node never compare equal, because its clock never issues the same
|
|
20
|
+
* `(wallMs, logical)` twice; two from different nodes are separated by `nodeId`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function compareHlc(a: Hlc, b: Hlc): number;
|
|
23
|
+
/** The later of `a` and `b` by {@link compareHlc}; `b` when `a` is absent. */
|
|
24
|
+
export declare function maxHlc(a: Hlc | undefined, b: Hlc): Hlc;
|
|
25
|
+
/**
|
|
26
|
+
* The HLC a reader derives for an entry or record written before the field existed: its plain
|
|
27
|
+
* timestamp, no logical count, and the empty node id. The empty id sorts before every real peer id,
|
|
28
|
+
* which is the only property anything relies on.
|
|
29
|
+
*/
|
|
30
|
+
export declare function legacyHlc(timestamp: number): Hlc;
|
|
31
|
+
/**
|
|
32
|
+
* Whether a value read off the wire has the shape of an {@link Hlc}: a finite `wallMs`, a `logical`
|
|
33
|
+
* that is a non-negative safe integer (what a clock issues, and what it can count past without
|
|
34
|
+
* losing precision), and a string node id. How far `wallMs` may sit from local time is not a shape
|
|
35
|
+
* question and is not checked here.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isHlc(value: unknown): value is Hlc;
|
|
38
|
+
//# sourceMappingURL=hlc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hlc.d.ts","sourceRoot":"","sources":["../../../src/hlc/hlc.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,GAAG;IACjB,6GAA6G;IAC7G,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uGAAuG;IACvG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAKjD;AAED,8EAA8E;AAC9E,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,GAAG,SAAS,EAAE,CAAC,EAAE,GAAG,GAAG,GAAG,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,CAMlD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The total order on HLCs: `wallMs`, then `logical`, then `nodeId` by plain string (code unit)
|
|
3
|
+
* comparison. Two HLCs from one node never compare equal, because its clock never issues the same
|
|
4
|
+
* `(wallMs, logical)` twice; two from different nodes are separated by `nodeId`.
|
|
5
|
+
*/
|
|
6
|
+
export function compareHlc(a, b) {
|
|
7
|
+
if (a.wallMs !== b.wallMs)
|
|
8
|
+
return a.wallMs < b.wallMs ? -1 : 1;
|
|
9
|
+
if (a.logical !== b.logical)
|
|
10
|
+
return a.logical < b.logical ? -1 : 1;
|
|
11
|
+
if (a.nodeId === b.nodeId)
|
|
12
|
+
return 0;
|
|
13
|
+
return a.nodeId < b.nodeId ? -1 : 1;
|
|
14
|
+
}
|
|
15
|
+
/** The later of `a` and `b` by {@link compareHlc}; `b` when `a` is absent. */
|
|
16
|
+
export function maxHlc(a, b) {
|
|
17
|
+
return a === undefined || compareHlc(b, a) > 0 ? b : a;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The HLC a reader derives for an entry or record written before the field existed: its plain
|
|
21
|
+
* timestamp, no logical count, and the empty node id. The empty id sorts before every real peer id,
|
|
22
|
+
* which is the only property anything relies on.
|
|
23
|
+
*/
|
|
24
|
+
export function legacyHlc(timestamp) {
|
|
25
|
+
return { wallMs: timestamp, logical: 0, nodeId: '' };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether a value read off the wire has the shape of an {@link Hlc}: a finite `wallMs`, a `logical`
|
|
29
|
+
* that is a non-negative safe integer (what a clock issues, and what it can count past without
|
|
30
|
+
* losing precision), and a string node id. How far `wallMs` may sit from local time is not a shape
|
|
31
|
+
* question and is not checked here.
|
|
32
|
+
*/
|
|
33
|
+
export function isHlc(value) {
|
|
34
|
+
if (typeof value !== 'object' || value === null)
|
|
35
|
+
return false;
|
|
36
|
+
const { wallMs, logical, nodeId } = value;
|
|
37
|
+
return typeof wallMs === 'number' && Number.isFinite(wallMs)
|
|
38
|
+
&& Number.isSafeInteger(logical) && logical >= 0
|
|
39
|
+
&& typeof nodeId === 'string';
|
|
40
|
+
}
|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AAE,OAAO,KAAK,CAAC;IAC9D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAgC,CAAC;IACrE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;WACxD,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAK,OAAkB,IAAI,CAAC;WACzD,OAAO,MAAM,KAAK,QAAQ,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hlc/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hlc/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** How many node ids a {@link SkewLedger} remembers; the least recently heard from is forgotten first. */
|
|
2
|
+
export declare const DEFAULT_SKEW_LEDGER_MAX_NODES = 256;
|
|
3
|
+
/**
|
|
4
|
+
* How far one node's HLCs have been from this node's wall clock, over the samples a
|
|
5
|
+
* {@link SkewLedger} kept for it. Both maxima are magnitudes, 0 when no sample fell on that side.
|
|
6
|
+
*
|
|
7
|
+
* A gap does not say which clock is wrong: a node whose own HLC jumped forward after it observed a
|
|
8
|
+
* far-ahead peer shows as ahead to everyone, and so does a node whose wall clock simply runs fast.
|
|
9
|
+
*/
|
|
10
|
+
export type NodeSkew = {
|
|
11
|
+
readonly nodeId: string;
|
|
12
|
+
readonly samples: number;
|
|
13
|
+
/** The largest amount one of the node's HLCs sat ahead of local time, in milliseconds. */
|
|
14
|
+
readonly maxAheadMs: number;
|
|
15
|
+
/** The largest amount one of the node's HLCs sat behind local time, in milliseconds. */
|
|
16
|
+
readonly maxBehindMs: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The measurement docs/crdt-sync.md §Open Questions asks for before deciding whether members should
|
|
20
|
+
* refuse an HLC far from their own clock: per node id, how far the HLCs this node received from it
|
|
21
|
+
* sat from local time. Pure and in memory; it refuses nothing and nothing acts on it. A db-p2p
|
|
22
|
+
* storage repo records one sample per pend that carries an HLC (`StorageRepo.hlcSkew`).
|
|
23
|
+
*/
|
|
24
|
+
export declare class SkewLedger {
|
|
25
|
+
private readonly nodes;
|
|
26
|
+
constructor(maxNodes?: number);
|
|
27
|
+
/**
|
|
28
|
+
* Add one sample: `gapMs` is the HLC's `wallMs` less local time, positive when the node's HLC was
|
|
29
|
+
* ahead. Returns the node's summary with the sample included.
|
|
30
|
+
*/
|
|
31
|
+
record(nodeId: string, gapMs: number): NodeSkew;
|
|
32
|
+
/** Every node remembered, least recently heard from first. */
|
|
33
|
+
snapshot(): NodeSkew[];
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=skew.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skew.d.ts","sourceRoot":"","sources":["../../../src/hlc/skew.ts"],"names":[],"mappings":"AAEA,0GAA0G;AAC1G,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0FAA0F;IAC1F,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,wFAAwF;IACxF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;gBAErC,QAAQ,SAAgC;IAIpD;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ;IAY/C,8DAA8D;IAC9D,QAAQ,IAAI,QAAQ,EAAE;CAGtB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LruMap } from '../utility/lru-map.js';
|
|
2
|
+
/** How many node ids a {@link SkewLedger} remembers; the least recently heard from is forgotten first. */
|
|
3
|
+
export const DEFAULT_SKEW_LEDGER_MAX_NODES = 256;
|
|
4
|
+
/**
|
|
5
|
+
* The measurement docs/crdt-sync.md §Open Questions asks for before deciding whether members should
|
|
6
|
+
* refuse an HLC far from their own clock: per node id, how far the HLCs this node received from it
|
|
7
|
+
* sat from local time. Pure and in memory; it refuses nothing and nothing acts on it. A db-p2p
|
|
8
|
+
* storage repo records one sample per pend that carries an HLC (`StorageRepo.hlcSkew`).
|
|
9
|
+
*/
|
|
10
|
+
export class SkewLedger {
|
|
11
|
+
nodes;
|
|
12
|
+
constructor(maxNodes = DEFAULT_SKEW_LEDGER_MAX_NODES) {
|
|
13
|
+
this.nodes = new LruMap(maxNodes);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Add one sample: `gapMs` is the HLC's `wallMs` less local time, positive when the node's HLC was
|
|
17
|
+
* ahead. Returns the node's summary with the sample included.
|
|
18
|
+
*/
|
|
19
|
+
record(nodeId, gapMs) {
|
|
20
|
+
const prior = this.nodes.get(nodeId);
|
|
21
|
+
const next = {
|
|
22
|
+
nodeId,
|
|
23
|
+
samples: (prior?.samples ?? 0) + 1,
|
|
24
|
+
maxAheadMs: Math.max(prior?.maxAheadMs ?? 0, gapMs),
|
|
25
|
+
maxBehindMs: Math.max(prior?.maxBehindMs ?? 0, -gapMs),
|
|
26
|
+
};
|
|
27
|
+
this.nodes.set(nodeId, next);
|
|
28
|
+
return next;
|
|
29
|
+
}
|
|
30
|
+
/** Every node remembered, least recently heard from first. */
|
|
31
|
+
snapshot() {
|
|
32
|
+
return [...this.nodes].map(([, skew]) => skew);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=skew.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skew.js","sourceRoot":"","sources":["../../../src/hlc/skew.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,0GAA0G;AAC1G,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAkBjD;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACL,KAAK,CAA2B;IAEjD,YAAY,QAAQ,GAAG,6BAA6B;QACnD,IAAI,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,MAAc,EAAE,KAAa;QACnC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,IAAI,GAAa;YACtB,MAAM;YACN,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC;YAClC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,IAAI,CAAC,EAAE,KAAK,CAAC;YACnD,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC;SACtD,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,8DAA8D;IAC9D,QAAQ;QACP,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;CACD"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export * from "./cluster/index.js";
|
|
|
5
5
|
export * from "./cohort-topic/index.js";
|
|
6
6
|
export * from "./collection/index.js";
|
|
7
7
|
export * from "./collections/index.js";
|
|
8
|
+
export * from "./hlc/index.js";
|
|
9
|
+
export * from "./lane/index.js";
|
|
8
10
|
export * from "./log/index.js";
|
|
9
11
|
export * from "./logger-registry.js";
|
|
10
12
|
export * from "./matchmaking/index.js";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -5,6 +5,8 @@ export * from "./cluster/index.js";
|
|
|
5
5
|
export * from "./cohort-topic/index.js";
|
|
6
6
|
export * from "./collection/index.js";
|
|
7
7
|
export * from "./collections/index.js";
|
|
8
|
+
export * from "./hlc/index.js";
|
|
9
|
+
export * from "./lane/index.js";
|
|
8
10
|
export * from "./log/index.js";
|
|
9
11
|
export * from "./logger-registry.js";
|
|
10
12
|
export * from "./matchmaking/index.js";
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lane/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lane/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lane of a write: how its conflicts with other machines' CONCURRENT writes are decided
|
|
3
|
+
* (docs/crdt-sync.md §Stage 5 — Tunable per-collection; docs/partition-healing.md §I-Confluence
|
|
4
|
+
* Classification).
|
|
5
|
+
*
|
|
6
|
+
* - `serializable` — the quorum lane. The write needs the collection's cohort to agree before it
|
|
7
|
+
* is committed, and the revision order decides every conflict: today's behaviour for every write.
|
|
8
|
+
* The tree entry guards (`TreeEntryGuard` in `packages/db-core/src/collections/tree/struct.ts`)
|
|
9
|
+
* are this lane's conflict rule, re-making every uniqueness and lost-update decision
|
|
10
|
+
* deterministically on replay.
|
|
11
|
+
* - `convergent` — the merge lane. The write may be committed by one machine without first agreeing
|
|
12
|
+
* with the others and merged into their concurrent writes later, because the invariants it is
|
|
13
|
+
* responsible for survive a merge: an append to an append-only set, an increment of an unbounded
|
|
14
|
+
* counter, a last-writer-wins field. The collection's merge declaration (`ConvergentMerge` in
|
|
15
|
+
* `packages/db-core/src/collection/collection.ts`) is this lane's conflict rule.
|
|
16
|
+
*
|
|
17
|
+
* Convergence is a property of an OPERATION, never of a system (the invariant-confluence result of
|
|
18
|
+
* Bailis et al., and Li et al.'s RedBlue consistency). **Idempotence is not the criterion**, and is
|
|
19
|
+
* the mistake a reader makes first: setting a column to a value is idempotent and still needs a
|
|
20
|
+
* tie-break under concurrency, while an increment is not idempotent and merges fine. The question is
|
|
21
|
+
* whether two machines applying the operation concurrently, each over its own view, leave the
|
|
22
|
+
* invariants the operation is responsible for true once the two views are merged.
|
|
23
|
+
*
|
|
24
|
+
* Nothing admits a write by its lane yet: the solo path, the offline queue and the conflict replay
|
|
25
|
+
* behave as they did before the field. The replay stage (backlog
|
|
26
|
+
* `feat-replay-mode-collections-merge-divergent-histories`) is what consumes it.
|
|
27
|
+
*/
|
|
28
|
+
export type Lane = 'serializable' | 'convergent';
|
|
29
|
+
/**
|
|
30
|
+
* The lane of a write made of several parts: `serializable` if any part is. Convergence is a claim
|
|
31
|
+
* each part makes about itself, so a write is convergent only when every part claims it — and a
|
|
32
|
+
* write of NO parts claims nothing, so an empty set answers `serializable`, the lane every write
|
|
33
|
+
* takes without a declaration.
|
|
34
|
+
*/
|
|
35
|
+
export declare function stricterLane(lanes: Iterable<Lane>): Lane;
|
|
36
|
+
/**
|
|
37
|
+
* Wraps a request's optional `lane` (`PendRequest.lane`, `CommitRequest.lane`) so the field spreads
|
|
38
|
+
* onto the request only when the sender has one: omitted rather than sent as `undefined`, because the
|
|
39
|
+
* request is hashed verbatim into every cohort signature preimage, so a request that states no lane
|
|
40
|
+
* must serialize exactly as it did before the field existed. Every producer of the field goes
|
|
41
|
+
* through here, as `refuseSoloField` does for its field.
|
|
42
|
+
*/
|
|
43
|
+
export declare function laneField(lane: Lane | undefined): {
|
|
44
|
+
lane?: Lane;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=lane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lane.d.ts","sourceRoot":"","sources":["../../../src/lane/lane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,IAAI,GAAG,cAAc,GAAG,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAOxD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,CAAA;CAAE,CAEjE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lane of a write made of several parts: `serializable` if any part is. Convergence is a claim
|
|
3
|
+
* each part makes about itself, so a write is convergent only when every part claims it — and a
|
|
4
|
+
* write of NO parts claims nothing, so an empty set answers `serializable`, the lane every write
|
|
5
|
+
* takes without a declaration.
|
|
6
|
+
*/
|
|
7
|
+
export function stricterLane(lanes) {
|
|
8
|
+
let seen = false;
|
|
9
|
+
for (const lane of lanes) {
|
|
10
|
+
if (lane === 'serializable')
|
|
11
|
+
return 'serializable';
|
|
12
|
+
seen = true;
|
|
13
|
+
}
|
|
14
|
+
return seen ? 'convergent' : 'serializable';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Wraps a request's optional `lane` (`PendRequest.lane`, `CommitRequest.lane`) so the field spreads
|
|
18
|
+
* onto the request only when the sender has one: omitted rather than sent as `undefined`, because the
|
|
19
|
+
* request is hashed verbatim into every cohort signature preimage, so a request that states no lane
|
|
20
|
+
* must serialize exactly as it did before the field existed. Every producer of the field goes
|
|
21
|
+
* through here, as `refuseSoloField` does for its field.
|
|
22
|
+
*/
|
|
23
|
+
export function laneField(lane) {
|
|
24
|
+
return lane === undefined ? {} : { lane };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=lane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lane.js","sourceRoot":"","sources":["../../../src/lane/lane.ts"],"names":[],"mappings":"AA6BA;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAqB;IACjD,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,IAAI,KAAK,cAAc;YAAE,OAAO,cAAc,CAAC;QACnD,IAAI,GAAG,IAAI,CAAC;IACb,CAAC;IACD,OAAO,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,IAAsB;IAC/C,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;AAC3C,CAAC"}
|
package/dist/src/log/log.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { IBlock, BlockId, ActionId, CollectionId, ChainPath, ActionRev, Act
|
|
|
3
3
|
import type { ChainDataNode } from '../chain/chain-nodes.js';
|
|
4
4
|
import type { LogEntry, DisputeResolutionProof, InvalidationEntry, RevertedBlock } from "./index.js";
|
|
5
5
|
import type { GetFromResult } from './struct.js';
|
|
6
|
+
import { type Hlc } from '../hlc/hlc.js';
|
|
7
|
+
import type { Lane } from '../lane/lane.js';
|
|
6
8
|
export type LogBlock<TAction> = ChainDataNode<LogEntry<TAction>> & {
|
|
7
9
|
/** Base64url encoded Sha256 hash of the prior (predecessor) block - present on every block except the head */
|
|
8
10
|
priorHash?: string;
|
|
@@ -34,10 +36,36 @@ export type LogOpenOptions = {
|
|
|
34
36
|
/** Supplies the id for each data block an append mints, in place of a fresh random one. */
|
|
35
37
|
newDataBlockId?: () => BlockId;
|
|
36
38
|
};
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The two per-write time values every entry kind carries (`LogEntry.hlc` and `LogEntry.timestamp`),
|
|
41
|
+
* taken by {@link Log.addActions}, {@link Log.addCheckpoint} and {@link Log.addInvalidation} alike.
|
|
42
|
+
*
|
|
43
|
+
* Both belong to the WRITE, not to the attempt. Storage identifies a saved block revision by
|
|
44
|
+
* `(action id, revision)` and accepts a retry of the same action at the same revision, so a value a
|
|
45
|
+
* retry minted afresh would store a second, different log block under one `(action, revision)` on
|
|
46
|
+
* every machine that missed the first attempt (docs/internals.md, "A write's log append is a fixed
|
|
47
|
+
* function of the write and the revision it is requesting").
|
|
48
|
+
*/
|
|
49
|
+
export type EntryTimes = {
|
|
50
|
+
/** The HLC the writer minted for the write (`clockOf(transactor).now()`), re-sent verbatim by every
|
|
51
|
+
* retry. No default: the clock is the writer's, and an append has none of its own. */
|
|
52
|
+
hlc: Hlc;
|
|
53
|
+
/**
|
|
54
|
+
* When the entry was written. Nothing in the tree reads it for logic — it is informational —
|
|
55
|
+
* which is what makes it safe for a writer to supply the time of the WRITE rather than of the
|
|
56
|
+
* attempt, and arguably the more honest value. A writer whose attempt may be retried MUST supply
|
|
57
|
+
* it, for the reason above. Defaults to `Date.now()` for a caller that appends once.
|
|
58
|
+
*/
|
|
59
|
+
timestamp?: number;
|
|
60
|
+
};
|
|
61
|
+
/** The trailing inputs to {@link Log.addActions}: the write's {@link EntryTimes} plus the two
|
|
62
|
+
* optional fields an action entry alone carries. An options object rather than positional
|
|
63
|
+
* parameters because a caller that needs only the times should not have to spell out the rest. */
|
|
64
|
+
export type AddActionsOptions = EntryTimes & {
|
|
65
|
+
/** The write's lane (`ActionEntry.lane`), minted once per write by the same rule as the times
|
|
66
|
+
* above and re-sent verbatim by every retry. No default: the lane is the write's, decided by the
|
|
67
|
+
* caller's classification or the collection's declaration, and an append has none of its own. */
|
|
68
|
+
lane: Lane;
|
|
41
69
|
/** Every collection participating in the action this entry records. */
|
|
42
70
|
collectionIds?: CollectionId[];
|
|
43
71
|
/** The transaction's `(blockId, revision)` read set, persisted on the entry so the invalidation
|
|
@@ -45,18 +73,13 @@ export type AddActionsOptions = {
|
|
|
45
73
|
* Omit it on the low-level direct-commit path that carries no `Transaction`; the cascade then
|
|
46
74
|
* treats the entry as an unknown dependency. */
|
|
47
75
|
reads?: ReadDependency[];
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
* revision, so a retry that took a fresh timestamp here would store a second, different log
|
|
56
|
-
* block under one `(action, revision)` on every machine that missed the first attempt.
|
|
57
|
-
* Defaults to `Date.now()` for a caller that appends once.
|
|
58
|
-
*/
|
|
59
|
-
timestamp?: number;
|
|
76
|
+
};
|
|
77
|
+
/** The trailing inputs to {@link Log.addInvalidation}: the write's {@link EntryTimes}, and the root
|
|
78
|
+
* invalidation when this entry is a cascade step. */
|
|
79
|
+
export type AddInvalidationOptions = EntryTimes & {
|
|
80
|
+
/** The root invalidation that triggered this cascade step; absent for a root invalidation
|
|
81
|
+
* (see {@link InvalidationEntry.cascadeRoot}). */
|
|
82
|
+
cascadeRoot?: ActionId;
|
|
60
83
|
};
|
|
61
84
|
export declare class Log<TAction> {
|
|
62
85
|
private readonly chain;
|
|
@@ -79,28 +102,32 @@ export declare class Log<TAction> {
|
|
|
79
102
|
* Adds a new action entry to the log.
|
|
80
103
|
*
|
|
81
104
|
* See {@link AddActionsOptions} for what the trailing options carry, and in particular why a
|
|
82
|
-
* writer that may retry passes its own `timestamp` rather than letting each attempt
|
|
105
|
+
* writer that may retry passes its own `hlc` and `timestamp` rather than letting each attempt
|
|
106
|
+
* take its own.
|
|
83
107
|
*/
|
|
84
|
-
addActions(actions: TAction[], actionId: ActionId, rev: number, getBlockIds: () => BlockId[], options
|
|
108
|
+
addActions(actions: TAction[], actionId: ActionId, rev: number, getBlockIds: () => BlockId[], options: AddActionsOptions): Promise<{
|
|
85
109
|
entry: {
|
|
86
110
|
action: {
|
|
87
111
|
blockIds: string[];
|
|
88
112
|
actionId: ActionId;
|
|
89
113
|
actions: TAction[];
|
|
90
114
|
collectionIds?: CollectionId[];
|
|
115
|
+
lane: Lane;
|
|
91
116
|
reads?: ReadDependency[];
|
|
92
117
|
};
|
|
93
118
|
timestamp: number;
|
|
119
|
+
hlc: Hlc;
|
|
94
120
|
rev: number;
|
|
95
121
|
checkpoint?: import("./struct.js").CheckpointEntry;
|
|
96
122
|
invalidation?: InvalidationEntry;
|
|
97
123
|
};
|
|
98
124
|
tailPath: ChainPath<LogEntry<TAction>>;
|
|
99
125
|
}>;
|
|
100
|
-
/** Adds a checkpoint to the log. */
|
|
101
|
-
addCheckpoint(pendings: ActionRev[], rev: number,
|
|
126
|
+
/** Adds a checkpoint to the log, under the write's {@link EntryTimes}. */
|
|
127
|
+
addCheckpoint(pendings: ActionRev[], rev: number, times: EntryTimes): Promise<{
|
|
102
128
|
entry: {
|
|
103
129
|
timestamp: number;
|
|
130
|
+
hlc: Hlc;
|
|
104
131
|
rev: number;
|
|
105
132
|
checkpoint: {
|
|
106
133
|
pendings: ActionRev[];
|
|
@@ -113,9 +140,10 @@ export declare class Log<TAction> {
|
|
|
113
140
|
* invalid by dispute. The committed history is never rewritten — this is a new, append-only,
|
|
114
141
|
* prior-hash-linked entry, recoverable on sync exactly like a commit. The caller has already
|
|
115
142
|
* verified `resolution` is a challenger-wins certificate and computed the per-block `reverted`
|
|
116
|
-
* targets (the new revisions restoring the as-if-`T_inv`-absent content).
|
|
143
|
+
* targets (the new revisions restoring the as-if-`T_inv`-absent content). The entry carries the
|
|
144
|
+
* applying node's {@link EntryTimes} like every other entry kind.
|
|
117
145
|
*/
|
|
118
|
-
addInvalidation(invalidatedActionId: ActionId, invalidatedRev: number, resolution: DisputeResolutionProof, reverted: ReadonlyArray<RevertedBlock>, rev: number,
|
|
146
|
+
addInvalidation(invalidatedActionId: ActionId, invalidatedRev: number, resolution: DisputeResolutionProof, reverted: ReadonlyArray<RevertedBlock>, rev: number, options: AddInvalidationOptions): Promise<{
|
|
119
147
|
entry: LogEntry<TAction>;
|
|
120
148
|
tailPath: ChainPath<LogEntry<TAction>>;
|
|
121
149
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/log/log.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAW,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9J,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAe,sBAAsB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGlH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/log/log.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAW,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9J,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAe,sBAAsB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGlH,O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GAAG,SAAS,CAAC;IAiB5D,wEAAwE;IAClE,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IA+C5E,oJAAoJ;IAC7I,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,UAAO;IAMrE,6GAA6G;YAC/F,cAAc;IAc5B,+EAA+E;YACjE,WAAW;IAWzB;;;;;oGAKgG;IAChG,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,OAAO,GAanF,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;CAGzC"}
|
package/dist/src/log/log.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { sha256 } from 'multiformats/hashes/sha2';
|
|
2
2
|
import { Chain, entryAt } from "../chain/chain.js";
|
|
3
3
|
import { nameof } from "../utility/nameof.js";
|
|
4
|
-
import { LogDataBlockType, LogHeaderBlockType } from "./struct.js";
|
|
4
|
+
import { LogDataBlockType, LogHeaderBlockType, hlcOf } from "./struct.js";
|
|
5
5
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
6
|
+
import { maxHlc } from '../hlc/hlc.js';
|
|
6
7
|
import { BLOCK_TARGET_BYTES } from '../network/block-size.js';
|
|
7
8
|
export const priorHash$ = nameof("priorHash");
|
|
8
9
|
/**
|
|
@@ -55,22 +56,24 @@ export class Log {
|
|
|
55
56
|
* Adds a new action entry to the log.
|
|
56
57
|
*
|
|
57
58
|
* See {@link AddActionsOptions} for what the trailing options carry, and in particular why a
|
|
58
|
-
* writer that may retry passes its own `timestamp` rather than letting each attempt
|
|
59
|
+
* writer that may retry passes its own `hlc` and `timestamp` rather than letting each attempt
|
|
60
|
+
* take its own.
|
|
59
61
|
*/
|
|
60
62
|
async addActions(actions, actionId, rev, getBlockIds, options) {
|
|
61
|
-
const { collectionIds = [], reads, timestamp = Date.now() } = options
|
|
63
|
+
const { collectionIds = [], reads, hlc, lane, timestamp = Date.now() } = options;
|
|
62
64
|
const action = reads !== undefined
|
|
63
|
-
? { actionId, actions, blockIds: [], collectionIds, reads }
|
|
64
|
-
: { actionId, actions, blockIds: [], collectionIds };
|
|
65
|
-
const entry = { timestamp, rev, action };
|
|
65
|
+
? { actionId, actions, blockIds: [], collectionIds, lane, reads }
|
|
66
|
+
: { actionId, actions, blockIds: [], collectionIds, lane };
|
|
67
|
+
const entry = { timestamp, hlc, rev, action };
|
|
66
68
|
const tailPath = await this.chain.add(entry);
|
|
67
69
|
const entryWithBlockIds = { ...entry, action: { ...entry.action, blockIds: getBlockIds() } };
|
|
68
70
|
this.chain.updateAt(tailPath, entryWithBlockIds);
|
|
69
71
|
return { entry: entryWithBlockIds, tailPath };
|
|
70
72
|
}
|
|
71
|
-
/** Adds a checkpoint to the log. */
|
|
72
|
-
async addCheckpoint(pendings, rev,
|
|
73
|
-
const
|
|
73
|
+
/** Adds a checkpoint to the log, under the write's {@link EntryTimes}. */
|
|
74
|
+
async addCheckpoint(pendings, rev, times) {
|
|
75
|
+
const { hlc, timestamp = Date.now() } = times;
|
|
76
|
+
const entry = { timestamp, hlc, rev, checkpoint: { pendings } };
|
|
74
77
|
const tailPath = await this.chain.add(entry);
|
|
75
78
|
return { entry, tailPath };
|
|
76
79
|
}
|
|
@@ -79,13 +82,15 @@ export class Log {
|
|
|
79
82
|
* invalid by dispute. The committed history is never rewritten — this is a new, append-only,
|
|
80
83
|
* prior-hash-linked entry, recoverable on sync exactly like a commit. The caller has already
|
|
81
84
|
* verified `resolution` is a challenger-wins certificate and computed the per-block `reverted`
|
|
82
|
-
* targets (the new revisions restoring the as-if-`T_inv`-absent content).
|
|
85
|
+
* targets (the new revisions restoring the as-if-`T_inv`-absent content). The entry carries the
|
|
86
|
+
* applying node's {@link EntryTimes} like every other entry kind.
|
|
83
87
|
*/
|
|
84
|
-
async addInvalidation(invalidatedActionId, invalidatedRev, resolution, reverted, rev,
|
|
88
|
+
async addInvalidation(invalidatedActionId, invalidatedRev, resolution, reverted, rev, options) {
|
|
89
|
+
const { hlc, timestamp = Date.now(), cascadeRoot } = options;
|
|
85
90
|
const invalidation = cascadeRoot !== undefined
|
|
86
91
|
? { invalidatedActionId, invalidatedRev, resolution, reverted, cascadeRoot }
|
|
87
92
|
: { invalidatedActionId, invalidatedRev, resolution, reverted };
|
|
88
|
-
const entry = { timestamp, rev, invalidation };
|
|
93
|
+
const entry = { timestamp, hlc, rev, invalidation };
|
|
89
94
|
const tailPath = await this.chain.add(entry);
|
|
90
95
|
return { entry, tailPath };
|
|
91
96
|
}
|
|
@@ -151,9 +156,11 @@ export class Log {
|
|
|
151
156
|
let checkpointPendings = [];
|
|
152
157
|
let rev;
|
|
153
158
|
let checkpointPath;
|
|
159
|
+
let hlcHighWater;
|
|
154
160
|
// Step through collecting both pending and entries until a checkpoint is found
|
|
155
161
|
for await (const path of this.chain.select(undefined, false)) {
|
|
156
162
|
const entry = entryAt(path);
|
|
163
|
+
hlcHighWater = maxHlc(hlcHighWater, hlcOf(entry));
|
|
157
164
|
rev = rev ?? entry.rev;
|
|
158
165
|
if (entry.checkpoint) {
|
|
159
166
|
checkpointPath = path;
|
|
@@ -175,6 +182,7 @@ export class Log {
|
|
|
175
182
|
if (checkpointPath) {
|
|
176
183
|
for await (const path of this.chain.select(checkpointPath, false)) {
|
|
177
184
|
const entry = entryAt(path);
|
|
185
|
+
hlcHighWater = maxHlc(hlcHighWater, hlcOf(entry));
|
|
178
186
|
if (startRev !== undefined && entry.rev > startRev) {
|
|
179
187
|
if (entry.action) {
|
|
180
188
|
entriesFromCheckpoint.push(entry.action);
|
|
@@ -187,7 +195,7 @@ export class Log {
|
|
|
187
195
|
}
|
|
188
196
|
const pendings = [...checkpointPendings, ...pendingActions.reverse()];
|
|
189
197
|
const entries = [...entriesFromCheckpoint.reverse(), ...entriesFromTail.reverse()];
|
|
190
|
-
return { context: rev ? { committed: pendings, rev } : undefined, entries };
|
|
198
|
+
return { context: rev ? { committed: pendings, rev } : undefined, entries, hlcHighWater };
|
|
191
199
|
}
|
|
192
200
|
/** Enumerates log entries from the given starting path or end if undefined, in forward (from tail to head) or reverse (from head to tail) order. */
|
|
193
201
|
async *select(starting, forward = true) {
|
package/dist/src/log/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/log/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/log/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAEtE,OAAO,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAQ9D,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAgB,WAAW,CAAC,CAAC;AAE7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CAAU,KAAwB;IACpE,MAAM,EAAE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