@optimystic/db-core 0.14.0 → 0.16.2
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/blocks/block-store.d.ts +18 -1
- package/dist/src/blocks/block-store.d.ts.map +1 -1
- package/dist/src/blocks/helpers.d.ts +2 -2
- package/dist/src/blocks/helpers.d.ts.map +1 -1
- package/dist/src/blocks/helpers.js +2 -2
- package/dist/src/blocks/helpers.js.map +1 -1
- package/dist/src/btree/btree.d.ts +27 -6
- package/dist/src/btree/btree.d.ts.map +1 -1
- package/dist/src/btree/btree.js +104 -61
- package/dist/src/btree/btree.js.map +1 -1
- package/dist/src/chain/chain.d.ts.map +1 -1
- package/dist/src/chain/chain.js +11 -1
- package/dist/src/chain/chain.js.map +1 -1
- package/dist/src/cluster/index.d.ts +1 -0
- package/dist/src/cluster/index.d.ts.map +1 -1
- package/dist/src/cluster/index.js +1 -0
- package/dist/src/cluster/index.js.map +1 -1
- package/dist/src/cluster/membership.d.ts +49 -0
- package/dist/src/cluster/membership.d.ts.map +1 -0
- package/dist/src/cluster/membership.js +75 -0
- package/dist/src/cluster/membership.js.map +1 -0
- package/dist/src/cluster/structs.d.ts +50 -1
- package/dist/src/cluster/structs.d.ts.map +1 -1
- package/dist/src/cluster/structs.js +9 -1
- package/dist/src/cluster/structs.js.map +1 -1
- package/dist/src/cohort-topic/addressing.d.ts +8 -2
- package/dist/src/cohort-topic/addressing.d.ts.map +1 -1
- package/dist/src/cohort-topic/addressing.js +11 -3
- package/dist/src/cohort-topic/addressing.js.map +1 -1
- package/dist/src/cohort-topic/antidos/bootstrap-evidence.d.ts +13 -7
- package/dist/src/cohort-topic/antidos/bootstrap-evidence.d.ts.map +1 -1
- package/dist/src/cohort-topic/antidos/bootstrap-evidence.js +17 -6
- package/dist/src/cohort-topic/antidos/bootstrap-evidence.js.map +1 -1
- package/dist/src/cohort-topic/antidos/replay-guard.d.ts +17 -0
- package/dist/src/cohort-topic/antidos/replay-guard.d.ts.map +1 -1
- package/dist/src/cohort-topic/antidos/replay-guard.js +33 -0
- package/dist/src/cohort-topic/antidos/replay-guard.js.map +1 -1
- package/dist/src/cohort-topic/antidos/topic-budget.d.ts +7 -0
- package/dist/src/cohort-topic/antidos/topic-budget.d.ts.map +1 -1
- package/dist/src/cohort-topic/antidos/topic-budget.js +8 -2
- package/dist/src/cohort-topic/antidos/topic-budget.js.map +1 -1
- package/dist/src/cohort-topic/coldstart.d.ts +34 -14
- package/dist/src/cohort-topic/coldstart.d.ts.map +1 -1
- package/dist/src/cohort-topic/coldstart.js +25 -11
- package/dist/src/cohort-topic/coldstart.js.map +1 -1
- package/dist/src/cohort-topic/gossip/bus.d.ts +12 -1
- package/dist/src/cohort-topic/gossip/bus.d.ts.map +1 -1
- package/dist/src/cohort-topic/gossip/bus.js +27 -1
- package/dist/src/cohort-topic/gossip/bus.js.map +1 -1
- package/dist/src/cohort-topic/gossip/view.d.ts +8 -0
- package/dist/src/cohort-topic/gossip/view.d.ts.map +1 -1
- package/dist/src/cohort-topic/gossip/view.js +17 -1
- package/dist/src/cohort-topic/gossip/view.js.map +1 -1
- package/dist/src/cohort-topic/member-engine.d.ts +10 -3
- package/dist/src/cohort-topic/member-engine.d.ts.map +1 -1
- package/dist/src/cohort-topic/member-engine.js +29 -14
- package/dist/src/cohort-topic/member-engine.js.map +1 -1
- package/dist/src/cohort-topic/membership/publisher.d.ts +14 -7
- package/dist/src/cohort-topic/membership/publisher.d.ts.map +1 -1
- package/dist/src/cohort-topic/membership/publisher.js +15 -27
- package/dist/src/cohort-topic/membership/publisher.js.map +1 -1
- package/dist/src/cohort-topic/membership/verifier.d.ts +35 -0
- package/dist/src/cohort-topic/membership/verifier.d.ts.map +1 -1
- package/dist/src/cohort-topic/membership/verifier.js +88 -3
- package/dist/src/cohort-topic/membership/verifier.js.map +1 -1
- package/dist/src/cohort-topic/promotion.d.ts +7 -0
- package/dist/src/cohort-topic/promotion.d.ts.map +1 -1
- package/dist/src/cohort-topic/promotion.js +16 -2
- package/dist/src/cohort-topic/promotion.js.map +1 -1
- package/dist/src/cohort-topic/registration/renewal.d.ts +18 -0
- package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -1
- package/dist/src/cohort-topic/registration/renewal.js +54 -0
- package/dist/src/cohort-topic/registration/renewal.js.map +1 -1
- package/dist/src/cohort-topic/registration/types.d.ts +12 -0
- package/dist/src/cohort-topic/registration/types.d.ts.map +1 -1
- package/dist/src/cohort-topic/registration/types.js +14 -0
- package/dist/src/cohort-topic/registration/types.js.map +1 -1
- package/dist/src/cohort-topic/service.d.ts +4 -3
- package/dist/src/cohort-topic/service.d.ts.map +1 -1
- package/dist/src/cohort-topic/service.js +38 -12
- package/dist/src/cohort-topic/service.js.map +1 -1
- package/dist/src/cohort-topic/sig/payloads.d.ts +23 -7
- package/dist/src/cohort-topic/sig/payloads.d.ts.map +1 -1
- package/dist/src/cohort-topic/sig/payloads.js +22 -6
- package/dist/src/cohort-topic/sig/payloads.js.map +1 -1
- package/dist/src/cohort-topic/traffic.d.ts +6 -0
- package/dist/src/cohort-topic/traffic.d.ts.map +1 -1
- package/dist/src/cohort-topic/traffic.js +16 -1
- package/dist/src/cohort-topic/traffic.js.map +1 -1
- package/dist/src/cohort-topic/walk.d.ts +22 -7
- package/dist/src/cohort-topic/walk.d.ts.map +1 -1
- package/dist/src/cohort-topic/walk.js +78 -18
- package/dist/src/cohort-topic/walk.js.map +1 -1
- package/dist/src/cohort-topic/wire/codec.d.ts +3 -1
- package/dist/src/cohort-topic/wire/codec.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/codec.js +7 -1
- package/dist/src/cohort-topic/wire/codec.js.map +1 -1
- package/dist/src/cohort-topic/wire/index.d.ts +1 -1
- package/dist/src/cohort-topic/wire/index.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/index.js +1 -1
- package/dist/src/cohort-topic/wire/index.js.map +1 -1
- package/dist/src/cohort-topic/wire/payloads.d.ts +5 -4
- package/dist/src/cohort-topic/wire/payloads.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/payloads.js +14 -5
- package/dist/src/cohort-topic/wire/payloads.js.map +1 -1
- package/dist/src/cohort-topic/wire/primitives.d.ts +65 -0
- package/dist/src/cohort-topic/wire/primitives.d.ts.map +1 -0
- package/dist/src/cohort-topic/wire/primitives.js +173 -0
- package/dist/src/cohort-topic/wire/primitives.js.map +1 -0
- package/dist/src/cohort-topic/wire/types.d.ts +132 -5
- package/dist/src/cohort-topic/wire/types.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.d.ts +15 -5
- package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.js +146 -123
- package/dist/src/cohort-topic/wire/validate.js.map +1 -1
- package/dist/src/collection/collection.d.ts +23 -12
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +111 -35
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collection/struct.d.ts +37 -2
- package/dist/src/collection/struct.d.ts.map +1 -1
- package/dist/src/collection/struct.js +16 -1
- package/dist/src/collection/struct.js.map +1 -1
- package/dist/src/collections/tree/tree.d.ts +18 -1
- package/dist/src/collections/tree/tree.d.ts.map +1 -1
- package/dist/src/collections/tree/tree.js +36 -6
- package/dist/src/collections/tree/tree.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/log/log.d.ts +26 -3
- package/dist/src/log/log.d.ts.map +1 -1
- package/dist/src/log/log.js +34 -7
- package/dist/src/log/log.js.map +1 -1
- package/dist/src/log/struct.d.ts +5 -4
- package/dist/src/log/struct.d.ts.map +1 -1
- package/dist/src/log/struct.js.map +1 -1
- package/dist/src/matchmaking/wire.d.ts +2 -1
- package/dist/src/matchmaking/wire.d.ts.map +1 -1
- package/dist/src/matchmaking/wire.js +13 -92
- package/dist/src/matchmaking/wire.js.map +1 -1
- package/dist/src/network/i-key-network.d.ts +9 -0
- package/dist/src/network/i-key-network.d.ts.map +1 -1
- package/dist/src/network/i-repo.d.ts +8 -0
- package/dist/src/network/i-repo.d.ts.map +1 -1
- package/dist/src/network/struct.d.ts +10 -0
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/reactivity/push-state.d.ts.map +1 -1
- package/dist/src/reactivity/push-state.js +4 -33
- package/dist/src/reactivity/push-state.js.map +1 -1
- package/dist/src/reactivity/wire-validate.d.ts +7 -22
- package/dist/src/reactivity/wire-validate.d.ts.map +1 -1
- package/dist/src/reactivity/wire-validate.js +7 -73
- package/dist/src/reactivity/wire-validate.js.map +1 -1
- package/dist/src/reactivity/wire.js +3 -3
- package/dist/src/reactivity/wire.js.map +1 -1
- package/dist/src/testing/async-wait.d.ts +23 -0
- package/dist/src/testing/async-wait.d.ts.map +1 -0
- package/dist/src/testing/async-wait.js +42 -0
- package/dist/src/testing/async-wait.js.map +1 -0
- package/dist/src/testing/index.d.ts +3 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +3 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/test-transactor.d.ts +44 -0
- package/dist/src/testing/test-transactor.d.ts.map +1 -0
- package/dist/src/testing/test-transactor.js +423 -0
- package/dist/src/testing/test-transactor.js.map +1 -0
- package/dist/src/transaction/actions-engine.d.ts +6 -3
- package/dist/src/transaction/actions-engine.d.ts.map +1 -1
- package/dist/src/transaction/actions-engine.js +8 -7
- package/dist/src/transaction/actions-engine.js.map +1 -1
- package/dist/src/transaction/coordinator.d.ts +43 -22
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +443 -178
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transaction/errors.d.ts +82 -0
- package/dist/src/transaction/errors.d.ts.map +1 -0
- package/dist/src/transaction/errors.js +93 -0
- package/dist/src/transaction/errors.js.map +1 -0
- package/dist/src/transaction/index.d.ts +6 -3
- package/dist/src/transaction/index.d.ts.map +1 -1
- package/dist/src/transaction/index.js +4 -2
- package/dist/src/transaction/index.js.map +1 -1
- package/dist/src/transaction/operations-hash.d.ts +119 -0
- package/dist/src/transaction/operations-hash.d.ts.map +1 -0
- package/dist/src/transaction/operations-hash.js +180 -0
- package/dist/src/transaction/operations-hash.js.map +1 -0
- package/dist/src/transaction/read-dependency-collector.d.ts +43 -0
- package/dist/src/transaction/read-dependency-collector.d.ts.map +1 -0
- package/dist/src/transaction/read-dependency-collector.js +69 -0
- package/dist/src/transaction/read-dependency-collector.js.map +1 -0
- package/dist/src/transaction/session.d.ts +12 -3
- package/dist/src/transaction/session.d.ts.map +1 -1
- package/dist/src/transaction/session.js +35 -9
- package/dist/src/transaction/session.js.map +1 -1
- package/dist/src/transaction/transaction.d.ts +162 -1
- package/dist/src/transaction/transaction.d.ts.map +1 -1
- package/dist/src/transaction/transaction.js +85 -3
- package/dist/src/transaction/transaction.js.map +1 -1
- package/dist/src/transaction/validator.d.ts +3 -11
- package/dist/src/transaction/validator.d.ts.map +1 -1
- package/dist/src/transaction/validator.js +69 -28
- package/dist/src/transaction/validator.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts +35 -0
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +146 -40
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/dist/src/transactor/transactor-source.d.ts +19 -5
- package/dist/src/transactor/transactor-source.d.ts.map +1 -1
- package/dist/src/transactor/transactor-source.js +43 -11
- package/dist/src/transactor/transactor-source.js.map +1 -1
- package/dist/src/transform/atomic-proxy.d.ts +35 -5
- package/dist/src/transform/atomic-proxy.d.ts.map +1 -1
- package/dist/src/transform/atomic-proxy.js +39 -7
- package/dist/src/transform/atomic-proxy.js.map +1 -1
- package/dist/src/transform/cache-source.d.ts +36 -5
- package/dist/src/transform/cache-source.d.ts.map +1 -1
- package/dist/src/transform/cache-source.js +84 -8
- package/dist/src/transform/cache-source.js.map +1 -1
- package/dist/src/transform/helpers.d.ts.map +1 -1
- package/dist/src/transform/helpers.js +8 -2
- package/dist/src/transform/helpers.js.map +1 -1
- package/dist/src/transform/tracker.d.ts +17 -2
- package/dist/src/transform/tracker.d.ts.map +1 -1
- package/dist/src/transform/tracker.js +66 -11
- package/dist/src/transform/tracker.js.map +1 -1
- package/dist/src/utility/backoff.d.ts +48 -0
- package/dist/src/utility/backoff.d.ts.map +1 -0
- package/dist/src/utility/backoff.js +60 -0
- package/dist/src/utility/backoff.js.map +1 -0
- package/dist/src/utility/pending.d.ts +1 -0
- package/dist/src/utility/pending.d.ts.map +1 -1
- package/dist/src/utility/pending.js +3 -1
- package/dist/src/utility/pending.js.map +1 -1
- package/package.json +4 -4
- package/src/blocks/block-store.ts +19 -1
- package/src/blocks/helpers.ts +3 -3
- package/src/btree/btree.ts +108 -63
- package/src/chain/chain.ts +11 -1
- package/src/cluster/index.ts +1 -0
- package/src/cluster/membership.ts +85 -0
- package/src/cluster/structs.ts +51 -1
- package/src/cohort-topic/addressing.ts +12 -4
- package/src/cohort-topic/antidos/bootstrap-evidence.ts +21 -9
- package/src/cohort-topic/antidos/replay-guard.ts +37 -0
- package/src/cohort-topic/antidos/topic-budget.ts +17 -2
- package/src/cohort-topic/coldstart.ts +48 -15
- package/src/cohort-topic/gossip/bus.ts +39 -2
- package/src/cohort-topic/gossip/view.ts +26 -1
- package/src/cohort-topic/member-engine.ts +36 -15
- package/src/cohort-topic/membership/publisher.ts +25 -33
- package/src/cohort-topic/membership/verifier.ts +119 -3
- package/src/cohort-topic/promotion.ts +23 -2
- package/src/cohort-topic/registration/renewal.ts +73 -1
- package/src/cohort-topic/registration/types.ts +15 -0
- package/src/cohort-topic/service.ts +41 -15
- package/src/cohort-topic/sig/payloads.ts +29 -9
- package/src/cohort-topic/traffic.ts +23 -1
- package/src/cohort-topic/walk.ts +95 -24
- package/src/cohort-topic/wire/codec.ts +12 -0
- package/src/cohort-topic/wire/index.ts +2 -0
- package/src/cohort-topic/wire/payloads.ts +14 -5
- package/src/cohort-topic/wire/primitives.ts +188 -0
- package/src/cohort-topic/wire/types.ts +136 -4
- package/src/cohort-topic/wire/validate.ts +168 -134
- package/src/collection/collection.ts +123 -40
- package/src/collection/struct.ts +44 -2
- package/src/collections/tree/tree.ts +42 -5
- package/src/index.ts +1 -0
- package/src/log/log.ts +37 -9
- package/src/log/struct.ts +5 -4
- package/src/matchmaking/wire.ts +25 -102
- package/src/network/i-key-network.ts +10 -0
- package/src/network/i-repo.ts +8 -0
- package/src/network/struct.ts +10 -0
- package/src/reactivity/push-state.ts +4 -37
- package/src/reactivity/wire-validate.ts +7 -81
- package/src/reactivity/wire.ts +3 -3
- package/src/testing/async-wait.ts +65 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/test-transactor.ts +468 -0
- package/src/transaction/actions-engine.ts +8 -6
- package/src/transaction/coordinator.ts +498 -229
- package/src/transaction/errors.ts +91 -0
- package/src/transaction/index.ts +23 -3
- package/src/transaction/operations-hash.ts +196 -0
- package/src/transaction/read-dependency-collector.ts +78 -0
- package/src/transaction/session.ts +37 -9
- package/src/transaction/transaction.ts +211 -4
- package/src/transaction/validator.ts +73 -48
- package/src/transactor/network-transactor.ts +164 -49
- package/src/transactor/transactor-source.ts +47 -12
- package/src/transform/atomic-proxy.ts +92 -49
- package/src/transform/cache-source.ts +87 -9
- package/src/transform/helpers.ts +8 -2
- package/src/transform/tracker.ts +69 -11
- package/src/utility/backoff.ts +95 -0
- package/src/utility/pending.ts +3 -1
- package/src/transaction/context.ts +0 -103
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { hashString } from '../utility/hash-string.js';
|
|
2
|
+
/**
|
|
3
|
+
* Rank of each operation type, used ONLY as the final tiebreaker when the same
|
|
4
|
+
* (collectionId, blockId) legitimately carries more than one operation — a block
|
|
5
|
+
* staged, then mutated, then deleted within one transform (Transforms apply order
|
|
6
|
+
* is insert → update → delete; see transform/struct.ts). This is the semantic
|
|
7
|
+
* apply order. The exact ranking is arbitrary for correctness (both sides use it),
|
|
8
|
+
* but it MUST be defined in exactly one place — here.
|
|
9
|
+
*/
|
|
10
|
+
const TYPE_RANK = {
|
|
11
|
+
insert: 0,
|
|
12
|
+
update: 1,
|
|
13
|
+
delete: 2,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Collect every block operation across all collections into a flat list.
|
|
17
|
+
*
|
|
18
|
+
* The returned order reflects Map/object insertion order and is therefore NOT
|
|
19
|
+
* canonical — {@link hashOperations} sorts before hashing, so callers do not need
|
|
20
|
+
* to pre-sort. Shared by the coordinator (both commit() and execute()) and the
|
|
21
|
+
* validator so all three collect sites produce the identical logical set.
|
|
22
|
+
*/
|
|
23
|
+
export function collectOperations(transforms) {
|
|
24
|
+
const operations = [];
|
|
25
|
+
for (const [collectionId, t] of transforms) {
|
|
26
|
+
for (const [blockId, block] of Object.entries(t.inserts ?? {})) {
|
|
27
|
+
operations.push({ type: 'insert', collectionId, blockId, block });
|
|
28
|
+
}
|
|
29
|
+
for (const [blockId, ops] of Object.entries(t.updates ?? {})) {
|
|
30
|
+
operations.push({ type: 'update', collectionId, blockId, operations: ops });
|
|
31
|
+
}
|
|
32
|
+
for (const blockId of t.deletes ?? []) {
|
|
33
|
+
operations.push({ type: 'delete', collectionId, blockId });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return operations;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Total order over operations by the tuple (collectionId, blockId, type), using
|
|
40
|
+
* plain string comparison on the first two components and {@link TYPE_RANK} on the
|
|
41
|
+
* third. This is the cross-node ordering contract: two honest nodes that see the
|
|
42
|
+
* same logical set MUST produce the same sorted sequence regardless of the order
|
|
43
|
+
* they happened to collect operations in.
|
|
44
|
+
*/
|
|
45
|
+
function compareOperations(a, b) {
|
|
46
|
+
if (a.collectionId !== b.collectionId)
|
|
47
|
+
return a.collectionId < b.collectionId ? -1 : 1;
|
|
48
|
+
if (a.blockId !== b.blockId)
|
|
49
|
+
return a.blockId < b.blockId ? -1 : 1;
|
|
50
|
+
return TYPE_RANK[a.type] - TYPE_RANK[b.type];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Canonical JSON encoder: recursively sorts object keys but PRESERVES array element
|
|
54
|
+
* order, and matches JSON.stringify leaf semantics.
|
|
55
|
+
*
|
|
56
|
+
* - Object keys are emitted in ascending (sorted) order, so two objects with the
|
|
57
|
+
* same content but different key-insertion order encode identically.
|
|
58
|
+
* - Array element order is preserved because BlockOperations is an ordered list of
|
|
59
|
+
* [entity, index, deleteCount, inserted] tuples whose order is semantically
|
|
60
|
+
* meaningful (as are any data arrays nested inside an IBlock).
|
|
61
|
+
* - Leaf semantics mirror JSON.stringify: `undefined`/function/symbol object-values
|
|
62
|
+
* are dropped, the same in arrays encode as `null`, `null` encodes as `null`,
|
|
63
|
+
* non-finite numbers as `null`, and other primitives via JSON.stringify.
|
|
64
|
+
*
|
|
65
|
+
* Exported so the order-independence test can exercise it directly.
|
|
66
|
+
*
|
|
67
|
+
* NOTE: no toJSON/Date special-casing — a value carrying toJSON (e.g. a Date)
|
|
68
|
+
* encodes as its plain enumerable keys ({} for a Date), not JSON.stringify's
|
|
69
|
+
* toJSON string. Harmless today (blocks hold plain JSON) and still deterministic
|
|
70
|
+
* across nodes (both sides run this same encoder); if IBlock content ever grows
|
|
71
|
+
* toJSON-bearing values and matching JSON.stringify exactly matters, add the hook.
|
|
72
|
+
*/
|
|
73
|
+
export function canonicalStringify(value) {
|
|
74
|
+
if (value === null)
|
|
75
|
+
return 'null';
|
|
76
|
+
const type = typeof value;
|
|
77
|
+
if (type === 'number')
|
|
78
|
+
return Number.isFinite(value) ? JSON.stringify(value) : 'null';
|
|
79
|
+
if (type === 'string' || type === 'boolean')
|
|
80
|
+
return JSON.stringify(value);
|
|
81
|
+
if (type === 'bigint')
|
|
82
|
+
throw new TypeError('Do not know how to serialize a BigInt');
|
|
83
|
+
if (type === 'undefined' || type === 'function' || type === 'symbol')
|
|
84
|
+
return 'null';
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
const items = value.map(element => {
|
|
87
|
+
const et = typeof element;
|
|
88
|
+
// In arrays, undefined/function/symbol serialize as null (JSON.stringify semantics).
|
|
89
|
+
if (element === undefined || et === 'function' || et === 'symbol')
|
|
90
|
+
return 'null';
|
|
91
|
+
return canonicalStringify(element);
|
|
92
|
+
});
|
|
93
|
+
return `[${items.join(',')}]`;
|
|
94
|
+
}
|
|
95
|
+
// Plain object: sort keys ascending, drop undefined/function/symbol values.
|
|
96
|
+
const obj = value;
|
|
97
|
+
const parts = [];
|
|
98
|
+
for (const key of Object.keys(obj).sort()) {
|
|
99
|
+
const v = obj[key];
|
|
100
|
+
const vt = typeof v;
|
|
101
|
+
if (v === undefined || vt === 'function' || vt === 'symbol')
|
|
102
|
+
continue;
|
|
103
|
+
parts.push(`${JSON.stringify(key)}:${canonicalStringify(v)}`);
|
|
104
|
+
}
|
|
105
|
+
return `{${parts.join(',')}}`;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Current operations-hash FORMAT VERSION. Versions the *serialization* of operations
|
|
109
|
+
* into bytes (the sort key, {@link canonicalStringify} rules, and the SHA-256/base64url
|
|
110
|
+
* step) — distinct from `engineId` in the TransactionStamp, which versions the operation
|
|
111
|
+
* *content* an engine produces from the same statements. Two honest nodes must agree on
|
|
112
|
+
* BOTH dimensions to produce the same ops-hash.
|
|
113
|
+
*
|
|
114
|
+
* Bump this whenever a change to the canonical serialization alters the emitted bytes,
|
|
115
|
+
* so a peer running the old format is *detected* (a legible version-skew error) rather
|
|
116
|
+
* than mistaken for a content disagreement or a Byzantine lie. See docs/transactions.md
|
|
117
|
+
* ("Operations Hash — Canonical Serialization").
|
|
118
|
+
*/
|
|
119
|
+
export const OPS_HASH_VERSION = 'v1';
|
|
120
|
+
/**
|
|
121
|
+
* Wire-token prefix carrying {@link OPS_HASH_VERSION}: `ops.v1:`. The `.` delimiter is
|
|
122
|
+
* outside the base64url alphabet (A–Z a–z 0–9 `-` `_`) that follows the trailing `:`, so
|
|
123
|
+
* the version segment can always be sliced back out unambiguously — see {@link opsHashVersion}.
|
|
124
|
+
*/
|
|
125
|
+
export const OPS_HASH_PREFIX = `ops.${OPS_HASH_VERSION}:`;
|
|
126
|
+
/**
|
|
127
|
+
* Extract the format-version segment from an ops-hash token — the `v1` in `ops.v1:<hash>` —
|
|
128
|
+
* or `null` if the string is not a recognizable versioned ops-hash token.
|
|
129
|
+
*
|
|
130
|
+
* Total: never throws. A bare legacy `ops:<hash>` token (no `.` delimiter), an empty
|
|
131
|
+
* string, or any garbage all return `null`. A validator treats a `null` (or a version it
|
|
132
|
+
* does not recognize) as an unsupported/foreign format — a legible version-skew error —
|
|
133
|
+
* never as an accidental content match.
|
|
134
|
+
*/
|
|
135
|
+
export function opsHashVersion(token) {
|
|
136
|
+
if (typeof token !== 'string')
|
|
137
|
+
return null;
|
|
138
|
+
if (!token.startsWith('ops.'))
|
|
139
|
+
return null;
|
|
140
|
+
const colon = token.indexOf(':', 4);
|
|
141
|
+
if (colon <= 4)
|
|
142
|
+
return null; // no version characters between "ops." and ":"
|
|
143
|
+
return token.slice(4, colon);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The EXACT canonical byte-string {@link hashOperations} feeds into SHA-256: the operations
|
|
147
|
+
* sorted by {@link compareOperations} and run through {@link canonicalStringify}. The version
|
|
148
|
+
* token is NOT part of this preimage — it wraps the resulting hash, it is not hashed.
|
|
149
|
+
*
|
|
150
|
+
* Exposed so a future client signature (design-client-transaction-signatures) can bind the
|
|
151
|
+
* IDENTICAL bytes the validators hash, rather than re-deriving the serialization and risking
|
|
152
|
+
* drift. Pair it with {@link OPS_HASH_VERSION} to record which format the bytes belong to.
|
|
153
|
+
*/
|
|
154
|
+
export function canonicalOperationsPayload(operations) {
|
|
155
|
+
return canonicalStringify([...operations].sort(compareOperations));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Compute the transaction operations hash: sort into canonical order, canonically
|
|
159
|
+
* stringify, SHA-256 (base64url) via {@link hashString}, then prefix the versioned
|
|
160
|
+
* {@link OPS_HASH_PREFIX} token (`ops.v1:`) so the wire string is self-describing.
|
|
161
|
+
*
|
|
162
|
+
* This is the fingerprint the coordinator sends in PendRequest.operationsHash and
|
|
163
|
+
* the validator recomputes; equality of this string is the cross-node agreement
|
|
164
|
+
* that a transaction's operations match.
|
|
165
|
+
*
|
|
166
|
+
* NOTE: the ops-hash carries a format-version token, so a mixed-version cluster now
|
|
167
|
+
* *detects* skew — a validator seeing a foreign/legacy version emits a distinct
|
|
168
|
+
* "unsupported operations-hash format version" error instead of the ambiguous
|
|
169
|
+
* "Operations hash mismatch" (see TransactionValidator). What it does NOT do is
|
|
170
|
+
* *cross-compute* older formats: a node only recognizes that a peer speaks a different
|
|
171
|
+
* version, it cannot reproduce that peer's historical bytes. Mixed-version clusters
|
|
172
|
+
* therefore fail LEGIBLY, not interoperably; multi-version compatibility is future
|
|
173
|
+
* work if rolling upgrades ship. The ops-hash is recomputed fresh on both sides and
|
|
174
|
+
* never persisted, so bumping the version cannot retroactively invalidate committed
|
|
175
|
+
* transactions (unlike transaction.id, which IS persisted — leave it untouched).
|
|
176
|
+
*/
|
|
177
|
+
export async function hashOperations(operations) {
|
|
178
|
+
return `${OPS_HASH_PREFIX}${await hashString(canonicalOperationsPayload(operations))}`;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=operations-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations-hash.js","sourceRoot":"","sources":["../../../src/transaction/operations-hash.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAgBvD;;;;;;;GAOG;AACH,MAAM,SAAS,GAAsC;IACpD,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;C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A0B,CAAC,UAAgC;IAC1E,OAAO,kBAAkB,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAAgC;IACpE,OAAO,GAAG,eAAe,GAAG,MAAM,UAAU,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BlockId, ReadPurpose } from "../blocks/index.js";
|
|
2
|
+
import type { ReadDependency } from "./transaction.js";
|
|
3
|
+
/** Accumulates the read dependencies of one transaction. Keyed by block id. For each id it keeps:
|
|
4
|
+
*
|
|
5
|
+
* - the HIGHEST revision observed (never downgrades — a re-read from cache must not overwrite a
|
|
6
|
+
* higher revision seen earlier), and
|
|
7
|
+
* - the read's PURPOSE with value-wins semantics: once a block is recorded as a `value` read from
|
|
8
|
+
* ANY path it stays `value`; `navigation` sticks only for a block that was never read as a value.
|
|
9
|
+
* This is the exact analogue of the max-wins rule on revision, and it makes the classification
|
|
10
|
+
* order-independent (so it is deterministic regardless of cache/timing — required for the
|
|
11
|
+
* transaction id and client signature to match across a re-executing validator; Theorem 4).
|
|
12
|
+
*
|
|
13
|
+
* {@link getReadDependencies} returns only the CONFLICT set (value reads); purely-structural
|
|
14
|
+
* `navigation` reads — interior B-tree branches walked through to reach a captured leaf — are
|
|
15
|
+
* dropped. See {@link markValue} and docs/correctness.md Theorem 5.
|
|
16
|
+
*
|
|
17
|
+
* One instance is shared by a collection's {@link TransactorSource} (direct structural reads —
|
|
18
|
+
* bootstrap, header) and its {@link CacheSource} (every cache hit/miss), so a block read from
|
|
19
|
+
* either layer produces a dependency. Because both feed the same collector, a cache miss records
|
|
20
|
+
* the id once from each layer at the same revision/purpose; the merge collapses those to one
|
|
21
|
+
* entry. Cleared at each txn boundary. */
|
|
22
|
+
export declare class ReadDependencyCollector {
|
|
23
|
+
private reads;
|
|
24
|
+
/** Record a read of `blockId` at `revision`. `purpose` defaults to `value` (retained); pass
|
|
25
|
+
* `navigation` for an interior structural read that a later {@link markValue} may or may not
|
|
26
|
+
* upgrade. Revision is max-wins; purpose is value-wins (see class doc). */
|
|
27
|
+
record(blockId: BlockId, revision: number, purpose?: ReadPurpose): void;
|
|
28
|
+
/** Upgrade an already-recorded read to `value` (keeping its revision), retaining it in the
|
|
29
|
+
* conflict set. The B-tree point-lookup path uses this to mark the terminal leaf — the
|
|
30
|
+
* load-bearing read whose content the result depends on — after its interior descent nodes
|
|
31
|
+
* were recorded as `navigation`. No-op if the id was never recorded (e.g. a leaf served from
|
|
32
|
+
* an uncommitted staged insert, which records no dependency at all). */
|
|
33
|
+
markValue(blockId: BlockId): void;
|
|
34
|
+
/** The optimistic-concurrency conflict (read) set: every `value` read, with `navigation`
|
|
35
|
+
* reads excluded. Dropping a covered navigation read cannot admit a lost update — any
|
|
36
|
+
* concurrent change to the queried result also bumps a retained value read (the target
|
|
37
|
+
* leaf) — but it removes the false-positive stale rejections that structural block reads
|
|
38
|
+
* otherwise caused (Theorem 5 Bound). Deterministic in query shape, so a coordinator and a
|
|
39
|
+
* re-executing validator derive the identical set. */
|
|
40
|
+
getReadDependencies(): ReadDependency[];
|
|
41
|
+
clear(): void;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=read-dependency-collector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-dependency-collector.d.ts","sourceRoot":"","sources":["../../../src/transaction/read-dependency-collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD;;;;;;;;;;;;;;;;;;2CAkB2C;AAC3C,qBAAa,uBAAuB;IACnC,OAAO,CAAC,KAAK,CAAiC;IAE9C;;gFAE4E;IAC5E,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,WAAqB,GAAG,IAAI;IAehF;;;;6EAIyE;IACzE,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAOjC;;;;;2DAKuD;IACvD,mBAAmB,IAAI,cAAc,EAAE;IAUvC,KAAK,IAAI,IAAI;CAGb"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Accumulates the read dependencies of one transaction. Keyed by block id. For each id it keeps:
|
|
2
|
+
*
|
|
3
|
+
* - the HIGHEST revision observed (never downgrades — a re-read from cache must not overwrite a
|
|
4
|
+
* higher revision seen earlier), and
|
|
5
|
+
* - the read's PURPOSE with value-wins semantics: once a block is recorded as a `value` read from
|
|
6
|
+
* ANY path it stays `value`; `navigation` sticks only for a block that was never read as a value.
|
|
7
|
+
* This is the exact analogue of the max-wins rule on revision, and it makes the classification
|
|
8
|
+
* order-independent (so it is deterministic regardless of cache/timing — required for the
|
|
9
|
+
* transaction id and client signature to match across a re-executing validator; Theorem 4).
|
|
10
|
+
*
|
|
11
|
+
* {@link getReadDependencies} returns only the CONFLICT set (value reads); purely-structural
|
|
12
|
+
* `navigation` reads — interior B-tree branches walked through to reach a captured leaf — are
|
|
13
|
+
* dropped. See {@link markValue} and docs/correctness.md Theorem 5.
|
|
14
|
+
*
|
|
15
|
+
* One instance is shared by a collection's {@link TransactorSource} (direct structural reads —
|
|
16
|
+
* bootstrap, header) and its {@link CacheSource} (every cache hit/miss), so a block read from
|
|
17
|
+
* either layer produces a dependency. Because both feed the same collector, a cache miss records
|
|
18
|
+
* the id once from each layer at the same revision/purpose; the merge collapses those to one
|
|
19
|
+
* entry. Cleared at each txn boundary. */
|
|
20
|
+
export class ReadDependencyCollector {
|
|
21
|
+
reads = new Map();
|
|
22
|
+
/** Record a read of `blockId` at `revision`. `purpose` defaults to `value` (retained); pass
|
|
23
|
+
* `navigation` for an interior structural read that a later {@link markValue} may or may not
|
|
24
|
+
* upgrade. Revision is max-wins; purpose is value-wins (see class doc). */
|
|
25
|
+
record(blockId, revision, purpose = 'value') {
|
|
26
|
+
const prev = this.reads.get(blockId);
|
|
27
|
+
if (prev === undefined) {
|
|
28
|
+
this.reads.set(blockId, { revision, purpose });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (revision > prev.revision) {
|
|
32
|
+
prev.revision = revision;
|
|
33
|
+
}
|
|
34
|
+
// value-wins: a value read anywhere pins the block as value; navigation never downgrades it.
|
|
35
|
+
if (purpose === 'value') {
|
|
36
|
+
prev.purpose = 'value';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Upgrade an already-recorded read to `value` (keeping its revision), retaining it in the
|
|
40
|
+
* conflict set. The B-tree point-lookup path uses this to mark the terminal leaf — the
|
|
41
|
+
* load-bearing read whose content the result depends on — after its interior descent nodes
|
|
42
|
+
* were recorded as `navigation`. No-op if the id was never recorded (e.g. a leaf served from
|
|
43
|
+
* an uncommitted staged insert, which records no dependency at all). */
|
|
44
|
+
markValue(blockId) {
|
|
45
|
+
const prev = this.reads.get(blockId);
|
|
46
|
+
if (prev) {
|
|
47
|
+
prev.purpose = 'value';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** The optimistic-concurrency conflict (read) set: every `value` read, with `navigation`
|
|
51
|
+
* reads excluded. Dropping a covered navigation read cannot admit a lost update — any
|
|
52
|
+
* concurrent change to the queried result also bumps a retained value read (the target
|
|
53
|
+
* leaf) — but it removes the false-positive stale rejections that structural block reads
|
|
54
|
+
* otherwise caused (Theorem 5 Bound). Deterministic in query shape, so a coordinator and a
|
|
55
|
+
* re-executing validator derive the identical set. */
|
|
56
|
+
getReadDependencies() {
|
|
57
|
+
const result = [];
|
|
58
|
+
for (const [blockId, entry] of this.reads) {
|
|
59
|
+
if (entry.purpose === 'value') {
|
|
60
|
+
result.push({ blockId, revision: entry.revision });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
clear() {
|
|
66
|
+
this.reads.clear();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=read-dependency-collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-dependency-collector.js","sourceRoot":"","sources":["../../../src/transaction/read-dependency-collector.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;2CAkB2C;AAC3C,MAAM,OAAO,uBAAuB;IAC3B,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE9C;;gFAE4E;IAC5E,MAAM,CAAC,OAAgB,EAAE,QAAgB,EAAE,UAAuB,OAAO;QACxE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;YAC/C,OAAO;QACR,CAAC;QACD,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC1B,CAAC;QACD,6FAA6F;QAC7F,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACxB,CAAC;IACF,CAAC;IAED;;;;6EAIyE;IACzE,SAAS,CAAC,OAAgB;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,IAAI,EAAE,CAAC;YACV,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACxB,CAAC;IACF,CAAC;IAED;;;;;2DAKuD;IACvD,mBAAmB;QAClB,MAAM,MAAM,GAAqB,EAAE,CAAC;QACpC,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3C,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAC/B,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;CACD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TransactionCoordinator } from "./coordinator.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SyncOptions } from "../collection/index.js";
|
|
3
|
+
import type { ExecutionResult, ITransactionEngine, TransactionStamp, CollectionActions, TransactionSigner } from "./transaction.js";
|
|
3
4
|
/**
|
|
4
5
|
* TransactionSession manages incremental transaction building.
|
|
5
6
|
*
|
|
@@ -22,6 +23,7 @@ import type { ExecutionResult, ITransactionEngine, TransactionStamp, CollectionA
|
|
|
22
23
|
export declare class TransactionSession {
|
|
23
24
|
private readonly coordinator;
|
|
24
25
|
private readonly engine;
|
|
26
|
+
private readonly signer?;
|
|
25
27
|
private readonly statements;
|
|
26
28
|
private readonly stamp;
|
|
27
29
|
private committed;
|
|
@@ -30,8 +32,12 @@ export declare class TransactionSession {
|
|
|
30
32
|
/**
|
|
31
33
|
* Create a new TransactionSession.
|
|
32
34
|
* Uses async factory because stamp creation requires SHA-256 hashing.
|
|
35
|
+
*
|
|
36
|
+
* @param signer - Optional client signer. When supplied, commit() stamps the built
|
|
37
|
+
* transaction's `signature` over its canonical payload; when omitted the
|
|
38
|
+
* transaction is left unsigned (accepted only by nodes with no verifier wired).
|
|
33
39
|
*/
|
|
34
|
-
static create(coordinator: TransactionCoordinator, engine: ITransactionEngine, peerId?: string, schemaHash?: string, ttlMs?: number): Promise<TransactionSession>;
|
|
40
|
+
static create(coordinator: TransactionCoordinator, engine: ITransactionEngine, peerId?: string, schemaHash?: string, ttlMs?: number, signer?: TransactionSigner): Promise<TransactionSession>;
|
|
35
41
|
/**
|
|
36
42
|
* Execute a statement.
|
|
37
43
|
*
|
|
@@ -50,8 +56,11 @@ export declare class TransactionSession {
|
|
|
50
56
|
* Commit the transaction.
|
|
51
57
|
*
|
|
52
58
|
* Compiles all statements into a complete Transaction and commits through coordinator.
|
|
59
|
+
*
|
|
60
|
+
* @param options - Optional retry knobs forwarded to {@link TransactionCoordinator.commit}
|
|
61
|
+
* (bounded backoff+jitter retry of a clean stale loss). Defaults are safe out of the box.
|
|
53
62
|
*/
|
|
54
|
-
commit(): Promise<ExecutionResult>;
|
|
63
|
+
commit(options?: SyncOptions): Promise<ExecutionResult>;
|
|
55
64
|
/**
|
|
56
65
|
* Rollback the transaction (undo this session's applied actions).
|
|
57
66
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/transaction/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAe,eAAe,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/transaction/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAe,eAAe,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGjJ;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,kBAAkB;IAO7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IATzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;IAC3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO;IASP;;;;;;;OAOG;WACU,MAAM,CAClB,WAAW,EAAE,sBAAsB,EACnC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,MAAgB,EACxB,UAAU,GAAE,MAAW,EACvB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,iBAAiB,GACxB,OAAO,CAAC,kBAAkB,CAAC;IAW9B;;;;;;;;;OASG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IA2C9G;;;;;;;OAOG;IACG,MAAM,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;IAkD7D;;;;;;OAMG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAe/B;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,QAAQ,IAAI,gBAAgB;IAI5B;;OAEG;IACH,aAAa,IAAI,SAAS,MAAM,EAAE;IAIlC;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,YAAY,IAAI,OAAO;CAGvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createTransactionStamp, createTransactionId, isTransactionExpired } from "./transaction.js";
|
|
1
|
+
import { createTransactionStamp, createTransactionId, isTransactionExpired, clientSignaturePayload } from "./transaction.js";
|
|
2
2
|
/**
|
|
3
3
|
* TransactionSession manages incremental transaction building.
|
|
4
4
|
*
|
|
@@ -21,23 +21,28 @@ import { createTransactionStamp, createTransactionId, isTransactionExpired } fro
|
|
|
21
21
|
export class TransactionSession {
|
|
22
22
|
coordinator;
|
|
23
23
|
engine;
|
|
24
|
+
signer;
|
|
24
25
|
statements = [];
|
|
25
26
|
stamp;
|
|
26
27
|
committed = false;
|
|
27
28
|
rolledBack = false;
|
|
28
|
-
constructor(coordinator, engine, stamp) {
|
|
29
|
+
constructor(coordinator, engine, stamp, signer) {
|
|
29
30
|
this.coordinator = coordinator;
|
|
30
31
|
this.engine = engine;
|
|
32
|
+
this.signer = signer;
|
|
31
33
|
this.stamp = stamp;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* Create a new TransactionSession.
|
|
35
37
|
* Uses async factory because stamp creation requires SHA-256 hashing.
|
|
38
|
+
*
|
|
39
|
+
* @param signer - Optional client signer. When supplied, commit() stamps the built
|
|
40
|
+
* transaction's `signature` over its canonical payload; when omitted the
|
|
41
|
+
* transaction is left unsigned (accepted only by nodes with no verifier wired).
|
|
36
42
|
*/
|
|
37
|
-
static async create(coordinator, engine, peerId = 'local', schemaHash = '', ttlMs) {
|
|
38
|
-
const stamp = await createTransactionStamp(peerId, Date.now(), schemaHash,
|
|
39
|
-
|
|
40
|
-
return new TransactionSession(coordinator, engine, stamp);
|
|
43
|
+
static async create(coordinator, engine, peerId = 'local', schemaHash = '', ttlMs, signer) {
|
|
44
|
+
const stamp = await createTransactionStamp(peerId, Date.now(), schemaHash, engine.id, ttlMs);
|
|
45
|
+
return new TransactionSession(coordinator, engine, stamp, signer);
|
|
41
46
|
}
|
|
42
47
|
/**
|
|
43
48
|
* Execute a statement.
|
|
@@ -93,8 +98,11 @@ export class TransactionSession {
|
|
|
93
98
|
* Commit the transaction.
|
|
94
99
|
*
|
|
95
100
|
* Compiles all statements into a complete Transaction and commits through coordinator.
|
|
101
|
+
*
|
|
102
|
+
* @param options - Optional retry knobs forwarded to {@link TransactionCoordinator.commit}
|
|
103
|
+
* (bounded backoff+jitter retry of a clean stale loss). Defaults are safe out of the box.
|
|
96
104
|
*/
|
|
97
|
-
async commit() {
|
|
105
|
+
async commit(options) {
|
|
98
106
|
if (this.committed) {
|
|
99
107
|
return { success: false, error: 'Transaction already committed' };
|
|
100
108
|
}
|
|
@@ -113,8 +121,26 @@ export class TransactionSession {
|
|
|
113
121
|
reads,
|
|
114
122
|
id: await createTransactionId(this.stamp.id, this.statements, reads)
|
|
115
123
|
};
|
|
116
|
-
//
|
|
117
|
-
|
|
124
|
+
// Sign the canonical client-signature payload if a signer was supplied. The
|
|
125
|
+
// payload covers stamp.id + statements + reads, which are all final now. A signer failure
|
|
126
|
+
// (e.g. a wrong-key-type libp2p sign) is caught and surfaced as a clean commit failure BEFORE
|
|
127
|
+
// coordinator.commit runs — the transaction object is local and discarded, so a failed sign can
|
|
128
|
+
// never leak a partially-built unsigned transaction into consensus.
|
|
129
|
+
if (this.signer) {
|
|
130
|
+
const payload = clientSignaturePayload(this.stamp.id, this.statements, reads);
|
|
131
|
+
try {
|
|
132
|
+
transaction.signature = await this.signer(payload);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return {
|
|
136
|
+
success: false,
|
|
137
|
+
error: `Failed to sign transaction: ${error instanceof Error ? error.message : String(error)}`
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Commit through coordinator (which will orchestrate PEND/COMMIT, with bounded
|
|
142
|
+
// backoff+jitter retry of a clean stale loss)
|
|
143
|
+
await this.coordinator.commit(transaction, options);
|
|
118
144
|
// Clear read dependencies after successful commit
|
|
119
145
|
this.coordinator.clearReadDependencies();
|
|
120
146
|
this.committed = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/transaction/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/transaction/session.ts"],"names":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