@optimystic/db-p2p 0.24.1 → 0.25.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 → README.md} +688 -668
- package/dist/src/cluster/block-transfer-service.d.ts +133 -10
- package/dist/src/cluster/block-transfer-service.d.ts.map +1 -1
- package/dist/src/cluster/block-transfer-service.js +155 -9
- package/dist/src/cluster/block-transfer-service.js.map +1 -1
- package/dist/src/cluster/block-transfer.d.ts +67 -7
- package/dist/src/cluster/block-transfer.d.ts.map +1 -1
- package/dist/src/cluster/block-transfer.js +127 -24
- package/dist/src/cluster/block-transfer.js.map +1 -1
- package/dist/src/cluster/certified-claims.d.ts +170 -0
- package/dist/src/cluster/certified-claims.d.ts.map +1 -0
- package/dist/src/cluster/certified-claims.js +200 -0
- package/dist/src/cluster/certified-claims.js.map +1 -0
- package/dist/src/cluster/client-signature-verifier.d.ts +23 -0
- package/dist/src/cluster/client-signature-verifier.d.ts.map +1 -0
- package/dist/src/cluster/client-signature-verifier.js +33 -0
- package/dist/src/cluster/client-signature-verifier.js.map +1 -0
- package/dist/src/cluster/cluster-policy.d.ts +9 -3
- package/dist/src/cluster/cluster-policy.d.ts.map +1 -1
- package/dist/src/cluster/cluster-policy.js +111 -27
- package/dist/src/cluster/cluster-policy.js.map +1 -1
- package/dist/src/cluster/cluster-repo.d.ts +140 -11
- package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
- package/dist/src/cluster/cluster-repo.js +485 -29
- package/dist/src/cluster/cluster-repo.js.map +1 -1
- package/dist/src/cluster/commit-proof.d.ts +134 -0
- package/dist/src/cluster/commit-proof.d.ts.map +1 -0
- package/dist/src/cluster/commit-proof.js +263 -0
- package/dist/src/cluster/commit-proof.js.map +1 -0
- package/dist/src/cluster/quorum-restore.d.ts +95 -8
- package/dist/src/cluster/quorum-restore.d.ts.map +1 -1
- package/dist/src/cluster/quorum-restore.js +113 -14
- package/dist/src/cluster/quorum-restore.js.map +1 -1
- package/dist/src/cluster/rebalance-monitor.d.ts +84 -0
- package/dist/src/cluster/rebalance-monitor.d.ts.map +1 -1
- package/dist/src/cluster/rebalance-monitor.js +207 -5
- package/dist/src/cluster/rebalance-monitor.js.map +1 -1
- package/dist/src/cluster/reconcile-block.d.ts +27 -7
- package/dist/src/cluster/reconcile-block.d.ts.map +1 -1
- package/dist/src/cluster/reconcile-block.js +179 -38
- package/dist/src/cluster/reconcile-block.js.map +1 -1
- package/dist/src/cluster/service.d.ts +21 -4
- package/dist/src/cluster/service.d.ts.map +1 -1
- package/dist/src/cluster/service.js +28 -17
- package/dist/src/cluster/service.js.map +1 -1
- package/dist/src/cluster/spread-on-churn.d.ts +8 -2
- package/dist/src/cluster/spread-on-churn.d.ts.map +1 -1
- package/dist/src/cluster/spread-on-churn.js +7 -7
- package/dist/src/cluster/spread-on-churn.js.map +1 -1
- package/dist/src/cohort-topic/host.d.ts.map +1 -1
- package/dist/src/cohort-topic/host.js +8 -7
- package/dist/src/cohort-topic/host.js.map +1 -1
- package/dist/src/cohort-topic/stream-util.d.ts +7 -6
- package/dist/src/cohort-topic/stream-util.d.ts.map +1 -1
- package/dist/src/cohort-topic/stream-util.js +14 -41
- package/dist/src/cohort-topic/stream-util.js.map +1 -1
- package/dist/src/dispute/cascade.d.ts +7 -8
- package/dist/src/dispute/cascade.d.ts.map +1 -1
- package/dist/src/dispute/cascade.js +24 -7
- package/dist/src/dispute/cascade.js.map +1 -1
- package/dist/src/dispute/dispute-service.d.ts +5 -0
- package/dist/src/dispute/dispute-service.d.ts.map +1 -1
- package/dist/src/dispute/dispute-service.js +13 -3
- package/dist/src/dispute/dispute-service.js.map +1 -1
- package/dist/src/dispute/invalidation.d.ts +33 -15
- package/dist/src/dispute/invalidation.d.ts.map +1 -1
- package/dist/src/dispute/invalidation.js +127 -34
- package/dist/src/dispute/invalidation.js.map +1 -1
- package/dist/src/dispute/service.d.ts.map +1 -1
- package/dist/src/dispute/service.js +2 -1
- package/dist/src/dispute/service.js.map +1 -1
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/libp2p-key-network.d.ts +78 -6
- package/dist/src/libp2p-key-network.d.ts.map +1 -1
- package/dist/src/libp2p-key-network.js +136 -57
- package/dist/src/libp2p-key-network.js.map +1 -1
- package/dist/src/libp2p-node-base.d.ts +38 -7
- package/dist/src/libp2p-node-base.d.ts.map +1 -1
- package/dist/src/libp2p-node-base.js +150 -62
- package/dist/src/libp2p-node-base.js.map +1 -1
- package/dist/src/logger.d.ts +2 -2
- package/dist/src/logger.js +2 -2
- package/dist/src/network/open-protocol-stream.d.ts +56 -0
- package/dist/src/network/open-protocol-stream.d.ts.map +1 -0
- package/dist/src/network/open-protocol-stream.js +60 -0
- package/dist/src/network/open-protocol-stream.js.map +1 -0
- package/dist/src/network/register-protocol-handler.d.ts +66 -0
- package/dist/src/network/register-protocol-handler.d.ts.map +1 -0
- package/dist/src/network/register-protocol-handler.js +51 -0
- package/dist/src/network/register-protocol-handler.js.map +1 -0
- package/dist/src/peer-address-book.d.ts +128 -1
- package/dist/src/peer-address-book.d.ts.map +1 -1
- package/dist/src/peer-address-book.js +198 -15
- package/dist/src/peer-address-book.js.map +1 -1
- package/dist/src/pend-validation.d.ts +65 -0
- package/dist/src/pend-validation.d.ts.map +1 -0
- package/dist/src/pend-validation.js +69 -0
- package/dist/src/pend-validation.js.map +1 -0
- package/dist/src/reactivity/notify-transport.d.ts.map +1 -1
- package/dist/src/reactivity/notify-transport.js +2 -1
- package/dist/src/reactivity/notify-transport.js.map +1 -1
- package/dist/src/reactivity/push-state-gossip.d.ts.map +1 -1
- package/dist/src/reactivity/push-state-gossip.js +2 -1
- package/dist/src/reactivity/push-state-gossip.js.map +1 -1
- package/dist/src/repo/cluster-coordinator.d.ts +32 -6
- package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
- package/dist/src/repo/cluster-coordinator.js +44 -10
- package/dist/src/repo/cluster-coordinator.js.map +1 -1
- package/dist/src/repo/coordinator-repo.d.ts +181 -25
- package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
- package/dist/src/repo/coordinator-repo.js +650 -62
- package/dist/src/repo/coordinator-repo.js.map +1 -1
- package/dist/src/repo/served-repo-proxy.d.ts +30 -0
- package/dist/src/repo/served-repo-proxy.d.ts.map +1 -0
- package/dist/src/repo/served-repo-proxy.js +50 -0
- package/dist/src/repo/served-repo-proxy.js.map +1 -0
- package/dist/src/repo/service.d.ts +22 -1
- package/dist/src/repo/service.d.ts.map +1 -1
- package/dist/src/repo/service.js +25 -13
- package/dist/src/repo/service.js.map +1 -1
- package/dist/src/reputation/types.d.ts +3 -1
- package/dist/src/reputation/types.d.ts.map +1 -1
- package/dist/src/reputation/types.js +3 -1
- package/dist/src/reputation/types.js.map +1 -1
- package/dist/src/rn.d.ts +24 -2
- package/dist/src/rn.d.ts.map +1 -1
- package/dist/src/rn.js +33 -4
- package/dist/src/rn.js.map +1 -1
- package/dist/src/routing/libp2p-known-peers.d.ts.map +1 -1
- package/dist/src/routing/libp2p-known-peers.js +5 -0
- package/dist/src/routing/libp2p-known-peers.js.map +1 -1
- package/dist/src/storage/block-archive.d.ts +153 -0
- package/dist/src/storage/block-archive.d.ts.map +1 -0
- package/dist/src/storage/block-archive.js +194 -0
- package/dist/src/storage/block-archive.js.map +1 -0
- package/dist/src/storage/block-latch.d.ts +92 -0
- package/dist/src/storage/block-latch.d.ts.map +1 -0
- package/dist/src/storage/block-latch.js +132 -0
- package/dist/src/storage/block-latch.js.map +1 -0
- package/dist/src/storage/block-storage.d.ts +169 -12
- package/dist/src/storage/block-storage.d.ts.map +1 -1
- package/dist/src/storage/block-storage.js +415 -152
- package/dist/src/storage/block-storage.js.map +1 -1
- package/dist/src/storage/cached-raw-storage.d.ts +5 -1
- package/dist/src/storage/cached-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/cached-raw-storage.js +16 -1
- package/dist/src/storage/cached-raw-storage.js.map +1 -1
- package/dist/src/storage/cached-store-driver.d.ts +14 -4
- package/dist/src/storage/cached-store-driver.d.ts.map +1 -1
- package/dist/src/storage/cached-store-driver.js +39 -5
- package/dist/src/storage/cached-store-driver.js.map +1 -1
- package/dist/src/storage/i-block-storage.d.ts +70 -19
- package/dist/src/storage/i-block-storage.d.ts.map +1 -1
- package/dist/src/storage/i-block-storage.js +21 -1
- package/dist/src/storage/i-block-storage.js.map +1 -1
- package/dist/src/storage/i-raw-storage.d.ts +38 -0
- package/dist/src/storage/i-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/kv-raw-storage.d.ts +14 -8
- package/dist/src/storage/kv-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/kv-raw-storage.js +29 -9
- package/dist/src/storage/kv-raw-storage.js.map +1 -1
- package/dist/src/storage/memory-store-driver.d.ts +4 -1
- package/dist/src/storage/memory-store-driver.d.ts.map +1 -1
- package/dist/src/storage/memory-store-driver.js +22 -2
- package/dist/src/storage/memory-store-driver.js.map +1 -1
- package/dist/src/storage/raw-store-codec.js +2 -2
- package/dist/src/storage/raw-store-driver.d.ts +44 -3
- package/dist/src/storage/raw-store-driver.d.ts.map +1 -1
- package/dist/src/storage/shared-cache-pool.d.ts +60 -3
- package/dist/src/storage/shared-cache-pool.d.ts.map +1 -1
- package/dist/src/storage/shared-cache-pool.js +68 -4
- package/dist/src/storage/shared-cache-pool.js.map +1 -1
- package/dist/src/storage/storage-repo.d.ts +204 -26
- package/dist/src/storage/storage-repo.d.ts.map +1 -1
- package/dist/src/storage/storage-repo.js +422 -119
- package/dist/src/storage/storage-repo.js.map +1 -1
- package/dist/src/storage/store-identity.d.ts +21 -0
- package/dist/src/storage/store-identity.d.ts.map +1 -0
- package/dist/src/storage/store-identity.js +33 -0
- package/dist/src/storage/store-identity.js.map +1 -0
- package/dist/src/storage/struct.d.ts +15 -0
- package/dist/src/storage/struct.d.ts.map +1 -1
- package/dist/src/storage/with-read-cache.d.ts +92 -0
- package/dist/src/storage/with-read-cache.d.ts.map +1 -0
- package/dist/src/storage/with-read-cache.js +132 -0
- package/dist/src/storage/with-read-cache.js.map +1 -0
- package/dist/src/sync/service.d.ts +13 -3
- package/dist/src/sync/service.d.ts.map +1 -1
- package/dist/src/sync/service.js +7 -30
- package/dist/src/sync/service.js.map +1 -1
- package/dist/src/testing/mesh-harness.d.ts +75 -2
- package/dist/src/testing/mesh-harness.d.ts.map +1 -1
- package/dist/src/testing/mesh-harness.js +193 -81
- package/dist/src/testing/mesh-harness.js.map +1 -1
- package/dist/src/testing/raw-storage-conformance.d.ts +8 -0
- package/dist/src/testing/raw-storage-conformance.d.ts.map +1 -1
- package/dist/src/testing/raw-storage-conformance.js +97 -2
- package/dist/src/testing/raw-storage-conformance.js.map +1 -1
- package/package.json +5 -6
- package/src/cluster/block-transfer-service.ts +528 -312
- package/src/cluster/block-transfer.ts +547 -424
- package/src/cluster/certified-claims.ts +319 -0
- package/src/cluster/client-signature-verifier.ts +34 -0
- package/src/cluster/cluster-policy.ts +294 -203
- package/src/cluster/cluster-repo.ts +2501 -2034
- package/src/cluster/commit-proof.ts +344 -0
- package/src/cluster/quorum-restore.ts +348 -223
- package/src/cluster/rebalance-monitor.ts +539 -254
- package/src/cluster/reconcile-block.ts +404 -203
- package/src/cluster/service.ts +308 -293
- package/src/cluster/spread-on-churn.ts +352 -346
- package/src/cohort-topic/host.ts +8 -7
- package/src/cohort-topic/stream-util.ts +14 -43
- package/src/dispute/cascade.ts +31 -15
- package/src/dispute/dispute-service.ts +706 -696
- package/src/dispute/invalidation.ts +162 -52
- package/src/dispute/service.ts +126 -125
- package/src/index.ts +7 -0
- package/src/libp2p-key-network.ts +142 -58
- package/src/libp2p-node-base.ts +1793 -1675
- package/src/logger.ts +27 -27
- package/src/network/open-protocol-stream.ts +87 -0
- package/src/network/register-protocol-handler.ts +85 -0
- package/src/peer-address-book.ts +360 -149
- package/src/pend-validation.ts +89 -0
- package/src/reactivity/notify-transport.ts +145 -144
- package/src/reactivity/push-state-gossip.ts +292 -291
- package/src/repo/cluster-coordinator.ts +65 -11
- package/src/repo/coordinator-repo.ts +729 -71
- package/src/repo/served-repo-proxy.ts +55 -0
- package/src/repo/service.ts +332 -313
- package/src/reputation/types.ts +3 -1
- package/src/rn.ts +34 -4
- package/src/routing/libp2p-known-peers.ts +31 -26
- package/src/storage/block-archive.ts +242 -0
- package/src/storage/block-latch.ts +144 -0
- package/src/storage/block-storage.ts +787 -498
- package/src/storage/cached-raw-storage.ts +21 -1
- package/src/storage/cached-store-driver.ts +898 -859
- package/src/storage/i-block-storage.ts +172 -116
- package/src/storage/i-raw-storage.ts +40 -0
- package/src/storage/kv-raw-storage.ts +34 -9
- package/src/storage/memory-store-driver.ts +26 -2
- package/src/storage/raw-store-codec.ts +42 -42
- package/src/storage/raw-store-driver.ts +45 -3
- package/src/storage/shared-cache-pool.ts +516 -452
- package/src/storage/storage-repo.ts +1421 -1014
- package/src/storage/store-identity.ts +41 -0
- package/src/storage/struct.ts +52 -34
- package/src/storage/with-read-cache.ts +182 -0
- package/src/sync/service.ts +178 -198
- package/src/testing/cohort-topic-mesh-harness.ts +673 -673
- package/src/testing/mesh-harness.ts +524 -344
- package/src/testing/raw-storage-conformance.ts +114 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { peerIdFromString } from "@libp2p/peer-id";
|
|
2
|
-
import type { ClusterRecord, IKeyNetwork, RepoMessage, BlockId, ClusterPeers, MessageOptions, ClusterConsensusConfig, ICluster } from "@optimystic/db-core";
|
|
2
|
+
import type { ClusterRecord, IKeyNetwork, RepoMessage, BlockId, ClusterPeers, MessageOptions, ClusterConsensusConfig, ICluster, PendResult, CommitResult } from "@optimystic/db-core";
|
|
3
3
|
import { CURRENT_MEMBERSHIP_VERSION, computeClusterMessageHash, membershipDigest } from "@optimystic/db-core";
|
|
4
4
|
import { Pending } from "@optimystic/db-core";
|
|
5
5
|
import type { PeerId } from "@libp2p/interface";
|
|
@@ -37,10 +37,17 @@ export class ValidatorRejectionError extends Error {
|
|
|
37
37
|
* vote (they hold a rival transaction that won the deterministic race on the same blocks) and
|
|
38
38
|
* approvals fell short of super-majority. Distinct from {@link ValidatorRejectionError} — nobody
|
|
39
39
|
* judged this write invalid; it lost an optimistic-concurrency race and a fresh retry can win.
|
|
40
|
-
* `CoordinatorRepo.pend`
|
|
41
|
-
* retry machinery (`isConflictFailure`) absorbs it; it should escape
|
|
42
|
-
*
|
|
43
|
-
*
|
|
40
|
+
* `CoordinatorRepo.pend` AND `CoordinatorRepo.commit` both convert this into a `StaleFailure` with
|
|
41
|
+
* `conflict: true` so the normal retry machinery (`isConflictFailure`) absorbs it; it should escape
|
|
42
|
+
* as a thrown error only from other paths. The commit conversion matters as much as the pend one:
|
|
43
|
+
* at the moment this is thrown zero members approved and the members hold the winner — nothing of
|
|
44
|
+
* the loser landed — yet a THROWN commit error is retried verbatim by db-core's `commitCollection`
|
|
45
|
+
* (it treats throws as transport faults), and that re-driven commit races into the window after
|
|
46
|
+
* members apply the winner and clear its reservation, where it can assemble a consensus no member
|
|
47
|
+
* will durably store. A returned conflict is instead surfaced immediately as a stale loss, and the
|
|
48
|
+
* writer re-reads and re-drives the whole pend+commit at a fresh revision. The conflicting peers
|
|
49
|
+
* and the winning hashes ride as structured data (from the signed `conflictWith` fields), never
|
|
50
|
+
* parsed out of prose.
|
|
44
51
|
*/
|
|
45
52
|
export class ConflictRaceLostError extends Error {
|
|
46
53
|
constructor(
|
|
@@ -123,6 +130,10 @@ export class ClusterCoordinator {
|
|
|
123
130
|
update: (record: ClusterRecord) => Promise<ClusterRecord>;
|
|
124
131
|
peerId: PeerId;
|
|
125
132
|
wasTransactionExecuted?: (messageHash: string) => boolean;
|
|
133
|
+
/** Local storage's verdict for a pend applied during consensus; see ClusterMember.getExecutedPendResult. */
|
|
134
|
+
getExecutedPendResult?: (messageHash: string) => PendResult | undefined;
|
|
135
|
+
/** Local storage's verdict for a commit applied during consensus; see ClusterMember.getExecutedCommitResult. */
|
|
136
|
+
getExecutedCommitResult?: (messageHash: string) => CommitResult | undefined;
|
|
126
137
|
},
|
|
127
138
|
private readonly fretService?: FretService,
|
|
128
139
|
private readonly reputation?: IPeerReputation,
|
|
@@ -183,7 +194,7 @@ export class ClusterCoordinator {
|
|
|
183
194
|
* reproduces the legacy v1 hash byte-for-byte.
|
|
184
195
|
*
|
|
185
196
|
* NOTE: the whole `message` is hashed (canonicalJson), so a transaction's advisory aged priority —
|
|
186
|
-
* which rides inside the pend operation as `pend.transaction.priority` (multi-collection) or
|
|
197
|
+
* which rides inside the pend operation as `pend.validation.transaction.priority` (multi-collection) or
|
|
187
198
|
* `pend.priority` (single-collection) — is automatically covered here and by the derived
|
|
188
199
|
* promise/commit hashes. That is what makes priority integrity-protected in transit: a relaying peer
|
|
189
200
|
* cannot strip or inflate it without invalidating the message hash the members verify. No separate
|
|
@@ -219,7 +230,6 @@ export class ClusterCoordinator {
|
|
|
219
230
|
membershipVersion: CURRENT_MEMBERSHIP_VERSION,
|
|
220
231
|
membershipDigest: membershipDigestValue,
|
|
221
232
|
message,
|
|
222
|
-
coordinatingBlockIds: message.coordinatingBlockIds,
|
|
223
233
|
promises: {},
|
|
224
234
|
commits: {},
|
|
225
235
|
suggestedClusterSize: peerCount || undefined,
|
|
@@ -249,7 +259,41 @@ export class ClusterCoordinator {
|
|
|
249
259
|
async executeClusterTransaction(blockId: BlockId, message: RepoMessage, _options?: MessageOptions): Promise<{
|
|
250
260
|
record: ClusterRecord;
|
|
251
261
|
localExecuted: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Local storage's verdict for a pend operation this node's own cluster member applied during
|
|
264
|
+
* consensus, when the member retained one. Meaningful only when `localExecuted` is true;
|
|
265
|
+
* absent for non-pend messages, for a member that predates the retention, or after the
|
|
266
|
+
* retention TTL. `CoordinatorRepo.pend` returns this instead of fabricating a success.
|
|
267
|
+
*/
|
|
268
|
+
localPendResult?: PendResult;
|
|
269
|
+
/**
|
|
270
|
+
* Local storage's verdict for a commit operation this node's own cluster member applied
|
|
271
|
+
* during consensus, when the member retained one. Same availability contract as
|
|
272
|
+
* `localPendResult`. `CoordinatorRepo.commit` uses a retained refusal to detect a rival's
|
|
273
|
+
* win swallowed by the member-side ahead-divergence tolerance, instead of fabricating a
|
|
274
|
+
* success no member durably stored.
|
|
275
|
+
*/
|
|
276
|
+
localCommitResult?: CommitResult;
|
|
252
277
|
}> {
|
|
278
|
+
// The coordinating block id is derived HERE, from the key this method is already handed, rather
|
|
279
|
+
// than being set by each caller's message builder: a member's membership admission gate derives
|
|
280
|
+
// its own cohort view from this field, and a builder that forgets it silently downgrades the gate
|
|
281
|
+
// to its fallback floor on that path (which is how `commit` and `cancel` used to strand writes —
|
|
282
|
+
// admitted at pend, refused at commit). Doing it at the single choke point means a future message
|
|
283
|
+
// builder cannot reintroduce the gap.
|
|
284
|
+
//
|
|
285
|
+
// Two constraints this shape exists to satisfy:
|
|
286
|
+
// - COPY, never mutate: `CoordinatorRepo.cancel` builds ONE message and hands the same object to
|
|
287
|
+
// N concurrent calls, one per block. In-place mutation would leak one block's id into another
|
|
288
|
+
// block's transaction.
|
|
289
|
+
// - Preserve an already-present list: `pend` deliberately declares the whole consolidated batch,
|
|
290
|
+
// not just its first block, so this must not overwrite it. Tested on `length`, not on the
|
|
291
|
+
// field: an empty list carries no id for a member to derive from, so preserving one would be
|
|
292
|
+
// the same silent downgrade to the fallback floor this choke point exists to prevent.
|
|
293
|
+
const coordinated: RepoMessage = message.coordinatingBlockIds?.length
|
|
294
|
+
? message
|
|
295
|
+
: { ...message, coordinatingBlockIds: [blockId] };
|
|
296
|
+
|
|
253
297
|
// Get the cluster peers for this block
|
|
254
298
|
const peers = await this.getClusterForBlock(blockId);
|
|
255
299
|
|
|
@@ -258,11 +302,14 @@ export class ClusterCoordinator {
|
|
|
258
302
|
// than one hash with a silent internal disagreement about who is responsible.
|
|
259
303
|
const membershipDigestValue = await membershipDigest(peers);
|
|
260
304
|
|
|
261
|
-
// Create a unique hash for this transaction (over message + membership digest)
|
|
262
|
-
|
|
305
|
+
// Create a unique hash for this transaction (over message + membership digest). Hashing the
|
|
306
|
+
// coordinating-block-bearing copy is what makes the field tamper-evident in transit — and it also
|
|
307
|
+
// makes a multi-block `cancel` produce a distinct hash per block, where before two blocks with
|
|
308
|
+
// identical cohorts collided on one `messageHash` in `this.transactions` / `wasTransactionExecuted`.
|
|
309
|
+
const messageHash = await this.createMessageHash(coordinated, membershipDigestValue);
|
|
263
310
|
|
|
264
311
|
// Create a cluster record for this transaction
|
|
265
|
-
const record = this.makeRecord(peers, messageHash,
|
|
312
|
+
const record = this.makeRecord(peers, messageHash, coordinated, membershipDigestValue);
|
|
266
313
|
log('cluster-tx:start', {
|
|
267
314
|
messageHash,
|
|
268
315
|
blockId,
|
|
@@ -296,7 +343,14 @@ export class ClusterCoordinator {
|
|
|
296
343
|
const result = await pending.result();
|
|
297
344
|
// Check if the local cluster already executed the operations during consensus
|
|
298
345
|
const localExecuted = this.localCluster?.wasTransactionExecuted?.(messageHash) ?? false;
|
|
299
|
-
|
|
346
|
+
const localPendResult = localExecuted ? this.localCluster?.getExecutedPendResult?.(messageHash) : undefined;
|
|
347
|
+
const localCommitResult = localExecuted ? this.localCluster?.getExecutedCommitResult?.(messageHash) : undefined;
|
|
348
|
+
return {
|
|
349
|
+
record: result,
|
|
350
|
+
localExecuted,
|
|
351
|
+
...(localPendResult === undefined ? {} : { localPendResult }),
|
|
352
|
+
...(localCommitResult === undefined ? {} : { localCommitResult })
|
|
353
|
+
};
|
|
300
354
|
} finally {
|
|
301
355
|
const stored = this.transactions.get(messageHash);
|
|
302
356
|
const retrySnapshot = stored?.retry ? {
|