@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
|
@@ -29,23 +29,206 @@ export const MAX_LEARNED_PEERS_PER_RECORD = 64;
|
|
|
29
29
|
* "an address string we are willing to carry".
|
|
30
30
|
*/
|
|
31
31
|
export function validMultiaddrStrings(addrs, log) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
log('WARN: invalid multiaddr %s %o', a, err);
|
|
32
|
+
return addrs.filter(a => isCarriableMultiaddrString(a, log));
|
|
33
|
+
}
|
|
34
|
+
/** One address string's verdict, shared by {@link validMultiaddrStrings} and {@link publishableConnectionAddr}. */
|
|
35
|
+
function isCarriableMultiaddrString(addr, log) {
|
|
36
|
+
try {
|
|
37
|
+
// An empty string parses as the root multiaddr `/` — syntactically fine, addresses
|
|
38
|
+
// nothing, and encodes to zero bytes. Reject it so a blank entry can't occupy a slot
|
|
39
|
+
// in the address book (or in the per-message cap).
|
|
40
|
+
if (multiaddr(addr).bytes.length === 0) {
|
|
41
|
+
log('WARN: multiaddr addresses nothing %s', addr);
|
|
42
|
+
return false;
|
|
46
43
|
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
log('WARN: invalid multiaddr %s %o', addr, err);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A live connection's remote address, when it is one we may publish to a **third** party —
|
|
53
|
+
* otherwise `undefined`.
|
|
54
|
+
*
|
|
55
|
+
* The companion to {@link validMultiaddrStrings}: that answers "an address string we are willing
|
|
56
|
+
* to carry", this answers "an address we are willing to hand to someone else". They are not the
|
|
57
|
+
* same question, because an inbound connection's `remoteAddr` is not an address at all in the
|
|
58
|
+
* sense a third party needs. For an **outbound** connection it is the address we dialed — a real
|
|
59
|
+
* listen (or circuit) address that anyone can reach the peer on. For an **inbound** one it is the
|
|
60
|
+
* far side's *ephemeral source socket*: the port their operating system picked for this single
|
|
61
|
+
* connection. It is reachable by nobody else, it is indistinguishable from a listen address once
|
|
62
|
+
* it is on the wire, and it takes a slot against {@link MAX_MERGED_ADDRS_PER_PEER} in every peer
|
|
63
|
+
* that merges it. So the cure has to be here, at the producer.
|
|
64
|
+
*
|
|
65
|
+
* An inbound-only peer loses nothing by this: its own advertised addresses reach us through
|
|
66
|
+
* `identify`/`identifyPush` and are published from the peerStore instead — see
|
|
67
|
+
* {@link publishableAddrsForPeer}, which is where the two halves are joined.
|
|
68
|
+
*
|
|
69
|
+
* NOTE: accepted tradeoff — making an INBOUND connection's `remoteAddr` publishable when it is a
|
|
70
|
+
* circuit address was proposed (the "at least a relayed dialer has a real address" reading) and
|
|
71
|
+
* declined. Read from `@libp2p/circuit-relay-v2@4.1.3` as vendored under
|
|
72
|
+
* `packages/db-p2p/node_modules`: the destination side composes that address as
|
|
73
|
+
* `ourConnectionToTheRelay.remoteAddr` encapsulated with `/p2p-circuit/p2p/<dialer>`
|
|
74
|
+
* (`dist/src/transport/index.js:272`), so the relay it names is the one WE hold a reservation
|
|
75
|
+
* with, not one the dialer is reachable on. A relay's `handleConnect` requires a reservation for
|
|
76
|
+
* the DESTINATION only (`dist/src/server/index.js:219-222`, status `NO_RESERVATION`) — a dialer
|
|
77
|
+
* needs none — so a third party dialing that composed address reaches the dialer only if the
|
|
78
|
+
* dialer coincidentally also holds a reservation on our relay, which nothing establishes. When our
|
|
79
|
+
* own hop to the relay was itself inbound the prefix is an ephemeral source socket, making it
|
|
80
|
+
* undialable twice over. And in the one case where it would work — dialer and we share a relay —
|
|
81
|
+
* the dialer's genuine self-advertised circuit address has already reached us through `identify`,
|
|
82
|
+
* so publishing the composed form adds nothing and costs a slot against
|
|
83
|
+
* {@link MAX_MERGED_ADDRS_PER_PEER}. Revisit only on a MEASURED case where a peer's genuine
|
|
84
|
+
* circuit address reaches a third party by no other route.
|
|
85
|
+
*/
|
|
86
|
+
export function publishableConnectionAddr(conn, log) {
|
|
87
|
+
if (conn.direction !== 'outbound')
|
|
88
|
+
return undefined;
|
|
89
|
+
const addr = conn.remoteAddr?.toString?.();
|
|
90
|
+
if (addr === undefined)
|
|
91
|
+
return undefined;
|
|
92
|
+
return isCarriableMultiaddrString(addr, log) ? addr : undefined;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Join the two sources of a third-party-publishable address set: the publishable half of our live
|
|
96
|
+
* connections, then the peer's own advertised addresses. De-duplicated, **connection-first**.
|
|
97
|
+
*
|
|
98
|
+
* The ordering is not cosmetic. An address that reaches `connectionAddrs` is one we OUTBOUND-dialed,
|
|
99
|
+
* so libp2p has just succeeded with it; an advertised address is one we have never tried. So the
|
|
100
|
+
* proven one goes first, and the recipient — which caps what it merges at
|
|
101
|
+
* {@link MAX_MERGED_ADDRS_PER_PEER} — keeps the proven ones when it truncates.
|
|
102
|
+
*
|
|
103
|
+
* `connectionAddrs` are already validated by {@link publishableConnectionAddr}; the advertised half
|
|
104
|
+
* arrives from a peerStore or a record and is put through {@link validMultiaddrStrings} here, so the
|
|
105
|
+
* union is uniformly carriable regardless of which side an address came from.
|
|
106
|
+
*
|
|
107
|
+
* Split out from {@link publishableAddrsForPeer} for the one caller that has already read the
|
|
108
|
+
* peerStore for other reasons (`findCluster`'s membership-scoped path reads protocols and addresses
|
|
109
|
+
* in a single `store.get` per member) and must not pay a second read to reuse the rule.
|
|
110
|
+
*/
|
|
111
|
+
export function unionPublishableAddrs(connectionAddrs, advertisedAddrs, log) {
|
|
112
|
+
return Array.from(new Set([...connectionAddrs, ...validMultiaddrStrings(advertisedAddrs, log)]));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Every address we may hand a **third** party for `peerId`.
|
|
116
|
+
*
|
|
117
|
+
* The single answer to that question: `findCluster` (via {@link unionPublishableAddrs}) and all
|
|
118
|
+
* three redirect-address resolvers — `RepoService.getPeerAddrs`, `ClusterService.getPeerAddrs`, and
|
|
119
|
+
* the `getConnectionAddrs` the node wires into the cluster service — go through this one rule.
|
|
120
|
+
* They used to answer it two different ways, and the connections-only half was the weaker one: a
|
|
121
|
+
* cohort member that only ever dialed US and is reachable only through a relay has its real circuit
|
|
122
|
+
* address in exactly one place — the peerStore, where `identify`/`identifyPush` put it — so a
|
|
123
|
+
* redirect built from connections alone described it as having no address at all.
|
|
124
|
+
*
|
|
125
|
+
* A peerStore read that fails or finds nothing yields the connection-derived half rather than
|
|
126
|
+
* throwing: a redirect carrying half the answer is strictly better than a redirect that errors.
|
|
127
|
+
*/
|
|
128
|
+
export async function publishableAddrsForPeer(host, connections, peerId, log) {
|
|
129
|
+
const connectionAddrs = [];
|
|
130
|
+
for (const conn of connections) {
|
|
131
|
+
const addr = publishableConnectionAddr(conn, log);
|
|
132
|
+
if (addr !== undefined)
|
|
133
|
+
connectionAddrs.push(addr);
|
|
134
|
+
}
|
|
135
|
+
return unionPublishableAddrs(connectionAddrs, await advertisedAddrsForPeer(host, peerId, log), log);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The addresses `peerId` has advertised to us, as libp2p's peerStore holds them.
|
|
139
|
+
*
|
|
140
|
+
* A miss is the common case, not an anomaly — libp2p's `peerStore.get` THROWS for a peer it has no
|
|
141
|
+
* record of, and a redirect routinely names cohort members we have never met — so this logs under
|
|
142
|
+
* the ordinary `peer-address-book:*` tag family rather than `WARN:`, which is reserved for input we
|
|
143
|
+
* were handed and rejected.
|
|
144
|
+
*
|
|
145
|
+
* NOTE: this adds one `peerStore.get` per redirect target where the redirect resolvers previously
|
|
146
|
+
* did none. A redirect names at most `clusterSize` peers — single digits — and only fires when this
|
|
147
|
+
* node is NOT responsible for the key, so the reads are bounded and off the hot path. Unmeasured;
|
|
148
|
+
* if redirect volume ever shows up in a profile, batch the reads per payload (they are already
|
|
149
|
+
* issued concurrently by `Promise.all` at both call sites) rather than dropping the peerStore arm.
|
|
150
|
+
*/
|
|
151
|
+
async function advertisedAddrsForPeer(host, peerId, log) {
|
|
152
|
+
const get = host.peerStore?.get;
|
|
153
|
+
if (typeof get !== 'function')
|
|
154
|
+
return [];
|
|
155
|
+
try {
|
|
156
|
+
const peer = await get.call(host.peerStore, peerId);
|
|
157
|
+
return (peer?.addresses ?? []).map(a => a.multiaddr.toString());
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
log('peer-address-book:peerstore-miss peer=%s %o', peerId.toString().substring(0, 12), err);
|
|
161
|
+
return [];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Does `addr` reach its target by relaying through `relayPeerId`?
|
|
166
|
+
*
|
|
167
|
+
* A circuit multiaddr names its relay in the `p2p` component immediately BEFORE the
|
|
168
|
+
* `p2p-circuit` marker — `/<transport>/p2p/<relay>/p2p-circuit[/p2p/<target>]`. So the question is
|
|
169
|
+
* answered by walking the address's components, not by testing the string for `/p2p/<id>/p2p-circuit`:
|
|
170
|
+
* the peer id after the marker (appended by libp2p's dial queue), a bare `/p2p-circuit` with no
|
|
171
|
+
* relay named, and multi-hop addresses with two circuit markers all read differently as text but
|
|
172
|
+
* classify correctly as components. True if ANY hop relays through `relayPeerId` — a chain that
|
|
173
|
+
* passes through us at any point is one we cannot open ourselves.
|
|
174
|
+
*
|
|
175
|
+
* Called with our own peer id, this is the "can WE dial this?" question. It is deliberately NOT
|
|
176
|
+
* the same question as {@link publishableConnectionAddr}'s: a self-relay address is perfectly
|
|
177
|
+
* publishable — a cohort sibling reaching a peer through our relay is the working path — and is
|
|
178
|
+
* simply unusable by the one node the circuit terminates on.
|
|
179
|
+
*/
|
|
180
|
+
export function routesThroughRelay(addr, relayPeerId, log) {
|
|
181
|
+
let components;
|
|
182
|
+
try {
|
|
183
|
+
components = multiaddr(addr).getComponents();
|
|
47
184
|
}
|
|
48
|
-
|
|
185
|
+
catch (err) {
|
|
186
|
+
// Fail open. An address we cannot parse is not evidence of a self-relay loop, and the
|
|
187
|
+
// caller's fallback — dial it and let libp2p reject it — is the pre-existing behavior.
|
|
188
|
+
log('WARN: invalid multiaddr %s %o', addr, err);
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
return components.some((component, i) => component.name === 'p2p-circuit' && isRelayComponent(components[i - 1], relayPeerId));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* True when `component` is the `p2p` hop naming `relayPeerId` (absent/other component → false).
|
|
195
|
+
*
|
|
196
|
+
* `relayPeerId` is always a `PeerId.toString()`, i.e. base58btc. A multiaddr's `p2p` value usually
|
|
197
|
+
* is too — but it may equally be written as a CIDv1 libp2p-key string, and `@multiformats/multiaddr`
|
|
198
|
+
* keeps whichever form it was given rather than normalizing. String equality alone would therefore
|
|
199
|
+
* miss a CIDv1-form self-relay address arriving from the wire (`mergePeerAddresses` accepts any
|
|
200
|
+
* parseable multiaddr). The canonical compare runs only when the cheap one fails, and only for the
|
|
201
|
+
* single component sitting in front of a circuit marker, so the parse is bounded to circuit
|
|
202
|
+
* addresses rather than paid per address.
|
|
203
|
+
*/
|
|
204
|
+
function isRelayComponent(component, relayPeerId) {
|
|
205
|
+
if (component?.name !== 'p2p' || component.value === undefined)
|
|
206
|
+
return false;
|
|
207
|
+
if (component.value === relayPeerId)
|
|
208
|
+
return true;
|
|
209
|
+
try {
|
|
210
|
+
return peerIdFromString(component.value).toString() === relayPeerId;
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
// multiaddr accepted the component but we cannot read it back as a peer id; we simply
|
|
214
|
+
// cannot claim it is ours, and the address stays dialable-as-far-as-we-know.
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Classify what the addresses we hold for one peer are worth to our own dialer.
|
|
220
|
+
*
|
|
221
|
+
* `self-relay-only` is the state a relay lands in for its own reservation holders: the address
|
|
222
|
+
* such a client advertises — and therefore the one we learn through `identifyPush` and store — is
|
|
223
|
+
* `/<our transport addr>/p2p/<our peer id>/p2p-circuit`. Dialing it is guaranteed to fail, and the
|
|
224
|
+
* failure is indistinguishable from `none` in libp2p's error text, so the two are separated here
|
|
225
|
+
* instead. Nothing can repair it from our side: once the client's connection drops only the client
|
|
226
|
+
* can re-initiate, so the useful response is to fail fast and let the caller move on.
|
|
227
|
+
*/
|
|
228
|
+
export function classifySelfDialability(addrs, selfPeerId, log) {
|
|
229
|
+
if (addrs.length === 0)
|
|
230
|
+
return 'none';
|
|
231
|
+
return addrs.some(addr => !routesThroughRelay(addr, selfPeerId, log)) ? 'dialable' : 'self-relay-only';
|
|
49
232
|
}
|
|
50
233
|
/**
|
|
51
234
|
* Write dialable addresses for `peerId` into the libp2p address book, from addresses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer-address-book.js","sourceRoot":"","sources":["../../src/peer-address-book.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"peer-address-book.js","sourceRoot":"","sources":["../../src/peer-address-book.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAkC,MAAM,yBAAyB,CAAA;AAEnF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAA;AAE1C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAA;AAc9C;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAe,EAAE,GAAe;IACrE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;AAC7D,CAAC;AAED,mHAAmH;AACnH,SAAS,0BAA0B,CAAC,IAAY,EAAE,GAAe;IAChE,IAAI,CAAC;QACJ,mFAAmF;QACnF,qFAAqF;QACrF,mDAAmD;QACnD,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxC,GAAG,CAAC,sCAAsC,EAAE,IAAI,CAAC,CAAA;YACjD,OAAO,KAAK,CAAA;QACb,CAAC;QACD,OAAO,IAAI,CAAA;IACZ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,GAAG,CAAC,+BAA+B,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;QAC/C,OAAO,KAAK,CAAA;IACb,CAAC;AACF,CAAC;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,y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E,CAAC;YAC7C,oFAAoF;YACpF,iDAAiD;YACjD,GAAG,CAAC,yCAAyC,EAAE,4BAA4B,CAAC,CAAA;YAC5E,OAAM;QACP,CAAC;QACD,OAAO,IAAI,CAAC,CAAA;QACZ,IAAI,GAAW,CAAA;QACf,IAAI,CAAC;YACJ,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,sFAAsF;YACtF,2CAA2C;YAC3C,GAAG,CAAC,mDAAmD,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;YACpE,SAAQ;QACT,CAAC;QACD,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACjB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { PendRequest, PendValidationResult, UnvalidatablePendPolicy } from "@optimystic/db-core";
|
|
2
|
+
/**
|
|
3
|
+
* Stable, greppable prefix on the failure reason a validating receiver emits when it refuses a pend
|
|
4
|
+
* that carries no `validation` payload (nothing to re-execute — the single-collection
|
|
5
|
+
* `Collection.sync` shape) under the fail-closed `unvalidatablePendPolicy: 'reject'`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PEND_NOT_VALIDATABLE = "pend-not-validatable";
|
|
8
|
+
/**
|
|
9
|
+
* Stable, greppable prefix on the failure reason a validating receiver emits when the checker
|
|
10
|
+
* itself THREW (engine fault, missing table, parse error) rather than returning a verdict. Distinct
|
|
11
|
+
* from a content verdict on purpose: an operator reading a reject reason can tell "this transaction
|
|
12
|
+
* is wrong" from "this node could not tell".
|
|
13
|
+
*/
|
|
14
|
+
export declare const VALIDATOR_FAULT = "validator-fault";
|
|
15
|
+
/**
|
|
16
|
+
* One re-check attempt: hand the pend's `validation` pair to whatever checker this tier holds
|
|
17
|
+
* (a `ClusterMember`'s `ITransactionValidator`, a `StorageRepo`'s `validatePend` hook) and
|
|
18
|
+
* return its verdict. Throwing is allowed — {@link checkPendValidation} converts a throw into a
|
|
19
|
+
* {@link VALIDATOR_FAULT} rejection.
|
|
20
|
+
*/
|
|
21
|
+
export type PendChecker = (validation: NonNullable<PendRequest['validation']>) => Promise<PendValidationResult>;
|
|
22
|
+
/** Structured trace of the decision this helper took, rendered by whichever tier called it. */
|
|
23
|
+
export type PendValidationEvent = {
|
|
24
|
+
kind: 'unvalidatable';
|
|
25
|
+
policy: UnvalidatablePendPolicy;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'validator-fault';
|
|
28
|
+
error: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The fail-closed pend re-check, shared by BOTH tiers that hold a checker — `ClusterMember`
|
|
32
|
+
* (voting on a cluster record) and `StorageRepo` (applying a pend locally). One implementation
|
|
33
|
+
* rather than two mirrored copies, because the two tiers refusing with *different* prefixes or
|
|
34
|
+
* *different* policy semantics is a silent inconsistency nothing would catch: they are read by the
|
|
35
|
+
* same operator, and a member that votes approve while its own storage refuses at apply burns a
|
|
36
|
+
* consensus round for nothing.
|
|
37
|
+
*
|
|
38
|
+
* Two decisions live here:
|
|
39
|
+
*
|
|
40
|
+
* - **No `validation` pair** (the single-collection `Collection.sync` shape — bare transforms, so
|
|
41
|
+
* there is nothing to re-execute): an explicit, LOGGED policy branch on both arms, never a silent
|
|
42
|
+
* fall-through. `'accept'` admits it unchecked, preserving the historical behaviour; `'reject'`
|
|
43
|
+
* refuses with {@link PEND_NOT_VALIDATABLE}. The presence test is on the whole pair, so a sender
|
|
44
|
+
* cannot talk a receiver out of validating by omitting half of it.
|
|
45
|
+
* - **A checker that throws**: caught and turned into a {@link VALIDATOR_FAULT} rejection, never an
|
|
46
|
+
* escaping error. At the cluster tier an escaping throw costs the member its vote entirely —
|
|
47
|
+
* indistinguishable from an unreachable peer, and with no signed reason for the dispute path.
|
|
48
|
+
*
|
|
49
|
+
* NOTE: a TRANSIENT checker fault (database busy, momentary connection loss) therefore produces a
|
|
50
|
+
* terminal reject where a redelivery might have produced an approve. `CoordinatorRepo`'s two
|
|
51
|
+
* rejection classifiers confirm retryability against LOCAL storage state and never read this prose,
|
|
52
|
+
* so a validator-fault reject is returned as retryable only when local state independently shows a
|
|
53
|
+
* stale revision or a rival pending — otherwise it reaches the writer as a throw. If transient
|
|
54
|
+
* validator faults ever show up in practice, give the classifier an arm keyed on this prefix rather
|
|
55
|
+
* than reverting to a silent pass or a lost vote.
|
|
56
|
+
*
|
|
57
|
+
* @param request the pend under consideration
|
|
58
|
+
* @param check the tier's checker, or undefined when this node re-validates nothing (then every
|
|
59
|
+
* pend passes and the policy is irrelevant — a storage-only node)
|
|
60
|
+
* @param policy what to do with a pend that carries no `validation` pair
|
|
61
|
+
* @param onEvent trace sink; called on every decision this helper takes, so the two tiers log the
|
|
62
|
+
* same facts in their own formats
|
|
63
|
+
*/
|
|
64
|
+
export declare function checkPendValidation(request: PendRequest, check: PendChecker | undefined, policy: UnvalidatablePendPolicy, onEvent: (event: PendValidationEvent) => void): Promise<PendValidationResult>;
|
|
65
|
+
//# sourceMappingURL=pend-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pend-validation.d.ts","sourceRoot":"","sources":["../../src/pend-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEtG;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEhH,+FAA+F;AAC/F,MAAM,MAAM,mBAAmB,GAC5B;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,WAAW,GAAG,SAAS,EAC9B,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,GAC3C,OAAO,CAAC,oBAAoB,CAAC,CAmB/B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable, greppable prefix on the failure reason a validating receiver emits when it refuses a pend
|
|
3
|
+
* that carries no `validation` payload (nothing to re-execute — the single-collection
|
|
4
|
+
* `Collection.sync` shape) under the fail-closed `unvalidatablePendPolicy: 'reject'`.
|
|
5
|
+
*/
|
|
6
|
+
export const PEND_NOT_VALIDATABLE = 'pend-not-validatable';
|
|
7
|
+
/**
|
|
8
|
+
* Stable, greppable prefix on the failure reason a validating receiver emits when the checker
|
|
9
|
+
* itself THREW (engine fault, missing table, parse error) rather than returning a verdict. Distinct
|
|
10
|
+
* from a content verdict on purpose: an operator reading a reject reason can tell "this transaction
|
|
11
|
+
* is wrong" from "this node could not tell".
|
|
12
|
+
*/
|
|
13
|
+
export const VALIDATOR_FAULT = 'validator-fault';
|
|
14
|
+
/**
|
|
15
|
+
* The fail-closed pend re-check, shared by BOTH tiers that hold a checker — `ClusterMember`
|
|
16
|
+
* (voting on a cluster record) and `StorageRepo` (applying a pend locally). One implementation
|
|
17
|
+
* rather than two mirrored copies, because the two tiers refusing with *different* prefixes or
|
|
18
|
+
* *different* policy semantics is a silent inconsistency nothing would catch: they are read by the
|
|
19
|
+
* same operator, and a member that votes approve while its own storage refuses at apply burns a
|
|
20
|
+
* consensus round for nothing.
|
|
21
|
+
*
|
|
22
|
+
* Two decisions live here:
|
|
23
|
+
*
|
|
24
|
+
* - **No `validation` pair** (the single-collection `Collection.sync` shape — bare transforms, so
|
|
25
|
+
* there is nothing to re-execute): an explicit, LOGGED policy branch on both arms, never a silent
|
|
26
|
+
* fall-through. `'accept'` admits it unchecked, preserving the historical behaviour; `'reject'`
|
|
27
|
+
* refuses with {@link PEND_NOT_VALIDATABLE}. The presence test is on the whole pair, so a sender
|
|
28
|
+
* cannot talk a receiver out of validating by omitting half of it.
|
|
29
|
+
* - **A checker that throws**: caught and turned into a {@link VALIDATOR_FAULT} rejection, never an
|
|
30
|
+
* escaping error. At the cluster tier an escaping throw costs the member its vote entirely —
|
|
31
|
+
* indistinguishable from an unreachable peer, and with no signed reason for the dispute path.
|
|
32
|
+
*
|
|
33
|
+
* NOTE: a TRANSIENT checker fault (database busy, momentary connection loss) therefore produces a
|
|
34
|
+
* terminal reject where a redelivery might have produced an approve. `CoordinatorRepo`'s two
|
|
35
|
+
* rejection classifiers confirm retryability against LOCAL storage state and never read this prose,
|
|
36
|
+
* so a validator-fault reject is returned as retryable only when local state independently shows a
|
|
37
|
+
* stale revision or a rival pending — otherwise it reaches the writer as a throw. If transient
|
|
38
|
+
* validator faults ever show up in practice, give the classifier an arm keyed on this prefix rather
|
|
39
|
+
* than reverting to a silent pass or a lost vote.
|
|
40
|
+
*
|
|
41
|
+
* @param request the pend under consideration
|
|
42
|
+
* @param check the tier's checker, or undefined when this node re-validates nothing (then every
|
|
43
|
+
* pend passes and the policy is irrelevant — a storage-only node)
|
|
44
|
+
* @param policy what to do with a pend that carries no `validation` pair
|
|
45
|
+
* @param onEvent trace sink; called on every decision this helper takes, so the two tiers log the
|
|
46
|
+
* same facts in their own formats
|
|
47
|
+
*/
|
|
48
|
+
export async function checkPendValidation(request, check, policy, onEvent) {
|
|
49
|
+
if (!check) {
|
|
50
|
+
return { valid: true };
|
|
51
|
+
}
|
|
52
|
+
if (!request.validation) {
|
|
53
|
+
onEvent({ kind: 'unvalidatable', policy });
|
|
54
|
+
return policy === 'reject'
|
|
55
|
+
// Plain prose after the stable prefix: at the cluster tier this reason is fed to
|
|
56
|
+
// computeSigningPayload and carried as Signature.rejectReason, so it must stay a string.
|
|
57
|
+
? { valid: false, reason: `${PEND_NOT_VALIDATABLE}: pend carries no transaction to re-execute` }
|
|
58
|
+
: { valid: true };
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return await check(request.validation);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
const error = err.message;
|
|
65
|
+
onEvent({ kind: 'validator-fault', error });
|
|
66
|
+
return { valid: false, reason: `${VALIDATOR_FAULT}: ${error}` };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=pend-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pend-validation.js","sourceRoot":"","sources":["../../src/pend-validation.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAejD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,OAAoB,EACpB,KAA8B,EAC9B,MAA+B,EAC/B,OAA6C;IAE7C,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACxB,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACzB,OAAO,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3C,OAAO,MAAM,KAAK,QAAQ;YACzB,iFAAiF;YACjF,yFAAyF;YACzF,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,oBAAoB,6CAA6C,EAAE;YAChG,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,MAAM,KAAK,GAAI,GAAa,CAAC,OAAO,CAAC;QACrC,OAAO,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,eAAe,KAAK,KAAK,EAAE,EAAE,CAAC;IACjE,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify-transport.d.ts","sourceRoot":"","sources":["../../../src/reactivity/notify-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"notify-transport.d.ts","sourceRoot":"","sources":["../../../src/reactivity/notify-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAYrC,wGAAwG;AACxG,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,wFAAwF;IACxF,cAAc,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,cAAc,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChF,mFAAmF;IACnF,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CACrD;AAED,wEAAwE;AACxE,MAAM,WAAW,gCAAgC;IAChD,sEAAsE;IACtE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,gGAAgG;IAChG,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,2GAA2G;IAC3G,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,qBAAa,+BAAgC,YAAW,yBAAyB;IAMpE,OAAO,CAAC,QAAQ,CAAC,IAAI;IALjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyD;IAClF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAS;gBAER,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gCAAqC;IAMzF,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBtD,cAAc,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,cAAc,KAAK,IAAI,GAAG,MAAM,IAAI;IAK/E,mFAAmF;IACnF,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;CAcpD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,yBAAyB,EACpC,QAAQ,SAA2B,GACjC,IAAI,CAgBN"}
|
|
@@ -23,6 +23,7 @@ import { readFramed } from "p2p-fret";
|
|
|
23
23
|
import { peerIdToBytes } from "../cohort-topic/peer-codec.js";
|
|
24
24
|
import { sendOneWay, DEFAULT_STREAM_MAX_BYTES } from "../cohort-topic/stream-util.js";
|
|
25
25
|
import { PROTOCOL_REACTIVITY_NOTIFY } from "./protocols.js";
|
|
26
|
+
import { registerProtocolHandler } from "../network/register-protocol-handler.js";
|
|
26
27
|
import { createLogger } from "../logger.js";
|
|
27
28
|
const log = createLogger("reactivity-notify");
|
|
28
29
|
/**
|
|
@@ -90,7 +91,7 @@ export class Libp2pReactivityNotifyTransport {
|
|
|
90
91
|
* swallows a decode failure, so the handler never throws on the stream.
|
|
91
92
|
*/
|
|
92
93
|
export function registerNotifyHandler(node, protocol, transport, maxBytes = DEFAULT_STREAM_MAX_BYTES) {
|
|
93
|
-
void node
|
|
94
|
+
void registerProtocolHandler(node, protocol, (stream, connection) => {
|
|
94
95
|
void (async () => {
|
|
95
96
|
try {
|
|
96
97
|
const frame = await readFramed(stream, maxBytes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify-transport.js","sourceRoot":"","sources":["../../../src/reactivity/notify-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,GAAG,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AA0B9C;;;;;GAKG;AACH,MAAM,OAAO,+BAA+B;IAMd;IALZ,QAAQ,GAAG,IAAI,GAAG,EAA8C,CAAC;IACjE,cAAc,CAAS;IACvB,QAAQ,CAAS;IACjB,UAAU,CAAU;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MAAM,CAAC;oBACR,qBAAqB;gBACtB,CAAC;YACF,CAAC;QACF,CAAC,CAAC,EAAE,CAAC;IACN,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-state-gossip.d.ts","sourceRoot":"","sources":["../../../src/reactivity/push-state-gossip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAGN,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"push-state-gossip.d.ts","sourceRoot":"","sources":["../../../src/reactivity/push-state-gossip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAGN,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAY5F,yGAAyG;AACzG,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC;CAChC;AAED,0GAA0G;AAC1G,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAC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A4C;IAExE,OAAO,CAAC,KAAK,CAAC,CAAiC;IAC/C,OAAO,CAAC,OAAO,CAAS;IACxB,8FAA8F;IAC9F,OAAO,CAAC,QAAQ,CAAS;gBAEb,IAAI,EAAE,mCAAmC;IAUrD,sFAAsF;IACtF,KAAK,IAAI,IAAI;IAYb;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAqBb;;;;;OAKG;IACH,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAuBpD,sFAAsF;IACtF,IAAI,IAAI,IAAI;IAQZ,sFAAsF;IACtF,OAAO,CAAC,YAAY;IAapB;;;;;;;;OAQG;IACH,OAAO,CAAC,YAAY;IA0BpB,4GAA4G;IAC5G,OAAO,CAAC,WAAW;CASnB;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC7C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,IAAI,CAAC,+BAA+B,EAAE,SAAS,CAAC,EACxD,QAAQ,SAA2B,GACjC,IAAI,CAgBN"}
|
|
@@ -35,6 +35,7 @@ import { readFramed } from "p2p-fret";
|
|
|
35
35
|
import { DEFAULT_GOSSIP_INTERVAL_MS } from "../cohort-topic/cohort-gossip-driver.js";
|
|
36
36
|
import { DEFAULT_STREAM_MAX_BYTES } from "../cohort-topic/stream-util.js";
|
|
37
37
|
import { PROTOCOL_REACTIVITY_PUSH_STATE_GOSSIP } from "./protocols.js";
|
|
38
|
+
import { registerProtocolHandler } from "../network/register-protocol-handler.js";
|
|
38
39
|
import { createLogger } from "../logger.js";
|
|
39
40
|
const log = createLogger("reactivity-push-state-gossip");
|
|
40
41
|
/** Encode a probe frame with no size ceiling so the driver can measure its true length before bounding. */
|
|
@@ -210,7 +211,7 @@ export class ReactivityPushStateGossipDriver {
|
|
|
210
211
|
* never throws on the stream. Mirrors {@link import("./notify-transport.js").registerNotifyHandler}.
|
|
211
212
|
*/
|
|
212
213
|
export function registerPushStateGossipHandler(node, protocol, driver, maxBytes = DEFAULT_STREAM_MAX_BYTES) {
|
|
213
|
-
void node
|
|
214
|
+
void registerProtocolHandler(node, protocol, (stream, connection) => {
|
|
214
215
|
void (async () => {
|
|
215
216
|
try {
|
|
216
217
|
const frame = await readFramed(stream, maxBytes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-state-gossip.js","sourceRoot":"","sources":["../../../src/reactivity/push-state-gossip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EACN,uBAAuB,EACvB,uBAAuB,GAIvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,qCAAqC,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,GAAG,GAAG,YAAY,CAAC,8BAA8B,CAAC,CAAC;AAEzD,2GAA2G;AAC3G,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC;AA0C/C;;;;;GAKG;AACH,MAAM,OAAO,+BAA+B;IAC1B,eAAe,CAAmD;IAClE,eAAe,CAA6C;IAC5D,kBAAkB,CAAkD;IACpE,cAAc,CAAyD;IACvE,UAAU,CAAS;IACnB,QAAQ,CAAS;IACjB,UAAU,CAA6C;IAEhE,KAAK,CAAkC;IACvC,OAAO,GAAG,KAAK,CAAC;IACxB,8FAA8F;IACtF,QAAQ,GAAG,KAAK,CAAC;IAEzB,YAAY,IAAyC;QACpD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC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;gBACjD,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;gBACxD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,CAAC;YAAC,MAAM,CAAC;gBACR,IAAI,CAAC;oBACJ,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC,CAAC;gBAC9E,CAAC;gBAAC,MAAM,CAAC;oBACR,qBAAqB;gBACtB,CAAC;YACF,CAAC;QACF,CAAC,CAAC,EAAE,CAAC;IACN,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClusterRecord, IKeyNetwork, RepoMessage, BlockId, MessageOptions, ClusterConsensusConfig, ICluster } from "@optimystic/db-core";
|
|
1
|
+
import type { ClusterRecord, IKeyNetwork, RepoMessage, BlockId, MessageOptions, ClusterConsensusConfig, ICluster, PendResult, CommitResult } from "@optimystic/db-core";
|
|
2
2
|
import type { PeerId } from "@libp2p/interface";
|
|
3
3
|
import type { FretService } from "p2p-fret";
|
|
4
4
|
import type { IPeerReputation } from "../reputation/types.js";
|
|
@@ -24,10 +24,17 @@ export declare class ValidatorRejectionError extends Error {
|
|
|
24
24
|
* vote (they hold a rival transaction that won the deterministic race on the same blocks) and
|
|
25
25
|
* approvals fell short of super-majority. Distinct from {@link ValidatorRejectionError} — nobody
|
|
26
26
|
* judged this write invalid; it lost an optimistic-concurrency race and a fresh retry can win.
|
|
27
|
-
* `CoordinatorRepo.pend`
|
|
28
|
-
* retry machinery (`isConflictFailure`) absorbs it; it should escape
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
* `CoordinatorRepo.pend` AND `CoordinatorRepo.commit` both convert this into a `StaleFailure` with
|
|
28
|
+
* `conflict: true` so the normal retry machinery (`isConflictFailure`) absorbs it; it should escape
|
|
29
|
+
* as a thrown error only from other paths. The commit conversion matters as much as the pend one:
|
|
30
|
+
* at the moment this is thrown zero members approved and the members hold the winner — nothing of
|
|
31
|
+
* the loser landed — yet a THROWN commit error is retried verbatim by db-core's `commitCollection`
|
|
32
|
+
* (it treats throws as transport faults), and that re-driven commit races into the window after
|
|
33
|
+
* members apply the winner and clear its reservation, where it can assemble a consensus no member
|
|
34
|
+
* will durably store. A returned conflict is instead surfaced immediately as a stale loss, and the
|
|
35
|
+
* writer re-reads and re-drives the whole pend+commit at a fresh revision. The conflicting peers
|
|
36
|
+
* and the winning hashes ride as structured data (from the signed `conflictWith` fields), never
|
|
37
|
+
* parsed out of prose.
|
|
31
38
|
*/
|
|
32
39
|
export declare class ConflictRaceLostError extends Error {
|
|
33
40
|
/** peerId → messageHash of the rival transaction that member holds as the race winner. */
|
|
@@ -77,6 +84,10 @@ export declare class ClusterCoordinator {
|
|
|
77
84
|
update: (record: ClusterRecord) => Promise<ClusterRecord>;
|
|
78
85
|
peerId: PeerId;
|
|
79
86
|
wasTransactionExecuted?: (messageHash: string) => boolean;
|
|
87
|
+
/** Local storage's verdict for a pend applied during consensus; see ClusterMember.getExecutedPendResult. */
|
|
88
|
+
getExecutedPendResult?: (messageHash: string) => PendResult | undefined;
|
|
89
|
+
/** Local storage's verdict for a commit applied during consensus; see ClusterMember.getExecutedCommitResult. */
|
|
90
|
+
getExecutedCommitResult?: (messageHash: string) => CommitResult | undefined;
|
|
80
91
|
} | undefined, fretService?: FretService | undefined, reputation?: IPeerReputation | undefined, stateStore?: ITransactionStateStore | undefined, clock?: ClusterCoordinatorClock);
|
|
81
92
|
/**
|
|
82
93
|
* Invoke one cluster member's `update`, retrying transient REMOTE failures up to
|
|
@@ -97,7 +108,7 @@ export declare class ClusterCoordinator {
|
|
|
97
108
|
* reproduces the legacy v1 hash byte-for-byte.
|
|
98
109
|
*
|
|
99
110
|
* NOTE: the whole `message` is hashed (canonicalJson), so a transaction's advisory aged priority —
|
|
100
|
-
* which rides inside the pend operation as `pend.transaction.priority` (multi-collection) or
|
|
111
|
+
* which rides inside the pend operation as `pend.validation.transaction.priority` (multi-collection) or
|
|
101
112
|
* `pend.priority` (single-collection) — is automatically covered here and by the derived
|
|
102
113
|
* promise/commit hashes. That is what makes priority integrity-protected in transit: a relaying peer
|
|
103
114
|
* cannot strip or inflate it without invalidating the message hash the members verify. No separate
|
|
@@ -116,6 +127,21 @@ export declare class ClusterCoordinator {
|
|
|
116
127
|
executeClusterTransaction(blockId: BlockId, message: RepoMessage, _options?: MessageOptions): Promise<{
|
|
117
128
|
record: ClusterRecord;
|
|
118
129
|
localExecuted: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Local storage's verdict for a pend operation this node's own cluster member applied during
|
|
132
|
+
* consensus, when the member retained one. Meaningful only when `localExecuted` is true;
|
|
133
|
+
* absent for non-pend messages, for a member that predates the retention, or after the
|
|
134
|
+
* retention TTL. `CoordinatorRepo.pend` returns this instead of fabricating a success.
|
|
135
|
+
*/
|
|
136
|
+
localPendResult?: PendResult;
|
|
137
|
+
/**
|
|
138
|
+
* Local storage's verdict for a commit operation this node's own cluster member applied
|
|
139
|
+
* during consensus, when the member retained one. Same availability contract as
|
|
140
|
+
* `localPendResult`. `CoordinatorRepo.commit` uses a retained refusal to detect a rival's
|
|
141
|
+
* win swallowed by the member-side ahead-divergence tolerance, instead of fabricating a
|
|
142
|
+
* success no member durably stored.
|
|
143
|
+
*/
|
|
144
|
+
localCommitResult?: CommitResult;
|
|
119
145
|
}>;
|
|
120
146
|
/**
|
|
121
147
|
* Executes the full transaction process
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-coordinator.d.ts","sourceRoot":"","sources":["../../../src/repo/cluster-coordinator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAgB,cAAc,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"cluster-coordinator.d.ts","sourceRoot":"","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