@optimystic/db-core 1.9.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cohort-topic/addressing.d.ts +46 -6
- package/dist/src/cohort-topic/addressing.d.ts.map +1 -1
- package/dist/src/cohort-topic/addressing.js +58 -18
- package/dist/src/cohort-topic/addressing.js.map +1 -1
- package/dist/src/cohort-topic/member-engine.d.ts +21 -1
- package/dist/src/cohort-topic/member-engine.d.ts.map +1 -1
- package/dist/src/cohort-topic/member-engine.js +39 -9
- package/dist/src/cohort-topic/member-engine.js.map +1 -1
- package/dist/src/cohort-topic/membership/publisher.js +1 -1
- package/dist/src/cohort-topic/membership/publisher.js.map +1 -1
- package/dist/src/cohort-topic/membership/source.d.ts +4 -0
- package/dist/src/cohort-topic/membership/source.d.ts.map +1 -1
- package/dist/src/cohort-topic/membership/source.js +4 -0
- package/dist/src/cohort-topic/membership/source.js.map +1 -1
- package/dist/src/cohort-topic/membership/verifier.d.ts +51 -9
- package/dist/src/cohort-topic/membership/verifier.d.ts.map +1 -1
- package/dist/src/cohort-topic/membership/verifier.js +138 -46
- package/dist/src/cohort-topic/membership/verifier.js.map +1 -1
- package/dist/src/cohort-topic/ports.d.ts +85 -14
- package/dist/src/cohort-topic/ports.d.ts.map +1 -1
- package/dist/src/cohort-topic/ports.js +1 -1
- package/dist/src/cohort-topic/ports.js.map +1 -1
- package/dist/src/cohort-topic/promotion.d.ts +3 -2
- package/dist/src/cohort-topic/promotion.d.ts.map +1 -1
- package/dist/src/cohort-topic/promotion.js +15 -3
- package/dist/src/cohort-topic/promotion.js.map +1 -1
- package/dist/src/cohort-topic/registration/renewal.d.ts +26 -5
- package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -1
- package/dist/src/cohort-topic/registration/renewal.js +71 -21
- package/dist/src/cohort-topic/registration/renewal.js.map +1 -1
- package/dist/src/cohort-topic/service.d.ts +34 -2
- package/dist/src/cohort-topic/service.d.ts.map +1 -1
- package/dist/src/cohort-topic/service.js +86 -28
- package/dist/src/cohort-topic/service.js.map +1 -1
- package/dist/src/cohort-topic/sig/payloads.d.ts +5 -1
- package/dist/src/cohort-topic/sig/payloads.d.ts.map +1 -1
- package/dist/src/cohort-topic/sig/payloads.js +6 -1
- package/dist/src/cohort-topic/sig/payloads.js.map +1 -1
- package/dist/src/cohort-topic/sig/threshold.d.ts +29 -4
- package/dist/src/cohort-topic/sig/threshold.d.ts.map +1 -1
- package/dist/src/cohort-topic/sig/threshold.js +39 -7
- package/dist/src/cohort-topic/sig/threshold.js.map +1 -1
- package/dist/src/cohort-topic/walk.d.ts +19 -4
- package/dist/src/cohort-topic/walk.d.ts.map +1 -1
- package/dist/src/cohort-topic/walk.js +29 -6
- package/dist/src/cohort-topic/walk.js.map +1 -1
- package/dist/src/cohort-topic/willingness.d.ts +17 -1
- package/dist/src/cohort-topic/willingness.d.ts.map +1 -1
- package/dist/src/cohort-topic/willingness.js +18 -3
- package/dist/src/cohort-topic/willingness.js.map +1 -1
- package/dist/src/cohort-topic/wire/index.d.ts +1 -1
- package/dist/src/cohort-topic/wire/index.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/index.js +1 -1
- package/dist/src/cohort-topic/wire/index.js.map +1 -1
- package/dist/src/cohort-topic/wire/payloads.d.ts +14 -0
- package/dist/src/cohort-topic/wire/payloads.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/payloads.js +20 -0
- package/dist/src/cohort-topic/wire/payloads.js.map +1 -1
- package/dist/src/cohort-topic/wire/primitives.d.ts +8 -0
- package/dist/src/cohort-topic/wire/primitives.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/primitives.js +24 -4
- package/dist/src/cohort-topic/wire/primitives.js.map +1 -1
- package/dist/src/cohort-topic/wire/types.d.ts +37 -0
- package/dist/src/cohort-topic/wire/types.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.d.ts +9 -1
- package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.js +23 -4
- package/dist/src/cohort-topic/wire/validate.js.map +1 -1
- package/dist/src/reactivity/config.d.ts +9 -10
- package/dist/src/reactivity/config.d.ts.map +1 -1
- package/dist/src/reactivity/config.js +9 -9
- package/dist/src/reactivity/config.js.map +1 -1
- package/dist/src/reactivity/index.d.ts +4 -3
- package/dist/src/reactivity/index.d.ts.map +1 -1
- package/dist/src/reactivity/index.js +4 -3
- package/dist/src/reactivity/index.js.map +1 -1
- package/dist/src/reactivity/rotation.d.ts +73 -57
- package/dist/src/reactivity/rotation.d.ts.map +1 -1
- package/dist/src/reactivity/rotation.js +54 -54
- package/dist/src/reactivity/rotation.js.map +1 -1
- package/dist/src/reactivity/subscription.d.ts +12 -9
- package/dist/src/reactivity/subscription.d.ts.map +1 -1
- package/dist/src/reactivity/subscription.js +9 -6
- package/dist/src/reactivity/subscription.js.map +1 -1
- package/dist/src/reactivity/topic-anchor.d.ts +36 -31
- package/dist/src/reactivity/topic-anchor.d.ts.map +1 -1
- package/dist/src/reactivity/topic-anchor.js +41 -39
- package/dist/src/reactivity/topic-anchor.js.map +1 -1
- package/dist/src/reactivity/verify.d.ts +26 -9
- package/dist/src/reactivity/verify.d.ts.map +1 -1
- package/dist/src/reactivity/verify.js +26 -11
- package/dist/src/reactivity/verify.js.map +1 -1
- package/dist/src/reactivity/wire.d.ts +1 -1
- package/dist/src/reactivity/wire.d.ts.map +1 -1
- package/dist/src/transactor/change-notifier.d.ts +1 -1
- package/package.json +1 -1
- package/src/cohort-topic/addressing.ts +83 -23
- package/src/cohort-topic/member-engine.ts +77 -8
- package/src/cohort-topic/membership/publisher.ts +1 -1
- package/src/cohort-topic/membership/source.ts +4 -0
- package/src/cohort-topic/membership/verifier.ts +169 -51
- package/src/cohort-topic/ports.ts +87 -15
- package/src/cohort-topic/promotion.ts +15 -3
- package/src/cohort-topic/registration/renewal.ts +87 -24
- package/src/cohort-topic/service.ts +157 -35
- package/src/cohort-topic/sig/payloads.ts +7 -2
- package/src/cohort-topic/sig/threshold.ts +41 -7
- package/src/cohort-topic/walk.ts +46 -9
- package/src/cohort-topic/willingness.ts +34 -3
- package/src/cohort-topic/wire/index.ts +1 -0
- package/src/cohort-topic/wire/payloads.ts +21 -0
- package/src/cohort-topic/wire/primitives.ts +26 -4
- package/src/cohort-topic/wire/types.ts +37 -0
- package/src/cohort-topic/wire/validate.ts +26 -3
- package/src/reactivity/config.ts +10 -10
- package/src/reactivity/index.ts +4 -3
- package/src/reactivity/rotation.ts +86 -78
- package/src/reactivity/subscription.ts +12 -9
- package/src/reactivity/topic-anchor.ts +42 -45
- package/src/reactivity/verify.ts +36 -17
- package/src/reactivity/wire.ts +1 -1
- package/src/transactor/change-notifier.ts +1 -1
|
@@ -22,10 +22,11 @@ import { createTierAddressing } from "./addressing.js";
|
|
|
22
22
|
import { makeDMaxComputer } from "./dmax.js";
|
|
23
23
|
import { DEFAULT_FANOUT } from "./addressing.js";
|
|
24
24
|
import { createWalkEngine } from "./walk.js";
|
|
25
|
-
import { createRenewalParticipant } from "./registration/renewal.js";
|
|
25
|
+
import { createRenewalParticipant, } from "./registration/renewal.js";
|
|
26
26
|
import { DEFAULT_TTL_MS } from "./registration/types.js";
|
|
27
27
|
import { recordKey } from "./registration/bytes.js";
|
|
28
28
|
import { bytesToB64url, b64urlToBytes, decodeRenewReplyV1, encodeCohortMessage } from "./wire/codec.js";
|
|
29
|
+
import { MAX_ROOT_KEY_BYTES } from "./wire/validate.js";
|
|
29
30
|
/** Thrown when the substrate cannot place a registration right now; carries the back-off delay. */
|
|
30
31
|
export class CohortBackoffError extends Error {
|
|
31
32
|
afterMs;
|
|
@@ -44,7 +45,7 @@ class WalkRegisterService {
|
|
|
44
45
|
clock;
|
|
45
46
|
ttl;
|
|
46
47
|
maxMessageBytes;
|
|
47
|
-
/** Live
|
|
48
|
+
/** Live renewals, keyed by `(topicId, participantId)` so renew/withdraw/moveRoot find their handle. */
|
|
48
49
|
renewals = new Map();
|
|
49
50
|
participantId;
|
|
50
51
|
constructor(deps) {
|
|
@@ -72,30 +73,45 @@ class WalkRegisterService {
|
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
async register(req) {
|
|
75
|
-
|
|
76
|
+
assertRootKey(req.rootKey);
|
|
77
|
+
const outcome = await this.walk.register(req.topicId, req.tier, req.appPayload, { rootKey: req.rootKey });
|
|
76
78
|
return this.handleFromOutcome(req, outcome);
|
|
77
79
|
}
|
|
78
|
-
async lookup(topicId, tier) {
|
|
80
|
+
async lookup(topicId, tier, rootKey) {
|
|
81
|
+
assertRootKey(rootKey);
|
|
79
82
|
// A read-only probe: it walks to the responsible cohort exactly as a register would and returns the
|
|
80
83
|
// same cohort snapshot, but admits NOTHING — no soft-state record, no arrival, no promotion trigger,
|
|
81
84
|
// no topic-budget touch, and never a cold-start instantiation. A topic served nowhere resolves to a
|
|
82
85
|
// `CohortBackoffError` (the probe never bootstraps a cold root), so a lookup leaves no throwaway
|
|
83
86
|
// registration behind to TTL-expire (§Application policies; the lookup-as-register interim is gone).
|
|
84
|
-
const outcome = await this.walk.register(topicId, tier, undefined, { probe: true });
|
|
87
|
+
const outcome = await this.walk.register(topicId, tier, undefined, { probe: true, rootKey });
|
|
85
88
|
if (outcome.kind !== "accepted") {
|
|
86
89
|
throw new CohortBackoffError(outcome.kind === "retry_later" ? outcome.afterMs : 0);
|
|
87
90
|
}
|
|
88
|
-
return this.hintFromReply(topicId, tier, outcome
|
|
91
|
+
return this.hintFromReply(topicId, tier, outcome, rootKey);
|
|
89
92
|
}
|
|
90
93
|
async renew(handle) {
|
|
91
94
|
// Act only if this handle is still the live entry. A stale handle (superseded by a second
|
|
92
95
|
// register() for the same pair) must not drive the new registration's ping loop, and a
|
|
93
96
|
// withdrawn handle must not silently re-start it.
|
|
94
|
-
|
|
97
|
+
const live = this.liveRenewal(handle);
|
|
98
|
+
if (live === undefined) {
|
|
95
99
|
return;
|
|
96
100
|
}
|
|
97
101
|
await handle.renewal.pingLoop();
|
|
98
|
-
this.syncHandle(handle);
|
|
102
|
+
this.syncHandle(handle, live.landing);
|
|
103
|
+
}
|
|
104
|
+
moveRoot(handle, rootKey) {
|
|
105
|
+
assertRootKey(rootKey);
|
|
106
|
+
if (handle.rootKey === undefined) {
|
|
107
|
+
throw new Error("cohort-topic: moveRoot needs a root-placed registration; this one was registered without a rootKey");
|
|
108
|
+
}
|
|
109
|
+
const live = this.liveRenewal(handle);
|
|
110
|
+
if (live === undefined) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
live.root.key = rootKey;
|
|
114
|
+
handle.rootKey = rootKey;
|
|
99
115
|
}
|
|
100
116
|
async withdraw(handle) {
|
|
101
117
|
// Two halves: (1) drop the handle from the live set so further renew() pings no-op (see renew()),
|
|
@@ -103,17 +119,16 @@ class WalkRegisterService {
|
|
|
103
119
|
// primary so the cohort frees the record immediately instead of holding it for up to a full TTL.
|
|
104
120
|
// The delete happens FIRST so a concurrent renew() already no-ops before the tombstone is sent. If
|
|
105
121
|
// the tombstone send fails (primary unreachable), the cohort soft-state TTL-expires as the
|
|
106
|
-
// fallback — withdraw never throws on a transport failure. Idempotent: a second withdraw finds
|
|
107
|
-
//
|
|
122
|
+
// fallback — withdraw never throws on a transport failure. Idempotent: a second withdraw finds no
|
|
123
|
+
// live entry for the handle and no-ops.
|
|
108
124
|
// Guard: act only if this handle is still the live entry. A stale handle must not evict the
|
|
109
125
|
// new registration or send a tombstone on its behalf.
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
if (renewal !== handle.renewal) {
|
|
126
|
+
const live = this.liveRenewal(handle);
|
|
127
|
+
if (live === undefined) {
|
|
113
128
|
return;
|
|
114
129
|
}
|
|
115
|
-
this.renewals.delete(
|
|
116
|
-
await renewal.withdraw();
|
|
130
|
+
this.renewals.delete(recordKey(handle.topicId, this.participantId));
|
|
131
|
+
await live.renewal.withdraw();
|
|
117
132
|
}
|
|
118
133
|
cohortGossip() {
|
|
119
134
|
return this.deps.gossipBus;
|
|
@@ -126,10 +141,15 @@ class WalkRegisterService {
|
|
|
126
141
|
if (outcome.kind !== "accepted") {
|
|
127
142
|
throw new CohortBackoffError(outcome.kind === "retry_later" ? outcome.afterMs : 0);
|
|
128
143
|
}
|
|
129
|
-
const hint = this.hintFromReply(req.topicId, req.tier, outcome.
|
|
144
|
+
const hint = this.hintFromReply(req.topicId, req.tier, outcome, req.rootKey);
|
|
130
145
|
const renewal = this.startRenewal(req, hint, outcome.correlationId);
|
|
131
146
|
return { ...hint, renewal };
|
|
132
147
|
}
|
|
148
|
+
/** The live renewal `handle` drives, or `undefined` when a later register displaced it or it was withdrawn. */
|
|
149
|
+
liveRenewal(handle) {
|
|
150
|
+
const live = this.renewals.get(recordKey(handle.topicId, this.participantId));
|
|
151
|
+
return live?.renewal === handle.renewal ? live : undefined;
|
|
152
|
+
}
|
|
133
153
|
startRenewal(req, hint, correlationId) {
|
|
134
154
|
const ttl = req.ttl ?? this.ttl;
|
|
135
155
|
const initial = {
|
|
@@ -143,7 +163,9 @@ class WalkRegisterService {
|
|
|
143
163
|
ttl,
|
|
144
164
|
appState: req.appPayload,
|
|
145
165
|
};
|
|
146
|
-
const
|
|
166
|
+
const root = { key: req.rootKey };
|
|
167
|
+
const landing = { treeTier: hint.treeTier, cohortMembers: hint.cohortMembers, topicTraffic: hint.topicTraffic };
|
|
168
|
+
const transport = this.renewalTransport(req, root, landing);
|
|
147
169
|
const renewal = createRenewalParticipant(initial, {
|
|
148
170
|
transport,
|
|
149
171
|
clock: this.clock,
|
|
@@ -158,41 +180,62 @@ class WalkRegisterService {
|
|
|
158
180
|
correlationId,
|
|
159
181
|
initialCohortEpoch: hint.cohortEpoch,
|
|
160
182
|
});
|
|
161
|
-
// NOTE: a second register() for the same (topicId, participantId)
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
|
|
183
|
+
// NOTE: accepted — a second register() for the same (topicId, participantId) displaces the first:
|
|
184
|
+
// renew()/withdraw()/moveRoot() on the displaced handle no-op (identity guard), and NO tombstone is
|
|
185
|
+
// sent for the displaced record, by design. A participant re-registers at a moved root while its old
|
|
186
|
+
// record still lives at the old one, and a machine in both roots' storage groups holds both; a
|
|
187
|
+
// tombstone resolves through the host's `findHolder`, which picks the newer record there, so it would
|
|
188
|
+
// evict the live registration. The displaced record expires by TTL at its cohort.
|
|
189
|
+
this.renewals.set(recordKey(req.topicId, this.participantId), { renewal, root, landing });
|
|
167
190
|
return renewal;
|
|
168
191
|
}
|
|
169
|
-
/**
|
|
170
|
-
|
|
192
|
+
/**
|
|
193
|
+
* Renewal transport: dial the cached primary directly; a full failure re-runs the register walk. The
|
|
194
|
+
* re-walk reads the root key from `root` when it runs, so after {@link CohortTopicService.moveRoot} it
|
|
195
|
+
* lands at the topic's current root rather than the one it registered under. An accepted re-walk records
|
|
196
|
+
* its tree tier, cohort and traffic in `landing` and hands its assignment to the participant to adopt.
|
|
197
|
+
*/
|
|
198
|
+
renewalTransport(req, root, landing) {
|
|
171
199
|
return {
|
|
172
200
|
send: async (target, msg) => {
|
|
173
201
|
const raw = await this.deps.router.dialMember({ id: target }, encodeCohortMessage(msg, this.maxMessageBytes));
|
|
174
202
|
return decodeRenewReplyV1(raw, this.maxMessageBytes);
|
|
175
203
|
},
|
|
176
204
|
relookup: async () => {
|
|
177
|
-
|
|
205
|
+
// NOTE: re-sends the first registration's `appPayload` (for a collection watch, its `tailIdAtAttach`
|
|
206
|
+
// and `lastKnownRev`). No cohort reads those fields off a held record today; if one ever does, the
|
|
207
|
+
// re-walk needs a fresh payload from the registering caller.
|
|
208
|
+
const outcome = await this.walk.register(req.topicId, req.tier, req.appPayload, { rootKey: root.key });
|
|
209
|
+
if (outcome.kind !== "accepted") {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
const hint = this.hintFromReply(req.topicId, req.tier, outcome, root.key);
|
|
213
|
+
landing.treeTier = hint.treeTier;
|
|
214
|
+
landing.cohortMembers = hint.cohortMembers;
|
|
215
|
+
landing.topicTraffic = hint.topicTraffic;
|
|
216
|
+
return { primary: hint.primary, backups: hint.backups, cohortEpoch: hint.cohortEpoch, correlationId: outcome.correlationId };
|
|
178
217
|
},
|
|
179
218
|
};
|
|
180
219
|
}
|
|
181
|
-
hintFromReply(topicId, tier,
|
|
220
|
+
hintFromReply(topicId, tier, outcome, rootKey) {
|
|
221
|
+
const reply = outcome.reply;
|
|
182
222
|
if (reply.primary === undefined || reply.cohortEpoch === undefined) {
|
|
183
223
|
throw new CohortBackoffError(0);
|
|
184
224
|
}
|
|
185
225
|
return {
|
|
186
226
|
topicId,
|
|
187
227
|
tier,
|
|
228
|
+
treeTier: outcome.treeTier,
|
|
188
229
|
primary: b64urlToBytes(reply.primary),
|
|
189
230
|
backups: (reply.backups ?? []).map(b64urlToBytes),
|
|
190
231
|
cohortEpoch: b64urlToBytes(reply.cohortEpoch),
|
|
191
232
|
cohortMembers: (reply.cohortMembers ?? []).map(b64urlToBytes),
|
|
192
233
|
topicTraffic: reply.topicTraffic,
|
|
234
|
+
...(rootKey === undefined ? {} : { rootKey }),
|
|
193
235
|
};
|
|
194
236
|
}
|
|
195
|
-
|
|
237
|
+
/** Copy the registration's current placement onto `handle`: the participant's record, and the last walk's landing. */
|
|
238
|
+
syncHandle(handle, landing) {
|
|
196
239
|
const rec = handle.renewal.record;
|
|
197
240
|
handle.primary = rec.primary;
|
|
198
241
|
handle.backups = [...rec.backups];
|
|
@@ -200,6 +243,9 @@ class WalkRegisterService {
|
|
|
200
243
|
if (epoch !== undefined) {
|
|
201
244
|
handle.cohortEpoch = epoch;
|
|
202
245
|
}
|
|
246
|
+
handle.treeTier = landing.treeTier;
|
|
247
|
+
handle.cohortMembers = landing.cohortMembers;
|
|
248
|
+
handle.topicTraffic = landing.topicTraffic;
|
|
203
249
|
}
|
|
204
250
|
/** The per-probe `RegisterV1` builder: stamps participant coord/ttl/correlation and signs. */
|
|
205
251
|
messageFactory() {
|
|
@@ -246,6 +292,9 @@ class WalkRegisterService {
|
|
|
246
292
|
if (params.appPayload !== undefined) {
|
|
247
293
|
body.appPayload = bytesToB64url(params.appPayload);
|
|
248
294
|
}
|
|
295
|
+
if (params.rootKey !== undefined) {
|
|
296
|
+
body.rootKey = bytesToB64url(params.rootKey);
|
|
297
|
+
}
|
|
249
298
|
return { ...body, signature: await this.deps.signer.signRegister(body) };
|
|
250
299
|
},
|
|
251
300
|
};
|
|
@@ -256,6 +305,15 @@ class WalkRegisterService {
|
|
|
256
305
|
return bytesToB64url(randomBytes(16));
|
|
257
306
|
}
|
|
258
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Reject a root key no cohort would accept. The wire validator refuses an empty or over-long `rootKey`,
|
|
310
|
+
* so sending one would only surface as a remote decode failure; it is a caller error, raised here.
|
|
311
|
+
*/
|
|
312
|
+
function assertRootKey(rootKey) {
|
|
313
|
+
if (rootKey !== undefined && (rootKey.length === 0 || rootKey.length > MAX_ROOT_KEY_BYTES)) {
|
|
314
|
+
throw new RangeError(`cohort-topic: rootKey must be 1..${MAX_ROOT_KEY_BYTES} bytes, got ${rootKey.length}`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
259
317
|
/** Build the participant-facing {@link CohortTopicService} over the injected ports. */
|
|
260
318
|
export function createCohortTopicService(deps) {
|
|
261
319
|
return new WalkRegisterService(deps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/cohort-topic/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAuB,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAqB,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAkE,MAAM,WA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able = Pick<DemotionNoticeV1, "topicId" | "tier" | "pare
|
|
|
31
31
|
/** Canonical signed byte image of a demotion notice. `cohortEpoch` stays last (the `/sign` endorser reads it positionally). */
|
|
32
32
|
export declare function demotionNoticeSigningPayload(n: DemotionSignable): Uint8Array;
|
|
33
33
|
/** Fields of a `ChildLinkV1` covered by the child cohort's threshold signature. */
|
|
34
|
-
export type ChildLinkSignable = Pick<ChildLinkV1, "topicId" | "childCohortCoord" | "childParticipantCoord" | "childTier" | "tier" | "effectiveAt" | "cohortEpoch">;
|
|
34
|
+
export type ChildLinkSignable = Pick<ChildLinkV1, "topicId" | "childCohortCoord" | "childParticipantCoord" | "childTier" | "tier" | "effectiveAt" | "cohortEpoch" | "rootKey">;
|
|
35
35
|
/**
|
|
36
36
|
* Canonical signed byte image of a child-link frame. `cohortEpoch` stays **last** so the `/sign` endorser
|
|
37
37
|
* (`handleSignRequest`) reads the embedded epoch positionally as `image[image.length - 1]`, exactly as it
|
|
38
38
|
* does for a promotion / demotion notice.
|
|
39
|
+
*
|
|
40
|
+
* `rootKey` (a tier-1 child of a root-placed topic) is covered only when present, and is inserted **before**
|
|
41
|
+
* `cohortEpoch` for that same reason. A link without one keeps the eight-element image unchanged; one
|
|
42
|
+
* with it signs nine elements, so stripping or swapping the key fails verification.
|
|
39
43
|
*/
|
|
40
44
|
export declare function childLinkSigningPayload(n: ChildLinkSignable): Uint8Array;
|
|
41
45
|
//# sourceMappingURL=payloads.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloads.d.ts","sourceRoot":"","sources":["../../../../src/cohort-topic/sig/payloads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"payloads.d.ts","sourceRoot":"","sources":["../../../../src/cohort-topic/sig/payloads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAI3G,gIAAgI;AAChI,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,gBAAgB,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,GAAG,cAAc,CAAC,CAAC;AAExH,+DAA+D;AAC/D,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,sBAAsB,GAAG,UAAU,CAErF;AAED,0EAA0E;AAC1E,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,aAAa,GAAG,aAAa,CAAC,CAAC;AAE3I,gIAAgI;AAChI,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,iBAAiB,GAAG,UAAU,CAE9E;AAED,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,MAAM,GAAG,mBAAmB,GAAG,aAAa,GAAG,aAAa,GAAG,aAAa,CAAC,CAAC;AAEhJ,+HAA+H;AAC/H,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,gBAAgB,GAAG,UAAU,CAE5E;AAED,mFAAmF;AACnF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,kBAAkB,GAAG,uBAAuB,GAAG,WAAW,GAAG,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,SAAS,CAAC,CAAC;AAE/K;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,iBAAiB,GAAG,UAAU,CAExE"}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* canonical signed bytes, acceptable pre-release (no deployed nodes speak this protocol, so there is no
|
|
18
18
|
* version to negotiate).
|
|
19
19
|
*/
|
|
20
|
+
import { presentOnly } from "../wire/payloads.js";
|
|
20
21
|
const utf8 = new TextEncoder();
|
|
21
22
|
/** Canonical signed byte image of a membership certificate. */
|
|
22
23
|
export function membershipCertSigningPayload(cert) {
|
|
@@ -34,8 +35,12 @@ export function demotionNoticeSigningPayload(n) {
|
|
|
34
35
|
* Canonical signed byte image of a child-link frame. `cohortEpoch` stays **last** so the `/sign` endorser
|
|
35
36
|
* (`handleSignRequest`) reads the embedded epoch positionally as `image[image.length - 1]`, exactly as it
|
|
36
37
|
* does for a promotion / demotion notice.
|
|
38
|
+
*
|
|
39
|
+
* `rootKey` (a tier-1 child of a root-placed topic) is covered only when present, and is inserted **before**
|
|
40
|
+
* `cohortEpoch` for that same reason. A link without one keeps the eight-element image unchanged; one
|
|
41
|
+
* with it signs nine elements, so stripping or swapping the key fails verification.
|
|
37
42
|
*/
|
|
38
43
|
export function childLinkSigningPayload(n) {
|
|
39
|
-
return utf8.encode(JSON.stringify(["ChildLinkV1", n.topicId, n.childCohortCoord, n.childParticipantCoord, n.childTier, n.tier, n.effectiveAt, n.cohortEpoch]));
|
|
44
|
+
return utf8.encode(JSON.stringify(["ChildLinkV1", n.topicId, n.childCohortCoord, n.childParticipantCoord, n.childTier, n.tier, n.effectiveAt, ...presentOnly(n.rootKey), n.cohortEpoch]));
|
|
40
45
|
}
|
|
41
46
|
//# sourceMappingURL=payloads.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloads.js","sourceRoot":"","sources":["../../../../src/cohort-topic/sig/payloads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"payloads.js","sourceRoot":"","sources":["../../../../src/cohort-topic/sig/payloads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;AAK/B,+DAA+D;AAC/D,MAAM,UAAU,4BAA4B,CAAC,IAA4B;IACxE,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CA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` must be a distinct `≥ minSigs` subset of the certificate's `members`, *and*
|
|
12
12
|
* the signature must verify against the payload. Either failure → not verified.
|
|
13
13
|
*/
|
|
14
|
-
import type { ICohortThresholdCrypto } from "../ports.js";
|
|
14
|
+
import type { ICohortThresholdCrypto, RootPlacement } from "../ports.js";
|
|
15
15
|
import type { MembershipCertV1 } from "../wire/types.js";
|
|
16
|
-
/** Default cohort-signature threshold, `k − x` (see §Configuration). */
|
|
16
|
+
/** Default cohort-signature threshold, `k − x` (see §Configuration). The rule for every coord that is not root-placed. */
|
|
17
17
|
export declare const DEFAULT_MIN_SIGS = 14;
|
|
18
|
+
/**
|
|
19
|
+
* Build the {@link RootPlacement} for a root-placed cohort from this node's own quorum ratio. A ratio
|
|
20
|
+
* outside `(0, 1]` (or not a number) is a configuration error and throws here, at construction, so
|
|
21
|
+
* verification never has to judge a malformed rule. `rootKey` is the routing key the root coordinate is
|
|
22
|
+
* the hash of, when the caller knows it (see {@link RootPlacement.rootKey}); it is carried, never checked
|
|
23
|
+
* here — the anchor that uses it checks that it hashes to the coordinate being judged.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createRootPlacement(quorumRatio: number, rootKey?: Uint8Array): RootPlacement;
|
|
26
|
+
/**
|
|
27
|
+
* Signature threshold of a root-placed cohort of `memberCount` members: `ceil(memberCount × quorumRatio)`.
|
|
28
|
+
*
|
|
29
|
+
* This is the formula `captureCommitCert` (`packages/db-p2p/src/cluster/cluster-repo.ts`) applies to a
|
|
30
|
+
* storage group's commit certificate — `ceil(|group| × superMajorityThreshold)` — written the same way on
|
|
31
|
+
* purpose (same multiplication, same rounding), so a commit certificate and a verifier given the same ratio
|
|
32
|
+
* agree on the threshold by construction. One member needs 1; four members at `0.75` need 3.
|
|
33
|
+
*
|
|
34
|
+
* The floor of 1 only matters for an empty member list, where the formula would yield 0 and "no signers"
|
|
35
|
+
* would count as a quorum; with it, a cert naming no members can never verify.
|
|
36
|
+
*/
|
|
37
|
+
export declare function rootPlacedMinSigs(memberCount: number, placement: RootPlacement): number;
|
|
18
38
|
/** Threshold signer/verifier over the injected cohort crypto. Peer ids are raw bytes. */
|
|
19
39
|
export interface CohortSigner {
|
|
20
40
|
/** Assemble a cohort threshold signature over `payload` (collects `minSigs` signers). */
|
|
@@ -28,6 +48,11 @@ export interface CohortSigner {
|
|
|
28
48
|
*/
|
|
29
49
|
verifyThreshold(payload: Uint8Array, sig: Uint8Array, signers: readonly Uint8Array[], cert: MembershipCertV1, minSigs: number): boolean;
|
|
30
50
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Build a {@link CohortSigner} over the FRET-backed (in db-p2p) threshold crypto. `minSigs` is the assembly
|
|
53
|
+
* threshold: a number for a cohort whose threshold is fixed (the node-wide `k − x`), or a function read at
|
|
54
|
+
* each signing for one whose threshold follows its member count (a root-placed cohort under
|
|
55
|
+
* {@link rootPlacedMinSigs}). Verification takes its threshold as an argument either way.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createCohortSigner(crypto: ICohortThresholdCrypto, minSigs?: number | (() => number)): CohortSigner;
|
|
33
58
|
//# sourceMappingURL=threshold.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threshold.d.ts","sourceRoot":"","sources":["../../../../src/cohort-topic/sig/threshold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"threshold.d.ts","sourceRoot":"","sources":["../../../../src/cohort-topic/sig/threshold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,0HAA0H;AAC1H,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,aAAa,CAK5F;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,MAAM,CAEvF;AAED,yFAAyF;AACzF,MAAM,WAAW,YAAY;IAC5B,yFAAyF;IACzF,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,UAAU,CAAC;QAAC,OAAO,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC,CAAC;IACjG;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,UAAU,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CACxI;AA8BD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,GAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAoB,GAAG,YAAY,CAEpI"}
|
|
@@ -12,17 +12,44 @@
|
|
|
12
12
|
* the signature must verify against the payload. Either failure → not verified.
|
|
13
13
|
*/
|
|
14
14
|
import { bytesToB64url } from "../wire/codec.js";
|
|
15
|
-
/** Default cohort-signature threshold, `k − x` (see §Configuration). */
|
|
15
|
+
/** Default cohort-signature threshold, `k − x` (see §Configuration). The rule for every coord that is not root-placed. */
|
|
16
16
|
export const DEFAULT_MIN_SIGS = 14;
|
|
17
|
+
/**
|
|
18
|
+
* Build the {@link RootPlacement} for a root-placed cohort from this node's own quorum ratio. A ratio
|
|
19
|
+
* outside `(0, 1]` (or not a number) is a configuration error and throws here, at construction, so
|
|
20
|
+
* verification never has to judge a malformed rule. `rootKey` is the routing key the root coordinate is
|
|
21
|
+
* the hash of, when the caller knows it (see {@link RootPlacement.rootKey}); it is carried, never checked
|
|
22
|
+
* here — the anchor that uses it checks that it hashes to the coordinate being judged.
|
|
23
|
+
*/
|
|
24
|
+
export function createRootPlacement(quorumRatio, rootKey) {
|
|
25
|
+
if (!(quorumRatio > 0 && quorumRatio <= 1)) {
|
|
26
|
+
throw new RangeError(`root placement quorumRatio must be in (0, 1], got ${quorumRatio}`);
|
|
27
|
+
}
|
|
28
|
+
return rootKey === undefined ? { quorumRatio } : { quorumRatio, rootKey };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Signature threshold of a root-placed cohort of `memberCount` members: `ceil(memberCount × quorumRatio)`.
|
|
32
|
+
*
|
|
33
|
+
* This is the formula `captureCommitCert` (`packages/db-p2p/src/cluster/cluster-repo.ts`) applies to a
|
|
34
|
+
* storage group's commit certificate — `ceil(|group| × superMajorityThreshold)` — written the same way on
|
|
35
|
+
* purpose (same multiplication, same rounding), so a commit certificate and a verifier given the same ratio
|
|
36
|
+
* agree on the threshold by construction. One member needs 1; four members at `0.75` need 3.
|
|
37
|
+
*
|
|
38
|
+
* The floor of 1 only matters for an empty member list, where the formula would yield 0 and "no signers"
|
|
39
|
+
* would count as a quorum; with it, a cert naming no members can never verify.
|
|
40
|
+
*/
|
|
41
|
+
export function rootPlacedMinSigs(memberCount, placement) {
|
|
42
|
+
return Math.max(1, Math.ceil(memberCount * placement.quorumRatio));
|
|
43
|
+
}
|
|
17
44
|
class CryptoCohortSigner {
|
|
18
45
|
crypto;
|
|
19
|
-
|
|
20
|
-
constructor(crypto,
|
|
46
|
+
minSigsNow;
|
|
47
|
+
constructor(crypto, minSigsNow) {
|
|
21
48
|
this.crypto = crypto;
|
|
22
|
-
this.
|
|
49
|
+
this.minSigsNow = minSigsNow;
|
|
23
50
|
}
|
|
24
51
|
thresholdSign(payload) {
|
|
25
|
-
return this.crypto.assemble(payload, this.
|
|
52
|
+
return this.crypto.assemble(payload, this.minSigsNow());
|
|
26
53
|
}
|
|
27
54
|
verifyThreshold(payload, sig, signers, cert, minSigs) {
|
|
28
55
|
if (signers.length < minSigs) {
|
|
@@ -44,8 +71,13 @@ class CryptoCohortSigner {
|
|
|
44
71
|
return this.crypto.verify(payload, sig, signers);
|
|
45
72
|
}
|
|
46
73
|
}
|
|
47
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Build a {@link CohortSigner} over the FRET-backed (in db-p2p) threshold crypto. `minSigs` is the assembly
|
|
76
|
+
* threshold: a number for a cohort whose threshold is fixed (the node-wide `k − x`), or a function read at
|
|
77
|
+
* each signing for one whose threshold follows its member count (a root-placed cohort under
|
|
78
|
+
* {@link rootPlacedMinSigs}). Verification takes its threshold as an argument either way.
|
|
79
|
+
*/
|
|
48
80
|
export function createCohortSigner(crypto, minSigs = DEFAULT_MIN_SIGS) {
|
|
49
|
-
return new CryptoCohortSigner(crypto, minSigs);
|
|
81
|
+
return new CryptoCohortSigner(crypto, typeof minSigs === "number" ? () => minSigs : minSigs);
|
|
50
82
|
}
|
|
51
83
|
//# sourceMappingURL=threshold.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threshold.js","sourceRoot":"","sources":["../../../../src/cohort-topic/sig/threshold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,
|
|
1
|
+
{"version":3,"file":"threshold.js","sourceRoot":"","sources":["../../../../src/cohort-topic/sig/threshold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,0HAA0H;AAC1H,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAmB,EAAE,OAAoB;IAC5E,IAAI,CAAC,CAAC,WAAW,GAAG,CAAC,IAAI,WAAW,IAAI,CAAC,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,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C,CAAC;YACd,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAC,CAAC,gDAAgD;YAC/D,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;CACD;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA8B,EAAE,UAAmC,gBAAgB;IACrH,OAAO,IAAI,kBAAkB,CAAC,MAAM,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAW,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AACtG,CAAC"}
|
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
* `afterMs` — which begins again at `d_max`, decorrelating retries across the ring (§Anti-flood
|
|
26
26
|
* claim 4: never re-hit the declined coord immediately).
|
|
27
27
|
*
|
|
28
|
+
* **Root-placed topics.** A walk given a `rootKey` (§Tier addressing → Root placement at a routing key)
|
|
29
|
+
* stamps it on every frame it builds and addresses its tier-0 step at `H(rootKey)` — delivered through
|
|
30
|
+
* {@link ITopicRouter.routeToRoot} when the router has it, else `routeAndAct` on the root key. Every other
|
|
31
|
+
* step, reply and back-off rule above is unchanged.
|
|
32
|
+
*
|
|
28
33
|
* This module is FRET-free: it drives the {@link ITopicRouter} port (db-p2p binds it to FRET's
|
|
29
34
|
* `RouteAndMaybeAct` / direct dial) and the {@link TierAddressing} math, and delegates building +
|
|
30
35
|
* signing the {@link RegisterV1} to the injected {@link RegisterMessageFactory} (participant identity
|
|
@@ -44,6 +49,8 @@ export interface AcceptedWalkOutcome {
|
|
|
44
49
|
* probe carries a distinct correlationId; this is the one the cohort admitted.
|
|
45
50
|
*/
|
|
46
51
|
readonly correlationId: string;
|
|
52
|
+
/** The tree tier `d` of the register frame the cohort accepted — where the registration landed. */
|
|
53
|
+
readonly treeTier: number;
|
|
47
54
|
}
|
|
48
55
|
/**
|
|
49
56
|
* The walk hit a `Promoted` redirect and the engine was configured **not** to follow it
|
|
@@ -75,6 +82,7 @@ export interface RegisterMessageFactory {
|
|
|
75
82
|
* (§Anti-DoS — a follow-on is gated identically to a bootstrap) via the injected builder seam before
|
|
76
83
|
* signing — keyed off `bootstrap`/`followOn`, so no extra parameter is needed (the walk decides both
|
|
77
84
|
* internally, not the application). `bootstrap`, `followOn`, and `probe` are mutually exclusive.
|
|
85
|
+
* A `rootKey` is stamped on the frame as `RegisterV1.rootKey` **before** signing, at every tier.
|
|
78
86
|
*/
|
|
79
87
|
build(params: {
|
|
80
88
|
topicId: Uint8Array;
|
|
@@ -86,8 +94,17 @@ export interface RegisterMessageFactory {
|
|
|
86
94
|
/** Read-only lookup probe: the factory stamps `RegisterV1.probe` and never mints cold-start evidence. */
|
|
87
95
|
probe: boolean;
|
|
88
96
|
appPayload?: Uint8Array;
|
|
97
|
+
/** Root key of a root-placed topic; absent for the default addressing. */
|
|
98
|
+
rootKey?: Uint8Array;
|
|
89
99
|
}): Promise<RegisterV1>;
|
|
90
100
|
}
|
|
101
|
+
/** Per-walk options for {@link WalkEngine.register}. */
|
|
102
|
+
export interface WalkOptions {
|
|
103
|
+
/** Read-only lookup: classify without admitting, and never cold-start. */
|
|
104
|
+
readonly probe?: boolean;
|
|
105
|
+
/** Root key of a root-placed topic: the walk's tier-0 step targets `H(rootKey)` and every frame carries the key. */
|
|
106
|
+
readonly rootKey?: Uint8Array;
|
|
107
|
+
}
|
|
91
108
|
export interface WalkConfig {
|
|
92
109
|
/** Cohort size requested from the router (`wantK`). Default 16. */
|
|
93
110
|
wantK?: number;
|
|
@@ -127,11 +144,9 @@ export interface WalkEngine {
|
|
|
127
144
|
* redirects outward. Resolves with the terminal {@link WalkOutcome}. With `opts.probe` the walk is a
|
|
128
145
|
* **read-only lookup**: identical routing discipline, but the terminal cohort classifies rather than
|
|
129
146
|
* admits and the root `no_state` branch backs off instead of issuing a `bootstrap: true` cold-start
|
|
130
|
-
* (a probe never instantiates a cold root).
|
|
147
|
+
* (a probe never instantiates a cold root). With `opts.rootKey` the topic is root-placed.
|
|
131
148
|
*/
|
|
132
|
-
register(topicId: Uint8Array, tier: number, appPayload?: Uint8Array, opts?:
|
|
133
|
-
probe?: boolean;
|
|
134
|
-
}): Promise<WalkOutcome>;
|
|
149
|
+
register(topicId: Uint8Array, tier: number, appPayload?: Uint8Array, opts?: WalkOptions): Promise<WalkOutcome>;
|
|
135
150
|
}
|
|
136
151
|
/** Build a {@link WalkEngine} over the injected router, addressing, `d_max`, and message factory. */
|
|
137
152
|
export declare function createWalkEngine(deps: WalkEngineDeps): WalkEngine;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../../src/cohort-topic/walk.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../../src/cohort-topic/walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAW,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9C,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEnE,sGAAsG;AACtG,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,mGAAmG;IACnG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IACnC,Q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;CACzB;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,cAAc,CAAC;IAC3B,mFAAmF;IACnF,IAAI,EAAE,YAAY,CAAC;IACnB,qEAAqE;IACrE,IAAI,EAAE,UAAU,CAAC;IACjB,iDAAiD;IACjD,OAAO,EAAE,sBAAsB,CAAC;IAChC,MAAM,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,kGAAkG;AAClG,MAAM,WAAW,UAAU;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/G;AAqMD,qGAAqG;AACrG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,UAAU,CAEjE"}
|
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
* `afterMs` — which begins again at `d_max`, decorrelating retries across the ring (§Anti-flood
|
|
26
26
|
* claim 4: never re-hit the declined coord immediately).
|
|
27
27
|
*
|
|
28
|
+
* **Root-placed topics.** A walk given a `rootKey` (§Tier addressing → Root placement at a routing key)
|
|
29
|
+
* stamps it on every frame it builds and addresses its tier-0 step at `H(rootKey)` — delivered through
|
|
30
|
+
* {@link ITopicRouter.routeToRoot} when the router has it, else `routeAndAct` on the root key. Every other
|
|
31
|
+
* step, reply and back-off rule above is unchanged.
|
|
32
|
+
*
|
|
28
33
|
* This module is FRET-free: it drives the {@link ITopicRouter} port (db-p2p binds it to FRET's
|
|
29
34
|
* `RouteAndMaybeAct` / direct dial) and the {@link TierAddressing} math, and delegates building +
|
|
30
35
|
* signing the {@link RegisterV1} to the injected {@link RegisterMessageFactory} (participant identity
|
|
@@ -64,6 +69,7 @@ class RouterWalkEngine {
|
|
|
64
69
|
const dMax = this.deps.dmax.dMax();
|
|
65
70
|
const maxSteps = this.configuredMaxSteps ?? 2 * (dMax + 2) + this.maxMemberRetries + 8;
|
|
66
71
|
const probe = opts?.probe ?? false;
|
|
72
|
+
const rootKey = opts?.rootKey;
|
|
67
73
|
let d = dMax;
|
|
68
74
|
let bootstrap = false;
|
|
69
75
|
let followOn = false;
|
|
@@ -85,20 +91,17 @@ class RouterWalkEngine {
|
|
|
85
91
|
// back-off rather than spin.
|
|
86
92
|
return { kind: "retry_later", afterMs: backoffRetryMs(0) };
|
|
87
93
|
}
|
|
88
|
-
const reg = await this.deps.factory.build({ topicId, tier, treeTier: d, bootstrap, followOn, probe, appPayload });
|
|
94
|
+
const reg = await this.deps.factory.build({ topicId, tier, treeTier: d, bootstrap, followOn, probe, appPayload, rootKey });
|
|
89
95
|
const activity = encodeCohortMessage(reg, this.maxMessageBytes);
|
|
90
96
|
const raw = dialTarget !== undefined
|
|
91
97
|
? await this.deps.router.dialMember(dialTarget, activity)
|
|
92
|
-
: await this.
|
|
93
|
-
wantK: this.wantK,
|
|
94
|
-
minSigs: this.minSigs,
|
|
95
|
-
});
|
|
98
|
+
: await this.routeToTier(d, topicId, rootKey, activity);
|
|
96
99
|
const reply = decodeRegisterReplyV1(raw, this.maxMessageBytes);
|
|
97
100
|
switch (reply.result) {
|
|
98
101
|
case "accepted": {
|
|
99
102
|
// Surface the accepted probe's correlationId so the participant's renewals can echo it
|
|
100
103
|
// (RenewV1 correlationId "matches original RegisterV1"). `reg` is the frame just admitted.
|
|
101
|
-
return { kind: "accepted", reply, correlationId: reg.correlationId };
|
|
104
|
+
return { kind: "accepted", reply, correlationId: reg.correlationId, treeTier: reg.treeTier };
|
|
102
105
|
}
|
|
103
106
|
case "no_state": {
|
|
104
107
|
// Step toward the root. The cohort served nothing here; no spatial sibling state.
|
|
@@ -202,6 +205,26 @@ class RouterWalkEngine {
|
|
|
202
205
|
}
|
|
203
206
|
}
|
|
204
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Route one probe to the cohort at tier `d`, on that tier's route key — the router hashes it once into
|
|
210
|
+
* `coord_d`. The root of a root-placed topic goes through the router's `routeToRoot` when it has one, so
|
|
211
|
+
* the frame reaches the root group by the rule that chose it; a router without it (a mock, an older
|
|
212
|
+
* binding) routes the same frame on the root key itself, which lands at the root coordinate `H(rootKey)`.
|
|
213
|
+
*
|
|
214
|
+
* NOTE: the fallback reaches the root coordinate by ring routing, which is the root group whenever the
|
|
215
|
+
* ring's nearest peers to `H(rootKey)` are the key network's storage group for that key. `routeToRoot`
|
|
216
|
+
* exists only because the two can differ on a ring shared with another network.
|
|
217
|
+
*/
|
|
218
|
+
routeToTier(d, topicId, rootKey, activity) {
|
|
219
|
+
const router = this.deps.router;
|
|
220
|
+
if (d === 0 && rootKey !== undefined && router.routeToRoot !== undefined) {
|
|
221
|
+
return router.routeToRoot(rootKey, activity);
|
|
222
|
+
}
|
|
223
|
+
return router.routeAndAct(this.deps.addressing.routeKey(d, this.deps.self, topicId, rootKey), activity, {
|
|
224
|
+
wantK: this.wantK,
|
|
225
|
+
minSigs: this.minSigs,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
205
228
|
}
|
|
206
229
|
/** Build a {@link WalkEngine} over the injected router, addressing, `d_max`, and message factory. */
|
|
207
230
|
export function createWalkEngine(deps) {
|