@optimystic/db-core 1.18.0 → 1.20.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 +2 -1
- package/dist/src/blocks/helpers.d.ts +7 -0
- package/dist/src/blocks/helpers.d.ts.map +1 -1
- package/dist/src/blocks/helpers.js +7 -1
- package/dist/src/blocks/helpers.js.map +1 -1
- package/dist/src/btree/btree.d.ts +100 -4
- package/dist/src/btree/btree.d.ts.map +1 -1
- package/dist/src/btree/btree.js +252 -90
- package/dist/src/btree/btree.js.map +1 -1
- package/dist/src/btree/node-division.d.ts +37 -0
- package/dist/src/btree/node-division.d.ts.map +1 -0
- package/dist/src/btree/node-division.js +133 -0
- package/dist/src/btree/node-division.js.map +1 -0
- package/dist/src/chain/chain.d.ts +23 -0
- package/dist/src/chain/chain.d.ts.map +1 -1
- package/dist/src/chain/chain.js +43 -6
- package/dist/src/chain/chain.js.map +1 -1
- package/dist/src/cluster/structs.d.ts +41 -8
- package/dist/src/cluster/structs.d.ts.map +1 -1
- package/dist/src/cluster/structs.js +18 -7
- package/dist/src/cluster/structs.js.map +1 -1
- package/dist/src/collection/action.d.ts +29 -0
- package/dist/src/collection/action.d.ts.map +1 -1
- package/dist/src/collection/action.js +6 -0
- package/dist/src/collection/action.js.map +1 -1
- package/dist/src/collection/collection.d.ts +566 -120
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +1084 -495
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collection/head-commit.d.ts +110 -0
- package/dist/src/collection/head-commit.d.ts.map +1 -0
- package/dist/src/collection/head-commit.js +65 -0
- package/dist/src/collection/head-commit.js.map +1 -0
- package/dist/src/collection/index.d.ts +2 -0
- package/dist/src/collection/index.d.ts.map +1 -1
- package/dist/src/collection/index.js +2 -0
- package/dist/src/collection/index.js.map +1 -1
- package/dist/src/collection/segments.d.ts +77 -0
- package/dist/src/collection/segments.d.ts.map +1 -0
- package/dist/src/collection/segments.js +110 -0
- package/dist/src/collection/segments.js.map +1 -0
- package/dist/src/collection/struct.d.ts +176 -1
- package/dist/src/collection/struct.d.ts.map +1 -1
- package/dist/src/collection/struct.js +70 -0
- package/dist/src/collection/struct.js.map +1 -1
- package/dist/src/collection/write-attempts.d.ts +245 -0
- package/dist/src/collection/write-attempts.d.ts.map +1 -0
- package/dist/src/collection/write-attempts.js +439 -0
- package/dist/src/collection/write-attempts.js.map +1 -0
- package/dist/src/collections/tree/struct.d.ts +100 -17
- package/dist/src/collections/tree/struct.d.ts.map +1 -1
- package/dist/src/collections/tree/struct.js +38 -7
- package/dist/src/collections/tree/struct.js.map +1 -1
- package/dist/src/collections/tree/tree.d.ts +17 -5
- package/dist/src/collections/tree/tree.d.ts.map +1 -1
- package/dist/src/collections/tree/tree.js +117 -29
- package/dist/src/collections/tree/tree.js.map +1 -1
- 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/log/log.d.ts +5 -1
- package/dist/src/log/log.d.ts.map +1 -1
- package/dist/src/log/log.js +7 -1
- package/dist/src/log/log.js.map +1 -1
- package/dist/src/network/block-size.d.ts +67 -0
- package/dist/src/network/block-size.d.ts.map +1 -0
- package/dist/src/network/block-size.js +82 -0
- package/dist/src/network/block-size.js.map +1 -0
- package/dist/src/network/i-repo.d.ts +3 -0
- package/dist/src/network/i-repo.d.ts.map +1 -1
- package/dist/src/network/index.d.ts +5 -0
- package/dist/src/network/index.d.ts.map +1 -1
- package/dist/src/network/index.js +5 -0
- package/dist/src/network/index.js.map +1 -1
- package/dist/src/network/promise-shortfall-error.d.ts +40 -0
- package/dist/src/network/promise-shortfall-error.d.ts.map +1 -0
- package/dist/src/network/promise-shortfall-error.js +67 -0
- package/dist/src/network/promise-shortfall-error.js.map +1 -0
- package/dist/src/network/refuse-solo.d.ts +8 -0
- package/dist/src/network/refuse-solo.d.ts.map +1 -0
- package/dist/src/network/refuse-solo.js +8 -0
- package/dist/src/network/refuse-solo.js.map +1 -0
- package/dist/src/network/stale-failure.d.ts +20 -3
- package/dist/src/network/stale-failure.d.ts.map +1 -1
- package/dist/src/network/stale-failure.js +24 -3
- package/dist/src/network/stale-failure.js.map +1 -1
- package/dist/src/network/struct.d.ts +161 -13
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/network/struct.js.map +1 -1
- package/dist/src/network/transaction-size.d.ts +59 -0
- package/dist/src/network/transaction-size.d.ts.map +1 -0
- package/dist/src/network/transaction-size.js +74 -0
- package/dist/src/network/transaction-size.js.map +1 -0
- package/dist/src/network/validity-rejected-error.d.ts +28 -0
- package/dist/src/network/validity-rejected-error.d.ts.map +1 -0
- package/dist/src/network/validity-rejected-error.js +51 -0
- package/dist/src/network/validity-rejected-error.js.map +1 -0
- package/dist/src/offline/entry.d.ts +72 -0
- package/dist/src/offline/entry.d.ts.map +1 -0
- package/dist/src/offline/entry.js +73 -0
- package/dist/src/offline/entry.js.map +1 -0
- package/dist/src/offline/index.d.ts +5 -0
- package/dist/src/offline/index.d.ts.map +1 -0
- package/dist/src/offline/index.js +5 -0
- package/dist/src/offline/index.js.map +1 -0
- package/dist/src/offline/journal.d.ts +61 -0
- package/dist/src/offline/journal.d.ts.map +1 -0
- package/dist/src/offline/journal.js +2 -0
- package/dist/src/offline/journal.js.map +1 -0
- package/dist/src/offline/queue.d.ts +484 -0
- package/dist/src/offline/queue.d.ts.map +1 -0
- package/dist/src/offline/queue.js +1236 -0
- package/dist/src/offline/queue.js.map +1 -0
- package/dist/src/offline/reachability.d.ts +25 -0
- package/dist/src/offline/reachability.d.ts.map +1 -0
- package/dist/src/offline/reachability.js +13 -0
- package/dist/src/offline/reachability.js.map +1 -0
- package/dist/src/offline/status.d.ts +148 -0
- package/dist/src/offline/status.d.ts.map +1 -0
- package/dist/src/offline/status.js +63 -0
- package/dist/src/offline/status.js.map +1 -0
- package/dist/src/offline/wake.d.ts +30 -0
- package/dist/src/offline/wake.d.ts.map +1 -0
- package/dist/src/offline/wake.js +68 -0
- package/dist/src/offline/wake.js.map +1 -0
- package/dist/src/reactivity/config.d.ts +8 -4
- package/dist/src/reactivity/config.d.ts.map +1 -1
- package/dist/src/reactivity/config.js +7 -3
- package/dist/src/reactivity/config.js.map +1 -1
- package/dist/src/reactivity/rotation.d.ts +9 -3
- package/dist/src/reactivity/rotation.d.ts.map +1 -1
- package/dist/src/reactivity/rotation.js +8 -2
- package/dist/src/reactivity/rotation.js.map +1 -1
- package/dist/src/testing/test-transactor.d.ts +31 -0
- package/dist/src/testing/test-transactor.d.ts.map +1 -1
- package/dist/src/testing/test-transactor.js +60 -0
- package/dist/src/testing/test-transactor.js.map +1 -1
- package/dist/src/transaction/commit-failure-class.d.ts +103 -0
- package/dist/src/transaction/commit-failure-class.d.ts.map +1 -0
- package/dist/src/transaction/commit-failure-class.js +96 -0
- package/dist/src/transaction/commit-failure-class.js.map +1 -0
- package/dist/src/transaction/coordinator.d.ts +224 -31
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +841 -362
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transaction/entry-commit.d.ts +139 -0
- package/dist/src/transaction/entry-commit.d.ts.map +1 -0
- package/dist/src/transaction/entry-commit.js +199 -0
- package/dist/src/transaction/entry-commit.js.map +1 -0
- package/dist/src/transaction/index.d.ts +4 -1
- package/dist/src/transaction/index.d.ts.map +1 -1
- package/dist/src/transaction/index.js +1 -0
- package/dist/src/transaction/index.js.map +1 -1
- package/dist/src/transaction/transaction.d.ts +20 -0
- package/dist/src/transaction/transaction.d.ts.map +1 -1
- package/dist/src/transaction/validator.d.ts +7 -0
- package/dist/src/transaction/validator.d.ts.map +1 -1
- package/dist/src/transaction/validator.js +21 -12
- package/dist/src/transaction/validator.js.map +1 -1
- package/dist/src/transactor/change-notifier.d.ts +13 -4
- package/dist/src/transactor/change-notifier.d.ts.map +1 -1
- package/dist/src/transactor/change-notifier.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts +58 -8
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +244 -50
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/dist/src/transactor/transactor-source.d.ts +22 -11
- package/dist/src/transactor/transactor-source.d.ts.map +1 -1
- package/dist/src/transactor/transactor-source.js +9 -13
- package/dist/src/transactor/transactor-source.js.map +1 -1
- package/dist/src/transactor/transactor.d.ts +14 -0
- package/dist/src/transactor/transactor.d.ts.map +1 -1
- package/dist/src/transform/digest.d.ts +20 -0
- package/dist/src/transform/digest.d.ts.map +1 -1
- package/dist/src/transform/digest.js +23 -3
- package/dist/src/transform/digest.js.map +1 -1
- package/dist/src/utility/visit-every.d.ts +14 -0
- package/dist/src/utility/visit-every.d.ts.map +1 -0
- package/dist/src/utility/visit-every.js +27 -0
- package/dist/src/utility/visit-every.js.map +1 -0
- package/package.json +1 -1
- package/src/blocks/helpers.ts +8 -1
- package/src/btree/btree.ts +266 -88
- package/src/btree/node-division.ts +155 -0
- package/src/chain/chain.ts +55 -6
- package/src/cluster/structs.ts +42 -7
- package/src/collection/action.ts +34 -0
- package/src/collection/collection.ts +1167 -540
- package/src/collection/head-commit.ts +148 -0
- package/src/collection/index.ts +2 -0
- package/src/collection/segments.ts +149 -0
- package/src/collection/struct.ts +201 -1
- package/src/collection/write-attempts.ts +506 -0
- package/src/collections/tree/struct.ts +97 -17
- package/src/collections/tree/tree.ts +129 -31
- package/src/index.ts +2 -0
- package/src/log/log.ts +7 -1
- package/src/network/block-size.ts +81 -0
- package/src/network/i-repo.ts +3 -0
- package/src/network/index.ts +5 -0
- package/src/network/promise-shortfall-error.ts +69 -0
- package/src/network/refuse-solo.ts +7 -0
- package/src/network/stale-failure.ts +27 -4
- package/src/network/struct.ts +169 -15
- package/src/network/transaction-size.ts +73 -0
- package/src/network/validity-rejected-error.ts +55 -0
- package/src/offline/entry.ts +127 -0
- package/src/offline/index.ts +4 -0
- package/src/offline/journal.ts +60 -0
- package/src/offline/queue.ts +1342 -0
- package/src/offline/reachability.ts +32 -0
- package/src/offline/status.ts +183 -0
- package/src/offline/wake.ts +67 -0
- package/src/reactivity/config.ts +8 -4
- package/src/reactivity/rotation.ts +9 -3
- package/src/testing/test-transactor.ts +65 -0
- package/src/transaction/commit-failure-class.ts +133 -0
- package/src/transaction/coordinator.ts +969 -393
- package/src/transaction/entry-commit.ts +285 -0
- package/src/transaction/index.ts +4 -0
- package/src/transaction/transaction.ts +21 -0
- package/src/transaction/validator.ts +22 -12
- package/src/transactor/change-notifier.ts +13 -4
- package/src/transactor/network-transactor.ts +252 -55
- package/src/transactor/transactor-source.ts +29 -13
- package/src/transactor/transactor.ts +16 -0
- package/src/transform/digest.ts +36 -3
- package/src/utility/visit-every.ts +25 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CollectionId, BlockId, IBlock, ActionId, Transform, Transforms } from "../index.js";
|
|
2
2
|
import type { ActionContext, ActionRev } from "../collection/action.js";
|
|
3
|
-
import type { Transaction } from "../transaction/transaction.js";
|
|
3
|
+
import type { Transaction, ValidityRejection } from "../transaction/transaction.js";
|
|
4
4
|
import type { DisputeResolutionProof } from "../log/struct.js";
|
|
5
5
|
import type { PeerId } from "./types.js";
|
|
6
6
|
export type ActionBlocks = {
|
|
@@ -78,18 +78,20 @@ export type PendRequest = ActionTransforms & {
|
|
|
78
78
|
*/
|
|
79
79
|
baseRevs?: BlockBaseRevs;
|
|
80
80
|
/**
|
|
81
|
-
* The writer's word that this pend
|
|
82
|
-
* is
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
81
|
+
* The writer's word that this pend, together with the other pends sent with it in one request
|
|
82
|
+
* (`IRepo.pendMany`), is the action's whole reservation — every block the action will commit is in
|
|
83
|
+
* that one request — and that the action's commit goes as one request to the coordinator this pend
|
|
84
|
+
* goes to. Only then may a coordinator hold back the pend record's final delivery to the other
|
|
85
|
+
* members and send it inside the commit's first request (`ClusterCoordinator.mayDeferPendDelivery`
|
|
86
|
+
* in db-p2p): a member that refuses any of the record's pends late refuses that one commit record,
|
|
87
|
+
* before anything of the action is durable. A send that pends in several requests before committing
|
|
88
|
+
* any — several collections one request each under one action id, or one collection split across
|
|
89
|
+
* coordinators — must never carry it: one request's late refusal would surface while another
|
|
90
|
+
* request's commit may already have landed, tearing the action.
|
|
90
91
|
*
|
|
91
|
-
* Set by `TransactorSource.transact
|
|
92
|
-
* one collection
|
|
92
|
+
* Set by `TransactorSource.transact`, and by `TransactionCoordinator` for a transaction of exactly
|
|
93
|
+
* one collection or for every request of a `pendMany` (whose commit goes through `commitMany`);
|
|
94
|
+
* `NetworkTransactor.pend` keeps it only on a request carrying the whole pend.
|
|
93
95
|
* `Collection.completeOwnEntry` re-sends one participant of a half-landed multi-collection action
|
|
94
96
|
* through `transact`, and carries it too: that re-send pends and commits its one collection on its
|
|
95
97
|
* own, so its late refusal stops only its own commit, as an on-time refusal would.
|
|
@@ -97,6 +99,25 @@ export type PendRequest = ActionTransforms & {
|
|
|
97
99
|
* an older build ignores it, and then delivers at once as it always did.
|
|
98
100
|
*/
|
|
99
101
|
soleReservation?: true;
|
|
102
|
+
/**
|
|
103
|
+
* The writer's word that this write must not be committed by a lone node that knows it is not
|
|
104
|
+
* alone (`SyncOptions.refuseSoloCommit`). A coordinator whose cohort for the write is only itself
|
|
105
|
+
* refuses the pend — before reserving anything — when it knows of cohort members it could not
|
|
106
|
+
* place in the cohort, is still waiting to hear from a configured bootstrap peer, or could not
|
|
107
|
+
* route the write to itself, answering with a {@link ShortfallFailure} whose
|
|
108
|
+
* {@link PromiseShortfall.soloRefused} names which (`CoordinatorRepo.pendSolo` in db-p2p). A
|
|
109
|
+
* coordinator that is genuinely alone ignores it and pends as it always did, and so does every
|
|
110
|
+
* coordinator whose cohort has more than one member.
|
|
111
|
+
*
|
|
112
|
+
* Carried by every send of the write's attempt cycle, the re-send a refresh makes to finish a torn
|
|
113
|
+
* attempt included (`Collection.completeOwnEntry`). Every per-coordinator rebuild of the request
|
|
114
|
+
* keeps it (`pendRequestForBatch` in `NetworkTransactor`), since a batch that dropped it would
|
|
115
|
+
* lose the protection for that coordinator's share. Omitted rather than `false`, for the same
|
|
116
|
+
* preimage reason as {@link baseRevs}: a write that does not set it serializes exactly as before.
|
|
117
|
+
* A coordinator on an older build ignores it and commits alone at `local`; in a group of mixed
|
|
118
|
+
* versions the offline queue's reachability gate is then the only protection.
|
|
119
|
+
*/
|
|
120
|
+
refuseSolo?: true;
|
|
100
121
|
};
|
|
101
122
|
export type BlockActionStatus = ActionBlocks & {
|
|
102
123
|
statuses: ('pending' | 'committed' | 'checkpointed' | 'aborted' | 'committed-invalidated')[];
|
|
@@ -219,6 +240,12 @@ export type StaleFailure = {
|
|
|
219
240
|
};
|
|
220
241
|
/** Never set on a lost race — an expiry is its own failure shape, {@link ExpiredFailure}. */
|
|
221
242
|
expired?: never;
|
|
243
|
+
/** Never set on a lost race — a cohort too few of whose members answered is its own failure
|
|
244
|
+
* shape, {@link ShortfallFailure}. */
|
|
245
|
+
shortfall?: never;
|
|
246
|
+
/** Never set on a lost race — a write judged invalid is its own failure shape,
|
|
247
|
+
* {@link RejectedFailure}. */
|
|
248
|
+
rejected?: never;
|
|
222
249
|
};
|
|
223
250
|
/**
|
|
224
251
|
* Why a cohort refused a write as expired: by each refusing member's own clock, the transaction's
|
|
@@ -253,9 +280,117 @@ export type ExpiredFailure = {
|
|
|
253
280
|
missing?: never;
|
|
254
281
|
pending?: never;
|
|
255
282
|
staleAt?: never;
|
|
283
|
+
shortfall?: never;
|
|
284
|
+
rejected?: never;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Why a cohort's promise round fell short with no member refusing it as a lost race or a held block,
|
|
288
|
+
* and too few rejecting it for a rejection: too few members answered. Plain data, so it crosses the
|
|
289
|
+
* JSON repo protocol intact. `PromiseShortfallError` is built from it, wherever it is raised.
|
|
290
|
+
*/
|
|
291
|
+
export type PromiseShortfall = {
|
|
292
|
+
/** Approve votes the round received. */
|
|
293
|
+
approvals: number;
|
|
294
|
+
/** Reject votes the round received — fewer than would make the round a rejection. */
|
|
295
|
+
rejections: number;
|
|
296
|
+
/** How many members the cohort the round ran on has. */
|
|
297
|
+
peerCount: number;
|
|
298
|
+
/** The approvals the round needed: `ceil(peerCount × superMajorityThreshold)`. */
|
|
299
|
+
needed: number;
|
|
300
|
+
/** Peer-id strings of the cohort members that cast no promise vote at all. */
|
|
301
|
+
silentPeers: string[];
|
|
302
|
+
/**
|
|
303
|
+
* Set only when no consensus round ran: a coordinator whose cohort for the write was only itself
|
|
304
|
+
* refused to write alone, because the write asked it to (`PendRequest.refuseSolo`). The other
|
|
305
|
+
* fields then describe the cohort the coordinator expected rather than one it asked: one approval
|
|
306
|
+
* (its own), no rejections, the members it knows of and could not reach as `silentPeers`, and the
|
|
307
|
+
* bar a cohort of that size would set. Absent on a shortfall a consensus round produced, so a log
|
|
308
|
+
* or an application can tell "refused to write alone" from "a round heard too few".
|
|
309
|
+
*/
|
|
310
|
+
soloRefused?: SoloRefusalReason;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* Why a lone coordinator refused a write that asked not to be committed alone
|
|
314
|
+
* (`PendRequest.refuseSolo`, `CommitRequest.refuseSolo`):
|
|
315
|
+
* - `absent-members`: its cohort for the write was only itself, and it knows of cohort members it
|
|
316
|
+
* could not place in that cohort (`IKeyNetwork.absentCohortMembers`);
|
|
317
|
+
* - `awaiting-bootstrap`: its cohort was only itself and it is still waiting to hear from a peer it
|
|
318
|
+
* was configured to join through (`IKeyNetwork.awaitingBootstrapContact`);
|
|
319
|
+
* - `unrouted`: the cohort lookup failed, named nobody, or named one peer that is not this node.
|
|
320
|
+
*/
|
|
321
|
+
export type SoloRefusalReason = 'absent-members' | 'awaiting-bootstrap' | 'unrouted';
|
|
322
|
+
/**
|
|
323
|
+
* The cohort refused the pend because too few of its members ANSWERED the promise round for it to
|
|
324
|
+
* reach its bar — silence, not a judgement of the write and not a lost race. Not retryable by a write
|
|
325
|
+
* path: every coordinator of that cohort meets the same silent members, so a re-read and re-pend fails
|
|
326
|
+
* the same way until they come back. A sibling of {@link StaleFailure} and {@link ExpiredFailure},
|
|
327
|
+
* with the fields it can never carry typed `never`, so a consumer reads `reason`, `missing` or
|
|
328
|
+
* `staleAt` off any of them unnarrowed. Tell it apart with `isShortfallFailure`, never by reading
|
|
329
|
+
* `reason`. A pend answer only: a commit that falls short is still thrown (see
|
|
330
|
+
* `CoordinatorRepo.commit`).
|
|
331
|
+
*/
|
|
332
|
+
export type ShortfallFailure = {
|
|
333
|
+
success: false;
|
|
334
|
+
/** The coordinator's description of the refusal, for a log line. Never branch on it. */
|
|
335
|
+
reason?: string;
|
|
336
|
+
/** Always false: silence is not a conflict a re-read can win. */
|
|
337
|
+
conflict: false;
|
|
338
|
+
shortfall: PromiseShortfall;
|
|
339
|
+
missing?: never;
|
|
340
|
+
pending?: never;
|
|
341
|
+
staleAt?: never;
|
|
342
|
+
expired?: never;
|
|
343
|
+
rejected?: never;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* One refusal behind a {@link TransactionInvalidity}: a cohort member's validity-marked reject vote
|
|
347
|
+
* (`Signature`'s `validity`), or the validity verdict of the coordinating node's own storage-tier check
|
|
348
|
+
* (`StorageRepo.pend`, for a cohort of one, where no vote is cast).
|
|
349
|
+
*/
|
|
350
|
+
export type ValidityRefusal = ValidityRejection & {
|
|
351
|
+
/** The refusing member's peer-id string. Absent for a refusal a node's storage made without a vote. */
|
|
352
|
+
peerId?: string;
|
|
353
|
+
/** The refuser's description, free-form, for a log line. Never branch on it. */
|
|
354
|
+
reason?: string;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Why a write was refused as INVALID: the members that sank it judged the transaction itself wrong
|
|
358
|
+
* (see {@link ValidityRejection} for which refusals qualify), and no refusal of any other kind sank it
|
|
359
|
+
* beside them, bar expiry votes. Plain data, so it crosses the JSON repo protocol intact.
|
|
360
|
+
* `ValidityRejectedError` is built from it, wherever it is raised.
|
|
361
|
+
*/
|
|
362
|
+
export type TransactionInvalidity = {
|
|
363
|
+
/** Every validity refusal that sank the write. Never empty. */
|
|
364
|
+
refusals: ValidityRefusal[];
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* The cohort refused the write because the members that sank it judged it INVALID — the transaction
|
|
368
|
+
* failed its re-execution, its operations hash, its stamp or its client signature. Never retryable:
|
|
369
|
+
* re-sending the same content to the same checks is refused the same way. A sibling of
|
|
370
|
+
* {@link StaleFailure}, {@link ExpiredFailure} and {@link ShortfallFailure}, with the fields it can
|
|
371
|
+
* never carry typed `never`, so a consumer reads `reason`, `missing` or `staleAt` off any of them
|
|
372
|
+
* unnarrowed. Tell it apart with `isRejectedFailure`, never by reading `reason`.
|
|
373
|
+
*
|
|
374
|
+
* A pend answer only, and only when nothing else could explain the rejection: a reject vote with no
|
|
375
|
+
* validity marker beside the marked ones (a stale revision, a member on an older build) leaves the
|
|
376
|
+
* rejection unclassified, and a revision loss the coordinator's own storage confirms is returned as
|
|
377
|
+
* the {@link StaleFailure} it is, since the writer's rebase sends different content.
|
|
378
|
+
*/
|
|
379
|
+
export type RejectedFailure = {
|
|
380
|
+
success: false;
|
|
381
|
+
/** The coordinator's description of the refusal, for a log line. Never branch on it. */
|
|
382
|
+
reason?: string;
|
|
383
|
+
/** Always false: a verdict on the content is not a conflict a re-read can win. */
|
|
384
|
+
conflict: false;
|
|
385
|
+
rejected: TransactionInvalidity;
|
|
386
|
+
missing?: never;
|
|
387
|
+
pending?: never;
|
|
388
|
+
staleAt?: never;
|
|
389
|
+
expired?: never;
|
|
390
|
+
shortfall?: never;
|
|
256
391
|
};
|
|
257
392
|
/** Every way a pend or a commit can be refused with an answer rather than a throw. */
|
|
258
|
-
export type WriteFailure = StaleFailure | ExpiredFailure;
|
|
393
|
+
export type WriteFailure = StaleFailure | ExpiredFailure | ShortfallFailure | RejectedFailure;
|
|
259
394
|
export type PendResult = PendSuccess | WriteFailure;
|
|
260
395
|
/** What one block will materialize to at the committing revision, declared by the client that
|
|
261
396
|
* authored the transforms. */
|
|
@@ -292,6 +427,17 @@ export type CommitRequest = ActionBlocks & {
|
|
|
292
427
|
* cohort signature with no change to the hash helpers. Action-wide here; the transactor narrows
|
|
293
428
|
* it to each per-coordinator batch's own block ids before sending (`RepoCommitRequest`). */
|
|
294
429
|
blockDigests?: BlockContentDigests;
|
|
430
|
+
/**
|
|
431
|
+
* {@link PendRequest.refuseSolo}, on the commit. A coordinator whose cohort for the commit is only
|
|
432
|
+
* itself refuses it on the same rule, before minting a proof or applying anything, with a
|
|
433
|
+
* conflict-shaped refusal (`SOLO_COMMIT_REFUSED_REASON` in db-p2p), since a commit cannot answer
|
|
434
|
+
* with a shortfall. That is reached when the pend ran on a real cohort and the partner dropped
|
|
435
|
+
* before the commit: the writer cancels and retries, and the retry's pend meets the pend-side
|
|
436
|
+
* refusal. Carried through every per-coordinator rebuild of the commit (`repoCommitRequest` in
|
|
437
|
+
* `NetworkTransactor`); omitted rather than `false` for the preimage reason
|
|
438
|
+
* {@link blockDigests} is.
|
|
439
|
+
*/
|
|
440
|
+
refuseSolo?: true;
|
|
295
441
|
};
|
|
296
442
|
/**
|
|
297
443
|
* Originates a compensating invalidation through the same critical-cluster consensus as any
|
|
@@ -526,6 +672,8 @@ export type PendValidationResult = {
|
|
|
526
672
|
valid: boolean;
|
|
527
673
|
/** Reason for validation failure (if valid=false) */
|
|
528
674
|
reason?: string;
|
|
675
|
+
/** Set only on a failure that judges the transaction itself wrong; see {@link ValidityRejection}. */
|
|
676
|
+
validity?: ValidityRejection;
|
|
529
677
|
};
|
|
530
678
|
/**
|
|
531
679
|
* Hook for validating transactions in PendRequests.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["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;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO;IAAE,QAAQ,CAAC,MAAM,EAAE,sBAAsB;gBAAzD,OAAO,EAAE,OAAO,EAAW,MAAM,EAAE,sBAAsB;CAI9E;AAED;;;;;;;GAOG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM;gBAA7C,OAAO,EAAE,OAAO,EAAW,UAAU,EAAE,MAAM;CAIlE;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,gCAAgC;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qGAAqG;IACrG,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAChC,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,MAAM,KAClB,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAGnC,2CAA2C;AAC3C,MAAM,MAAM,SAAS,GAAG,YAAY,CAAC;AACrC,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAC7C,8CAA8C;AAC9C,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;AAC3C,4CAA4C;AAC5C,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"struct.js","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"struct.js","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":"AA+qBA;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC1B;IAA2B;IAAhD,YAAqB,OAAgB,EAAW,MAA8B;QAC7E,KAAK,CAAC,SAAS,OAAO,oBAAoB,MAAM,mDAAmD,CAAC,CAAC;QADjF,YAAO,GAAP,OAAO,CAAS;QAAW,WAAM,GAAN,MAAM,CAAwB;QAE7E,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACrC,CAAC;CACD;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAC5B;IAA2B;IAAhD,YAAqB,OAAgB,EAAW,UAAkB;QACjE,KAAK,CAAC,SAAS,OAAO,4CAA4C,UAAU,wDAAwD,CAAC,CAAC;QADlH,YAAO,GAAP,OAAO,CAAS;QAAW,eAAU,GAAV,UAAU,CAAQ;QAEjE,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACvC,CAAC;CACD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ActionId } from "../collection/action.js";
|
|
2
|
+
import type { PendRequest } from "./struct.js";
|
|
3
|
+
/**
|
|
4
|
+
* The most bytes one transaction's pend may encode to: 7.5 MiB, measured by {@link jsonEncodedBytes}
|
|
5
|
+
* over the {@link PendRequest}s that travel together in one consensus record — transforms, validation
|
|
6
|
+
* payload and all. That is the sum of the batch when a transaction's collections travel together
|
|
7
|
+
* (`IRepo.pendMany`), and one collection's pend when they cannot and each is pended on its own.
|
|
8
|
+
*
|
|
9
|
+
* A pend's payload travels whole in one frame on every hop it takes: writer → coordinator on the repo
|
|
10
|
+
* protocol, then coordinator → each other cohort member on the cluster protocol, and back as the
|
|
11
|
+
* member's echoed answer. Both protocols decode under one frame cap (db-p2p's
|
|
12
|
+
* `MAX_BLOCK_MESSAGE_BYTES`), which is this limit plus a reserve for the envelope around the pend, so a
|
|
13
|
+
* transaction under this limit fits every frame it rides in. The limit is the same at every group
|
|
14
|
+
* size: a solo cohort takes no cluster hop, but is held to it all the same, so a write that commits
|
|
15
|
+
* on one machine does not start failing when a second joins.
|
|
16
|
+
*
|
|
17
|
+
* A writer with more to save than this splits it into several transactions.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MAX_TRANSACTION_BYTES: number;
|
|
20
|
+
/**
|
|
21
|
+
* The bytes `value` encodes to on the wire: the UTF-8 length of its `JSON.stringify`. JSON is the
|
|
22
|
+
* encoding every request and response frame of the repo and cluster protocols carries, so this is the
|
|
23
|
+
* measure a frame cap is judged by.
|
|
24
|
+
*/
|
|
25
|
+
export declare function jsonEncodedBytes(value: unknown): number;
|
|
26
|
+
/**
|
|
27
|
+
* A transaction too large to send: its pend encodes to more than {@link MAX_TRANSACTION_BYTES}.
|
|
28
|
+
* Raised before anything is sent, so nothing was reserved and nothing needs cancelling. Not a
|
|
29
|
+
* `StaleFailure` and never retried — the same transaction is the same size on every attempt. The
|
|
30
|
+
* writer has to split the change into smaller transactions.
|
|
31
|
+
*/
|
|
32
|
+
export declare class TransactionTooLargeError extends Error {
|
|
33
|
+
readonly actionId: ActionId;
|
|
34
|
+
/** What the transaction's pend encodes to, by {@link jsonEncodedBytes}. */
|
|
35
|
+
readonly bytes: number;
|
|
36
|
+
/** The limit it exceeded: {@link MAX_TRANSACTION_BYTES}. */
|
|
37
|
+
readonly limit: number;
|
|
38
|
+
constructor(actionId: ActionId,
|
|
39
|
+
/** What the transaction's pend encodes to, by {@link jsonEncodedBytes}. */
|
|
40
|
+
bytes: number,
|
|
41
|
+
/** The limit it exceeded: {@link MAX_TRANSACTION_BYTES}. */
|
|
42
|
+
limit?: number);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What `requests` — one transaction's pends that ride in one consensus record — encode to together,
|
|
46
|
+
* the measure {@link MAX_TRANSACTION_BYTES} is judged by.
|
|
47
|
+
*
|
|
48
|
+
* NOTE: encodes every request once more than sending it does, on the writer and again on the
|
|
49
|
+
* coordinator. Negligible for an ordinary write; if pend encoding ever shows in a profile of large
|
|
50
|
+
* writes, measure once on the writer and hand the size along instead.
|
|
51
|
+
*/
|
|
52
|
+
export declare function transactionBytes(requests: readonly PendRequest[]): number;
|
|
53
|
+
/**
|
|
54
|
+
* Throws {@link TransactionTooLargeError} when `requests` together encode to more than
|
|
55
|
+
* {@link MAX_TRANSACTION_BYTES} ({@link transactionBytes}). The one rule both the writer (before
|
|
56
|
+
* sending) and the coordinator (on receipt) apply.
|
|
57
|
+
*/
|
|
58
|
+
export declare function assertTransactionFits(requests: readonly PendRequest[]): void;
|
|
59
|
+
//# sourceMappingURL=transaction-size.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-size.d.ts","sourceRoot":"","sources":["../../../src/network/transaction-size.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB,QAAoB,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEvD;AAED;;;;;GAKG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IAEjD,QAAQ,CAAC,QAAQ,EAAE,QAAQ;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM;gBAJb,QAAQ,EAAE,QAAQ;IAC3B,2EAA2E;IAClE,KAAK,EAAE,MAAM;IACtB,4DAA4D;IACnD,KAAK,GAAE,MAA8B;CAK/C;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAIzE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,IAAI,CAI5E"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The most bytes one transaction's pend may encode to: 7.5 MiB, measured by {@link jsonEncodedBytes}
|
|
3
|
+
* over the {@link PendRequest}s that travel together in one consensus record — transforms, validation
|
|
4
|
+
* payload and all. That is the sum of the batch when a transaction's collections travel together
|
|
5
|
+
* (`IRepo.pendMany`), and one collection's pend when they cannot and each is pended on its own.
|
|
6
|
+
*
|
|
7
|
+
* A pend's payload travels whole in one frame on every hop it takes: writer → coordinator on the repo
|
|
8
|
+
* protocol, then coordinator → each other cohort member on the cluster protocol, and back as the
|
|
9
|
+
* member's echoed answer. Both protocols decode under one frame cap (db-p2p's
|
|
10
|
+
* `MAX_BLOCK_MESSAGE_BYTES`), which is this limit plus a reserve for the envelope around the pend, so a
|
|
11
|
+
* transaction under this limit fits every frame it rides in. The limit is the same at every group
|
|
12
|
+
* size: a solo cohort takes no cluster hop, but is held to it all the same, so a write that commits
|
|
13
|
+
* on one machine does not start failing when a second joins.
|
|
14
|
+
*
|
|
15
|
+
* A writer with more to save than this splits it into several transactions.
|
|
16
|
+
*/
|
|
17
|
+
export const MAX_TRANSACTION_BYTES = 7.5 * 1024 * 1024;
|
|
18
|
+
/**
|
|
19
|
+
* The bytes `value` encodes to on the wire: the UTF-8 length of its `JSON.stringify`. JSON is the
|
|
20
|
+
* encoding every request and response frame of the repo and cluster protocols carries, so this is the
|
|
21
|
+
* measure a frame cap is judged by.
|
|
22
|
+
*/
|
|
23
|
+
export function jsonEncodedBytes(value) {
|
|
24
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A transaction too large to send: its pend encodes to more than {@link MAX_TRANSACTION_BYTES}.
|
|
28
|
+
* Raised before anything is sent, so nothing was reserved and nothing needs cancelling. Not a
|
|
29
|
+
* `StaleFailure` and never retried — the same transaction is the same size on every attempt. The
|
|
30
|
+
* writer has to split the change into smaller transactions.
|
|
31
|
+
*/
|
|
32
|
+
export class TransactionTooLargeError extends Error {
|
|
33
|
+
actionId;
|
|
34
|
+
bytes;
|
|
35
|
+
limit;
|
|
36
|
+
constructor(actionId,
|
|
37
|
+
/** What the transaction's pend encodes to, by {@link jsonEncodedBytes}. */
|
|
38
|
+
bytes,
|
|
39
|
+
/** The limit it exceeded: {@link MAX_TRANSACTION_BYTES}. */
|
|
40
|
+
limit = MAX_TRANSACTION_BYTES) {
|
|
41
|
+
super(`transaction ${actionId} encodes to ${bytes} bytes, over the per-transaction limit MAX_TRANSACTION_BYTES (${limit} bytes); split it into smaller transactions`);
|
|
42
|
+
this.actionId = actionId;
|
|
43
|
+
this.bytes = bytes;
|
|
44
|
+
this.limit = limit;
|
|
45
|
+
this.name = 'TransactionTooLargeError';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* What `requests` — one transaction's pends that ride in one consensus record — encode to together,
|
|
50
|
+
* the measure {@link MAX_TRANSACTION_BYTES} is judged by.
|
|
51
|
+
*
|
|
52
|
+
* NOTE: encodes every request once more than sending it does, on the writer and again on the
|
|
53
|
+
* coordinator. Negligible for an ordinary write; if pend encoding ever shows in a profile of large
|
|
54
|
+
* writes, measure once on the writer and hand the size along instead.
|
|
55
|
+
*/
|
|
56
|
+
export function transactionBytes(requests) {
|
|
57
|
+
let bytes = 0;
|
|
58
|
+
for (const request of requests)
|
|
59
|
+
bytes += jsonEncodedBytes(request);
|
|
60
|
+
return bytes;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Throws {@link TransactionTooLargeError} when `requests` together encode to more than
|
|
64
|
+
* {@link MAX_TRANSACTION_BYTES} ({@link transactionBytes}). The one rule both the writer (before
|
|
65
|
+
* sending) and the coordinator (on receipt) apply.
|
|
66
|
+
*/
|
|
67
|
+
export function assertTransactionFits(requests) {
|
|
68
|
+
if (requests.length === 0)
|
|
69
|
+
return;
|
|
70
|
+
const bytes = transactionBytes(requests);
|
|
71
|
+
if (bytes > MAX_TRANSACTION_BYTES)
|
|
72
|
+
throw new TransactionTooLargeError(requests[0].actionId, bytes);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=transaction-size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-size.js","sourceRoot":"","sources":["../../../src/network/transaction-size.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC9C,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAExC;IAEA;IAEA;IALV,YACU,QAAkB;IAC3B,2EAA2E;IAClE,KAAa;IACtB,4DAA4D;IACnD,QAAgB,qBAAqB;QAE9C,KAAK,CAAC,eAAe,QAAQ,eAAe,KAAK,iEAAiE,KAAK,6CAA6C,CAAC,CAAC;QAN7J,aAAQ,GAAR,QAAQ,CAAU;QAElB,UAAK,GAAL,KAAK,CAAQ;QAEb,UAAK,GAAL,KAAK,CAAgC;QAG9C,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACxC,CAAC;CACD;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgC;IAChE,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,KAAK,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACnE,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgC;IACrE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAClC,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,KAAK,GAAG,qBAAqB;QAAE,MAAM,IAAI,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACrG,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RejectedFailure, TransactionInvalidity, ValidityRefusal } from "./struct.js";
|
|
2
|
+
/**
|
|
3
|
+
* A write the cohort refused because the members that sank it judged the transaction INVALID: it failed
|
|
4
|
+
* its re-execution, its operations hash, its stamp or its client signature (`ValidityRejection` in
|
|
5
|
+
* `transaction/transaction.ts` says which refusals qualify). Not retryable — re-sending the same
|
|
6
|
+
* content to the same checks is refused the same way. Nothing was saved: the members that approved
|
|
7
|
+
* release their reservation when the writer cancels.
|
|
8
|
+
*
|
|
9
|
+
* ONE class for every place it is raised, as `TransactionExpiredError` is. The coordinating repo (db-p2p
|
|
10
|
+
* `CoordinatorRepo`) returns its facts as a {@link RejectedFailure} ({@link toFailure}) when every reject
|
|
11
|
+
* that sank a pend was validity-marked or an expiry vote and its own storage confirms no revision loss,
|
|
12
|
+
* and a cohort of one's storage tier returns the same for its own check; each write path
|
|
13
|
+
* (`Collection.sync`, `TransactionCoordinator.commit`) raises it again from that refusal.
|
|
14
|
+
*
|
|
15
|
+
* Not the dispute answer. With disputes enabled, a marked rejection beside approvals is held for a ruling
|
|
16
|
+
* before it ends the pend, and that writer is answered with the dispute's own refusal (backlog
|
|
17
|
+
* `dispute-commit-path-block`, `dispute-writer-sees-disputed-pend`); this error stays the answer for a
|
|
18
|
+
* rejection no approval contests.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ValidityRejectedError extends Error {
|
|
21
|
+
/** Every validity refusal that sank the write. Never empty. */
|
|
22
|
+
readonly refusals: readonly ValidityRefusal[];
|
|
23
|
+
constructor(invalidity: TransactionInvalidity);
|
|
24
|
+
/** The refusal a coordinating repo returns for this error, so it crosses the repo protocol as an
|
|
25
|
+
* answer rather than as a reset stream. */
|
|
26
|
+
toFailure(): RejectedFailure;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=validity-rejected-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validity-rejected-error.d.ts","sourceRoot":"","sources":["../../../src/network/validity-rejected-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE3F;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC/C,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;gBAElC,UAAU,EAAE,qBAAqB;IAU7C;gDAC4C;IAC5C,SAAS,IAAI,eAAe;CAQ5B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A write the cohort refused because the members that sank it judged the transaction INVALID: it failed
|
|
3
|
+
* its re-execution, its operations hash, its stamp or its client signature (`ValidityRejection` in
|
|
4
|
+
* `transaction/transaction.ts` says which refusals qualify). Not retryable — re-sending the same
|
|
5
|
+
* content to the same checks is refused the same way. Nothing was saved: the members that approved
|
|
6
|
+
* release their reservation when the writer cancels.
|
|
7
|
+
*
|
|
8
|
+
* ONE class for every place it is raised, as `TransactionExpiredError` is. The coordinating repo (db-p2p
|
|
9
|
+
* `CoordinatorRepo`) returns its facts as a {@link RejectedFailure} ({@link toFailure}) when every reject
|
|
10
|
+
* that sank a pend was validity-marked or an expiry vote and its own storage confirms no revision loss,
|
|
11
|
+
* and a cohort of one's storage tier returns the same for its own check; each write path
|
|
12
|
+
* (`Collection.sync`, `TransactionCoordinator.commit`) raises it again from that refusal.
|
|
13
|
+
*
|
|
14
|
+
* Not the dispute answer. With disputes enabled, a marked rejection beside approvals is held for a ruling
|
|
15
|
+
* before it ends the pend, and that writer is answered with the dispute's own refusal (backlog
|
|
16
|
+
* `dispute-commit-path-block`, `dispute-writer-sees-disputed-pend`); this error stays the answer for a
|
|
17
|
+
* rejection no approval contests.
|
|
18
|
+
*/
|
|
19
|
+
export class ValidityRejectedError extends Error {
|
|
20
|
+
/** Every validity refusal that sank the write. Never empty. */
|
|
21
|
+
refusals;
|
|
22
|
+
constructor(invalidity) {
|
|
23
|
+
// NOTE: `invalidity` off the wire is trusted as shaped (`isRejectedFailure` checks only presence),
|
|
24
|
+
// so a malformed coordinator answer throws a TypeError here (no `refusals` array) instead of this
|
|
25
|
+
// error. Either still ends the write; if hostile coordinators become a concern, validate the shape
|
|
26
|
+
// where the refusal is received, as for `TransactionExpiredError`.
|
|
27
|
+
super(validityRejectedMessage(invalidity.refusals));
|
|
28
|
+
this.name = 'ValidityRejectedError';
|
|
29
|
+
this.refusals = invalidity.refusals.map(refusal => ({ ...refusal }));
|
|
30
|
+
}
|
|
31
|
+
/** The refusal a coordinating repo returns for this error, so it crosses the repo protocol as an
|
|
32
|
+
* answer rather than as a reset stream. */
|
|
33
|
+
toFailure() {
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
conflict: false,
|
|
37
|
+
reason: this.message,
|
|
38
|
+
rejected: { refusals: this.refusals.map(refusal => ({ ...refusal })) },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Written to be shown to a person. Names each refuser — the member's peer id, or the coordinating
|
|
43
|
+
* node's own check where no vote was cast — with the reason it gave. */
|
|
44
|
+
function validityRejectedMessage(refusals) {
|
|
45
|
+
const details = refusals
|
|
46
|
+
.map(refusal => `${refusal.peerId ?? 'coordinating node'}: ${refusal.reason ?? 'no reason given'}`)
|
|
47
|
+
.join('; ');
|
|
48
|
+
return `The transaction was rejected as invalid by ${refusals.length} validator(s) (${details}). `
|
|
49
|
+
+ `This is a verdict on the transaction itself, not a conflict or an unreachable cohort, and sending it again is refused the same way.`;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=validity-rejected-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validity-rejected-error.js","sourceRoot":"","sources":["../../../src/network/validity-rejected-error.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC/C,+DAA+D;IACtD,QAAQ,CAA6B;IAE9C,YAAY,UAAiC;QAC5C,mGAAmG;QACnG,kGAAkG;QAClG,mGAAmG;QACnG,mEAAmE;QACnE,KAAK,CAAC,uBAAuB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;IAED;gDAC4C;IAC5C,SAAS;QACR,OAAO;YACN,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,EAAE;SACtE,CAAC;IACH,CAAC;CACD;AAED;yEACyE;AACzE,SAAS,uBAAuB,CAAC,QAAoC;IACpE,MAAM,OAAO,GAAG,QAAQ;SACtB,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,mBAAmB,KAAK,OAAO,CAAC,MAAM,IAAI,iBAAiB,EAAE,CAAC;SAClG,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,OAAO,8CAA8C,QAAQ,CAAC,MAAM,kBAAkB,OAAO,KAAK;UAC/F,qIAAqI,CAAC;AAC1I,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ActionId, AlreadyAppliedTally } from '../collection/action.js';
|
|
2
|
+
import type { Collection } from '../collection/collection.js';
|
|
3
|
+
import type { EntryId } from '../collection/segments.js';
|
|
4
|
+
import type { CollectionId, InFlightAttempt } from '../collection/struct.js';
|
|
5
|
+
import type { WriteDurability } from '../network/struct.js';
|
|
6
|
+
import type { CommittedEffect, EntryStatus, EntryWaitingFor, QueuedEntry } from './status.js';
|
|
7
|
+
import type { JournalDriveState } from './journal.js';
|
|
8
|
+
/** One queued entry, as `OfflineQueue` holds it, and the projections of it the queue reports. */
|
|
9
|
+
export type Entry = {
|
|
10
|
+
readonly id: EntryId;
|
|
11
|
+
readonly seq: number;
|
|
12
|
+
readonly queuedAt: number;
|
|
13
|
+
readonly expiresAt: number | undefined;
|
|
14
|
+
/** The collections the entry sealed a segment in — the ones `sealPending` answered `true` for. */
|
|
15
|
+
readonly collections: readonly Collection<any>[];
|
|
16
|
+
/** One action id for the entry's whole life, with one exception: a `torn-not-saved` outcome mints
|
|
17
|
+
* a fresh one (the queue's `applyFailure` says why). */
|
|
18
|
+
actionId: ActionId;
|
|
19
|
+
attempts: number;
|
|
20
|
+
/** Whether an attempt may have landed; sticky — see the NOTE at the queue's `recordAttempts`. */
|
|
21
|
+
inDoubt: boolean;
|
|
22
|
+
/** The attempts recorded under `actionId` and not yet resolved, per collection, handed back as
|
|
23
|
+
* `resume` when the entry is re-driven. Cleared with the action id. */
|
|
24
|
+
readonly retained: Map<CollectionId, InFlightAttempt>;
|
|
25
|
+
/** The collections a partial commit has already committed, with who holds each, accumulated
|
|
26
|
+
* across submissions (`recordCollectionDurability`); empty until one does. The committed half's
|
|
27
|
+
* segments are consumed, so the next submission drives only the rest, and the terminal status
|
|
28
|
+
* reports these beside it. */
|
|
29
|
+
readonly committed: Map<CollectionId, WriteDurability | undefined>;
|
|
30
|
+
/** What each collection's head segment accepted as already applied when it was committed, as the
|
|
31
|
+
* `onCommittedHead` hooks reported it — across submissions, so a partial commit's committed half is
|
|
32
|
+
* recorded before the error reaches the queue and a later submission's tallies accumulate beside
|
|
33
|
+
* it. A collection a restore found already committed records nothing. Folded into the `committed`
|
|
34
|
+
* status's `effect` ({@link effectOf}, which answers `applied` while any collection the entry wrote
|
|
35
|
+
* has no tally here). In memory only: a restart between a partial commit and the remainder's commit
|
|
36
|
+
* loses the committed half's tally, and the entry then reports `applied`, the conservative answer,
|
|
37
|
+
* whatever the remainder reports. */
|
|
38
|
+
readonly applied: Map<CollectionId, AlreadyAppliedTally>;
|
|
39
|
+
phase: 'queued' | 'submitting';
|
|
40
|
+
waitingFor: EntryWaitingFor | undefined;
|
|
41
|
+
lastError: unknown;
|
|
42
|
+
/** The last `queued` status emitted, so a re-check that changes nothing emits nothing. */
|
|
43
|
+
lastQueued: QueuedStatus | undefined;
|
|
44
|
+
/** The `offline:expiry-deferred` line is logged once per entry, not once per re-check. */
|
|
45
|
+
expiryDeferredLogged: boolean;
|
|
46
|
+
};
|
|
47
|
+
export type QueuedStatus = Extract<EntryStatus, {
|
|
48
|
+
kind: 'queued';
|
|
49
|
+
}>;
|
|
50
|
+
export declare function queuedStatus(entry: Entry): QueuedStatus;
|
|
51
|
+
/** `{ committedCollections }` once part of the entry has committed, `{}` before — the field the
|
|
52
|
+
* `queued` and `failed` statuses and {@link snapshot} carry only when it says something. */
|
|
53
|
+
export declare function committedField(entry: Entry): {
|
|
54
|
+
committedCollections?: readonly CollectionId[];
|
|
55
|
+
};
|
|
56
|
+
export declare function currentStatus(entry: Entry): EntryStatus;
|
|
57
|
+
/** The entry as `OfflineQueue.entries` lists it. */
|
|
58
|
+
export declare function snapshot(entry: Entry): QueuedEntry;
|
|
59
|
+
/** Whether two `queued` statuses differ in anything an application can see. */
|
|
60
|
+
export declare function queuedStatusChanged(previous: QueuedStatus | undefined, status: QueuedStatus): boolean;
|
|
61
|
+
/** The `effect` of a committed entry ({@link CommittedEffect}): `already-applied` exactly when EVERY
|
|
62
|
+
* collection the entry wrote reported a tally and the tallies sum to `alreadyApplied > 0` and
|
|
63
|
+
* `applied === 0`. A collection whose tally was never heard — one committed before a restart, or one
|
|
64
|
+
* a restore found already committed — may have changed rows, so its absence answers `applied`: a
|
|
65
|
+
* remainder that was wholly already applied must not speak for a half that was not. */
|
|
66
|
+
export declare function effectOf(entry: Entry): CommittedEffect;
|
|
67
|
+
/** The entry's drive state as the journal records it (`IOfflineJournal.driving`): its action id,
|
|
68
|
+
* the attempts retained under it — with `attempts`, the ones about to be sent, laid over them when
|
|
69
|
+
* given — and the collections already committed. Copies, so the journal serialises a state the
|
|
70
|
+
* drain cannot change under it. */
|
|
71
|
+
export declare function driveState(entry: Entry, attempts?: ReadonlyMap<CollectionId, InFlightAttempt>): JournalDriveState;
|
|
72
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../../src/offline/entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,iGAAiG;AACjG,MAAM,MAAM,KAAK,GAAG;IACnB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,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