@serfab/cadre-core 1.4.0 → 1.5.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/dist/cadre-node.d.ts +38 -15
- package/dist/cadre-node.js +77 -29
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-database.d.ts +24 -10
- package/dist/control-database.js +48 -16
- package/dist/control-database.js.map +1 -1
- package/dist/control-read-retry.d.ts +12 -0
- package/dist/control-read-retry.js +12 -0
- package/dist/control-read-retry.js.map +1 -1
- package/dist/control-write-retry.d.ts +5 -4
- package/dist/control-write-retry.js +24 -7
- package/dist/control-write-retry.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/link-budget.d.ts +182 -0
- package/dist/link-budget.js +195 -0
- package/dist/link-budget.js.map +1 -0
- package/dist/peer-dial.d.ts +36 -17
- package/dist/peer-dial.js +37 -17
- package/dist/peer-dial.js.map +1 -1
- package/dist/peer-join-backfill.d.ts +58 -4
- package/dist/peer-join-backfill.js +165 -20
- package/dist/peer-join-backfill.js.map +1 -1
- package/dist/relay-reservation.d.ts +59 -11
- package/dist/relay-reservation.js +169 -43
- package/dist/relay-reservation.js.map +1 -1
- package/dist/seed-bootstrap.js +2 -1
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/strand-first-sync-gate.d.ts +43 -5
- package/dist/strand-first-sync-gate.js +55 -7
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +27 -2
- package/dist/strand-instance-manager.js +56 -13
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-reconciler.d.ts +200 -45
- package/dist/strand-membership-reconciler.js +302 -86
- package/dist/strand-membership-reconciler.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +3 -2
- package/dist/strand-membership-writer.js +67 -90
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-network-config.d.ts +2 -2
- package/dist/strand-network-config.js +2 -2
- package/dist/types.d.ts +96 -9
- package/dist/types.js +14 -4
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/src/cadre-node.ts +7445 -7397
- package/src/control-database.ts +48 -16
- package/src/control-read-retry.ts +214 -202
- package/src/control-write-retry.ts +24 -7
- package/src/index.ts +581 -563
- package/src/link-budget.ts +217 -0
- package/src/peer-dial.ts +39 -17
- package/src/peer-join-backfill.ts +192 -23
- package/src/relay-reservation.ts +1119 -951
- package/src/seed-bootstrap.ts +2 -1
- package/src/strand-first-sync-gate.ts +55 -7
- package/src/strand-instance-manager.ts +1516 -1458
- package/src/strand-membership-reconciler.ts +334 -92
- package/src/strand-membership-writer.ts +1962 -1987
- package/src/strand-network-config.ts +2 -2
- package/src/types.ts +95 -8
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dial and reservation budgets derived from ONE declared link round trip, instead of fixed
|
|
3
|
+
* millisecond numbers chosen on a fast local network.
|
|
4
|
+
*
|
|
5
|
+
* Reaching another machine through a relay costs a FIXED NUMBER OF EXCHANGES, not a fixed
|
|
6
|
+
* number of milliseconds. So every budget written as milliseconds has a link speed above which
|
|
7
|
+
* it can never open a connection at all — and the slower the link, the more of them fall over,
|
|
8
|
+
* silently, because an abandoned dial looks the same as a peer that is not there. Counting round
|
|
9
|
+
* trips instead is what stops that class of defect coming back: the next person to widen a
|
|
10
|
+
* budget changes ONE declaration, and the next person to add a dial writes down its round-trip
|
|
11
|
+
* count beside the arithmetic.
|
|
12
|
+
*
|
|
13
|
+
* ── The instrument ──
|
|
14
|
+
*
|
|
15
|
+
* Every count and every number below comes from
|
|
16
|
+
* `packages/integration-tests/src/scenarios/relayed-dial-cost-by-latency.integration.ts`, which
|
|
17
|
+
* is committed and opt-in (`RELAY_DIAL_COST=1`). **Its doc comment is the single home of the
|
|
18
|
+
* measurement**; this module holds only what the derivation needs. Re-run it before changing
|
|
19
|
+
* anything here.
|
|
20
|
+
*
|
|
21
|
+
* ── The unit ──
|
|
22
|
+
*
|
|
23
|
+
* ONE LINK ROUND TRIP is a message from one machine reaching the other and a reply coming
|
|
24
|
+
* back, over the path those two machines actually use — through the relay, when that is the
|
|
25
|
+
* only way they can reach each other. In the instrument, which injects a constant ONE-WAY
|
|
26
|
+
* frame delay `d`, one link round trip is `2d`.
|
|
27
|
+
*
|
|
28
|
+
* A leg between a node and the RELAY is half a link round trip, because it crosses one of the
|
|
29
|
+
* two hops rather than both. That is why the reservation drive's cost reads as "four
|
|
30
|
+
* node-to-relay round trips" in one telling and "two link round trips" in another: same
|
|
31
|
+
* quantity, different unit. This module uses the LINK round trip throughout, so there is one
|
|
32
|
+
* unit to reason in.
|
|
33
|
+
*
|
|
34
|
+
* ── The counts, and what they cost ──
|
|
35
|
+
*
|
|
36
|
+
* | operation | link round trips | at the declared default |
|
|
37
|
+
* | ---------------------------------------------------- | ---------------- | ----------------------- |
|
|
38
|
+
* | open a relayed connection to another machine | 4 | 8 000 ms |
|
|
39
|
+
* | dial the relay itself | 1 | 2 000 ms |
|
|
40
|
+
* | request a reservation on an open relay connection | 1 | 2 000 ms |
|
|
41
|
+
* | negotiate a protocol over an established circuit | 1 | 2 000 ms |
|
|
42
|
+
*
|
|
43
|
+
* **Measured** 2026-09-26, one Windows machine, loopback dedicated relay, re-run for this
|
|
44
|
+
* change: a relayed dial took 20-25 ms at no delay, **7 255-7 279 ms at 900 ms one-way**, and
|
|
45
|
+
* **12 066-12 094 ms at 1 500 ms one-way**. Four link round trips of pure delay would be 7 200
|
|
46
|
+
* and 12 000, so the real cost sits about 60-95 ms ABOVE the arithmetic — the handshakes and a
|
|
47
|
+
* phone's pure-JS crypto, which no delay figure contains. That residue is small but it is why
|
|
48
|
+
* {@link DECLARED_LINK_ROUND_TRIP_MS} carries headroom over the band sereus supports rather
|
|
49
|
+
* than matching it exactly: a declaration equal to the measured round trip would derive a
|
|
50
|
+
* budget marginally BELOW the dial it has to contain.
|
|
51
|
+
*
|
|
52
|
+
* ── The ceiling this does NOT lift ──
|
|
53
|
+
*
|
|
54
|
+
* Above roughly 1 250 ms one-way — a 2.5-second link round trip — no relayed connection can be
|
|
55
|
+
* established by this stack whatever cadre declares here. Two budgets of 10 000 ms each inside
|
|
56
|
+
* libp2p bound the same dial and cannot be reached from sereus at all:
|
|
57
|
+
* `connectionManager.dialTimeout` (libp2p's own default, which `@optimystic/db-p2p`'s
|
|
58
|
+
* `libp2p-node-base.ts` neither sets nor exposes) and `connectionManager.inboundUpgradeTimeout`
|
|
59
|
+
* (which it sets to 10 000). Both appear in the same re-run: at 1 500 ms one-way the dial under
|
|
60
|
+
* libp2p's default failed with `The operation was aborted due to timeout`, and with the shipped
|
|
61
|
+
* inbound-upgrade budget the DIALER's own 12 094 ms dial resolved while the LISTENER had
|
|
62
|
+
* already thrown the half-built connection away — so the first stream over it died with
|
|
63
|
+
* `Unexpected EOF - stream closed while reading 0/1 bytes` and the listener reported no peer at
|
|
64
|
+
* all. That is why a too-slow link produces silence rather than an error.
|
|
65
|
+
*
|
|
66
|
+
* Two consequences for a reader choosing a declaration. Below that ceiling, the DEFAULT
|
|
67
|
+
* declaration of 2 000 ms does not reach it: four round trips of 2 000 ms is 8 000 ms, which
|
|
68
|
+
* covers a one-way delay up to 1 000 ms, so a deployment somewhere between 1 000 and 1 250 ms
|
|
69
|
+
* one-way has to declare its own (about 2 200-2 500) to use the band libp2p still allows. And
|
|
70
|
+
* declaring much ABOVE 2 500 buys nothing: the budgets here grow, and
|
|
71
|
+
* the connection still fails inside libp2p. Lifting that needs an upstream change and a
|
|
72
|
+
* decision about how slow a link sereus intends to carry —
|
|
73
|
+
* `tickets/blocked/how-slow-a-relayed-link-does-sereus-carry`. A reader who raised these
|
|
74
|
+
* numbers and still cannot connect at 1 500 ms one-way has met that ceiling, not this module.
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* The link round trip cadre assumes when a host declares none, in milliseconds. A deployment
|
|
78
|
+
* that knows its own link states it with `NetworkConfig.linkRoundTripMs` instead.
|
|
79
|
+
*
|
|
80
|
+
* **Why 2 000.** It states the slowest link sereus already claims to support, and two other
|
|
81
|
+
* budgets fix that claim independently: `COHORT_READ_DEADLINE_MS`
|
|
82
|
+
* (`quereus-plugin-sereus/src/cluster-size.ts`, 5 000 ms) and
|
|
83
|
+
* `DEFAULT_STRAND_FIRST_SYNC_TIMEOUT_MS` (`strand-first-sync-gate.ts`, 120 000 ms) were both
|
|
84
|
+
* sized against two parties reaching each other only through a public relay at a round trip
|
|
85
|
+
* near 1.8 s. Declaring 2 000 rounds that band up and leaves about 720 ms over the worst
|
|
86
|
+
* relayed dial measured at it (7 279 ms against a derived 8 000 ms).
|
|
87
|
+
*
|
|
88
|
+
* Raising it is how a deployment that KNOWS its link is slower moves every derived budget at
|
|
89
|
+
* once. The cost is the ordinary cost of a longer deadline: a peer that is genuinely gone holds
|
|
90
|
+
* the operation for that much longer before it is abandoned and retried. Above about 2 500 it
|
|
91
|
+
* buys nothing — see the module doc's ceiling paragraph.
|
|
92
|
+
*/
|
|
93
|
+
export declare const DECLARED_LINK_ROUND_TRIP_MS = 2000;
|
|
94
|
+
/**
|
|
95
|
+
* Link round trips one relayed connection setup costs: transport, encryption and multiplexer
|
|
96
|
+
* handshakes to the relay, the circuit open, then both handshakes again end to end through it.
|
|
97
|
+
* Measured at 8 one-way delays, which is 4 link round trips.
|
|
98
|
+
*/
|
|
99
|
+
export declare const RELAYED_DIAL_ROUND_TRIPS = 4;
|
|
100
|
+
/**
|
|
101
|
+
* Link round trips one whole reservation drive is budgeted for
|
|
102
|
+
* (`relay-reservation.ts`'s `driveRelayReservation`, whose ONE deadline covers the dial, the
|
|
103
|
+
* reservation request and the wait together).
|
|
104
|
+
*
|
|
105
|
+
* The protocol work measured is 2 — dial the relay (1) plus request the reservation (1). It is
|
|
106
|
+
* budgeted at 4, the relayed-dial count, because the wait afterwards may instead be satisfied
|
|
107
|
+
* by libp2p's own relay discovery, which repeats both legs after identify has run; 4 is
|
|
108
|
+
* therefore the largest thing this one deadline can be asked to contain, and the poll interval
|
|
109
|
+
* (`DEFAULT_RELAY_RESERVE_POLL_MS`) rounds up on top of it.
|
|
110
|
+
*/
|
|
111
|
+
export declare const RELAY_RESERVATION_ROUND_TRIPS = 4;
|
|
112
|
+
/**
|
|
113
|
+
* Link round trips one request-and-answer over an ALREADY-OPEN circuit costs: the protocol
|
|
114
|
+
* negotiation (1, measured at 2 one-way delays) plus the request and its response (1). It does
|
|
115
|
+
* not include a dial — a caller that may have to open the connection budgets
|
|
116
|
+
* {@link RELAYED_DIAL_ROUND_TRIPS} separately, which is exactly what the two-field shape of
|
|
117
|
+
* Optimystic's `dialTimeoutMs` / `responseTimeoutMs` pair is for.
|
|
118
|
+
*/
|
|
119
|
+
export declare const CIRCUIT_REQUEST_ROUND_TRIPS = 2;
|
|
120
|
+
/**
|
|
121
|
+
* What a block-transfer push message's BYTES get to cross, on top of the latency
|
|
122
|
+
* {@link CIRCUIT_REQUEST_ROUND_TRIPS} covers, in milliseconds.
|
|
123
|
+
*
|
|
124
|
+
* This part is bandwidth, not latency, so it does not scale with the declared round trip: a
|
|
125
|
+
* chunk is capped at `PeerJoinBackfillConfig.maxChunkBytes` (1 MiB by default) and crossing it
|
|
126
|
+
* costs whatever the link's throughput costs.
|
|
127
|
+
*
|
|
128
|
+
* NOTE: 6 000 ms is not a measurement of any throughput — it is the residue of the 10 000 ms
|
|
129
|
+
* this deadline shipped as before it was split into a latency part and a transfer part, chosen
|
|
130
|
+
* so that at the default declaration the derived value is the same 10 000 and no fast link got
|
|
131
|
+
* slower. Nobody has measured how long 1 MiB takes to cross a relayed mobile link. If pushes
|
|
132
|
+
* ever time out with the transfer only part done, measure that and raise THIS, not the declared
|
|
133
|
+
* round trip.
|
|
134
|
+
*/
|
|
135
|
+
export declare const PUSH_TRANSFER_ALLOWANCE_MS = 6000;
|
|
136
|
+
/**
|
|
137
|
+
* Resolve a host's declared link round trip, falling back to
|
|
138
|
+
* {@link DECLARED_LINK_ROUND_TRIP_MS}.
|
|
139
|
+
*
|
|
140
|
+
* Validated here rather than downstream because nothing downstream would: every consumer
|
|
141
|
+
* multiplies this value into a `setTimeout` deadline, where a zero silently turns a budget into
|
|
142
|
+
* "give up immediately" and a `NaN` turns it into "never time out".
|
|
143
|
+
*
|
|
144
|
+
* Both node bring-up paths call this EAGERLY — `CadreNode.start()`, and
|
|
145
|
+
* `StrandInstanceManager.buildStrandRuntime` behind `addStrand`/`resumeStrand` — so a bad
|
|
146
|
+
* declaration fails the same start that Optimystic's own check on `cohortQueryTimeoutMs` fails.
|
|
147
|
+
* The eager call is what makes that true: every budget derived here is behind a condition (a
|
|
148
|
+
* node with no control storage builds no catch-up, a node with no relay addrs drives no
|
|
149
|
+
* reservation), so waiting for a first consumer would let a broken declaration boot and then
|
|
150
|
+
* throw inside a best-effort path that logs and carries on.
|
|
151
|
+
*/
|
|
152
|
+
export declare function resolveLinkRoundTripMs(linkRoundTripMs?: number): number;
|
|
153
|
+
/**
|
|
154
|
+
* Deadline for OPENING a connection to another machine that may only be reachable through a
|
|
155
|
+
* relay: {@link RELAYED_DIAL_ROUND_TRIPS} at the declared link round trip.
|
|
156
|
+
*/
|
|
157
|
+
export declare function relayedDialBudgetMs(linkRoundTripMs?: number): number;
|
|
158
|
+
/**
|
|
159
|
+
* Deadline for one whole relay reservation drive: {@link RELAY_RESERVATION_ROUND_TRIPS} at the
|
|
160
|
+
* declared link round trip.
|
|
161
|
+
*/
|
|
162
|
+
export declare function relayReservationBudgetMs(linkRoundTripMs?: number): number;
|
|
163
|
+
/**
|
|
164
|
+
* Deadline for one request and its answer over a circuit that is already open —
|
|
165
|
+
* {@link CIRCUIT_REQUEST_ROUND_TRIPS} at the declared link round trip, plus `transferAllowanceMs`
|
|
166
|
+
* for the payload's own bytes.
|
|
167
|
+
*/
|
|
168
|
+
export declare function circuitRequestBudgetMs(linkRoundTripMs?: number, transferAllowanceMs?: number): number;
|
|
169
|
+
/** The two deadlines one peer-join catch-up push needs, both derived from the declared link. */
|
|
170
|
+
export interface PeerJoinPushBudget {
|
|
171
|
+
/** Opening the connection to the peer being caught up — a relayed dial, in the worst case. */
|
|
172
|
+
dialTimeoutMs: number;
|
|
173
|
+
/** The push request and its answer over that connection, including the chunk's own bytes. */
|
|
174
|
+
responseTimeoutMs: number;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The dial and response deadlines a peer-join catch-up push needs at a declared link. One
|
|
178
|
+
* helper rather than two call-site expressions, because the two construction sites
|
|
179
|
+
* (`CadreNode`'s control catch-up and `StrandInstanceManager`'s per-strand one) and
|
|
180
|
+
* `DEFAULT_PEER_JOIN_BACKFILL` must not drift apart.
|
|
181
|
+
*/
|
|
182
|
+
export declare function peerJoinPushBudget(linkRoundTripMs?: number): PeerJoinPushBudget;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dial and reservation budgets derived from ONE declared link round trip, instead of fixed
|
|
3
|
+
* millisecond numbers chosen on a fast local network.
|
|
4
|
+
*
|
|
5
|
+
* Reaching another machine through a relay costs a FIXED NUMBER OF EXCHANGES, not a fixed
|
|
6
|
+
* number of milliseconds. So every budget written as milliseconds has a link speed above which
|
|
7
|
+
* it can never open a connection at all — and the slower the link, the more of them fall over,
|
|
8
|
+
* silently, because an abandoned dial looks the same as a peer that is not there. Counting round
|
|
9
|
+
* trips instead is what stops that class of defect coming back: the next person to widen a
|
|
10
|
+
* budget changes ONE declaration, and the next person to add a dial writes down its round-trip
|
|
11
|
+
* count beside the arithmetic.
|
|
12
|
+
*
|
|
13
|
+
* ── The instrument ──
|
|
14
|
+
*
|
|
15
|
+
* Every count and every number below comes from
|
|
16
|
+
* `packages/integration-tests/src/scenarios/relayed-dial-cost-by-latency.integration.ts`, which
|
|
17
|
+
* is committed and opt-in (`RELAY_DIAL_COST=1`). **Its doc comment is the single home of the
|
|
18
|
+
* measurement**; this module holds only what the derivation needs. Re-run it before changing
|
|
19
|
+
* anything here.
|
|
20
|
+
*
|
|
21
|
+
* ── The unit ──
|
|
22
|
+
*
|
|
23
|
+
* ONE LINK ROUND TRIP is a message from one machine reaching the other and a reply coming
|
|
24
|
+
* back, over the path those two machines actually use — through the relay, when that is the
|
|
25
|
+
* only way they can reach each other. In the instrument, which injects a constant ONE-WAY
|
|
26
|
+
* frame delay `d`, one link round trip is `2d`.
|
|
27
|
+
*
|
|
28
|
+
* A leg between a node and the RELAY is half a link round trip, because it crosses one of the
|
|
29
|
+
* two hops rather than both. That is why the reservation drive's cost reads as "four
|
|
30
|
+
* node-to-relay round trips" in one telling and "two link round trips" in another: same
|
|
31
|
+
* quantity, different unit. This module uses the LINK round trip throughout, so there is one
|
|
32
|
+
* unit to reason in.
|
|
33
|
+
*
|
|
34
|
+
* ── The counts, and what they cost ──
|
|
35
|
+
*
|
|
36
|
+
* | operation | link round trips | at the declared default |
|
|
37
|
+
* | ---------------------------------------------------- | ---------------- | ----------------------- |
|
|
38
|
+
* | open a relayed connection to another machine | 4 | 8 000 ms |
|
|
39
|
+
* | dial the relay itself | 1 | 2 000 ms |
|
|
40
|
+
* | request a reservation on an open relay connection | 1 | 2 000 ms |
|
|
41
|
+
* | negotiate a protocol over an established circuit | 1 | 2 000 ms |
|
|
42
|
+
*
|
|
43
|
+
* **Measured** 2026-09-26, one Windows machine, loopback dedicated relay, re-run for this
|
|
44
|
+
* change: a relayed dial took 20-25 ms at no delay, **7 255-7 279 ms at 900 ms one-way**, and
|
|
45
|
+
* **12 066-12 094 ms at 1 500 ms one-way**. Four link round trips of pure delay would be 7 200
|
|
46
|
+
* and 12 000, so the real cost sits about 60-95 ms ABOVE the arithmetic — the handshakes and a
|
|
47
|
+
* phone's pure-JS crypto, which no delay figure contains. That residue is small but it is why
|
|
48
|
+
* {@link DECLARED_LINK_ROUND_TRIP_MS} carries headroom over the band sereus supports rather
|
|
49
|
+
* than matching it exactly: a declaration equal to the measured round trip would derive a
|
|
50
|
+
* budget marginally BELOW the dial it has to contain.
|
|
51
|
+
*
|
|
52
|
+
* ── The ceiling this does NOT lift ──
|
|
53
|
+
*
|
|
54
|
+
* Above roughly 1 250 ms one-way — a 2.5-second link round trip — no relayed connection can be
|
|
55
|
+
* established by this stack whatever cadre declares here. Two budgets of 10 000 ms each inside
|
|
56
|
+
* libp2p bound the same dial and cannot be reached from sereus at all:
|
|
57
|
+
* `connectionManager.dialTimeout` (libp2p's own default, which `@optimystic/db-p2p`'s
|
|
58
|
+
* `libp2p-node-base.ts` neither sets nor exposes) and `connectionManager.inboundUpgradeTimeout`
|
|
59
|
+
* (which it sets to 10 000). Both appear in the same re-run: at 1 500 ms one-way the dial under
|
|
60
|
+
* libp2p's default failed with `The operation was aborted due to timeout`, and with the shipped
|
|
61
|
+
* inbound-upgrade budget the DIALER's own 12 094 ms dial resolved while the LISTENER had
|
|
62
|
+
* already thrown the half-built connection away — so the first stream over it died with
|
|
63
|
+
* `Unexpected EOF - stream closed while reading 0/1 bytes` and the listener reported no peer at
|
|
64
|
+
* all. That is why a too-slow link produces silence rather than an error.
|
|
65
|
+
*
|
|
66
|
+
* Two consequences for a reader choosing a declaration. Below that ceiling, the DEFAULT
|
|
67
|
+
* declaration of 2 000 ms does not reach it: four round trips of 2 000 ms is 8 000 ms, which
|
|
68
|
+
* covers a one-way delay up to 1 000 ms, so a deployment somewhere between 1 000 and 1 250 ms
|
|
69
|
+
* one-way has to declare its own (about 2 200-2 500) to use the band libp2p still allows. And
|
|
70
|
+
* declaring much ABOVE 2 500 buys nothing: the budgets here grow, and
|
|
71
|
+
* the connection still fails inside libp2p. Lifting that needs an upstream change and a
|
|
72
|
+
* decision about how slow a link sereus intends to carry —
|
|
73
|
+
* `tickets/blocked/how-slow-a-relayed-link-does-sereus-carry`. A reader who raised these
|
|
74
|
+
* numbers and still cannot connect at 1 500 ms one-way has met that ceiling, not this module.
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* The link round trip cadre assumes when a host declares none, in milliseconds. A deployment
|
|
78
|
+
* that knows its own link states it with `NetworkConfig.linkRoundTripMs` instead.
|
|
79
|
+
*
|
|
80
|
+
* **Why 2 000.** It states the slowest link sereus already claims to support, and two other
|
|
81
|
+
* budgets fix that claim independently: `COHORT_READ_DEADLINE_MS`
|
|
82
|
+
* (`quereus-plugin-sereus/src/cluster-size.ts`, 5 000 ms) and
|
|
83
|
+
* `DEFAULT_STRAND_FIRST_SYNC_TIMEOUT_MS` (`strand-first-sync-gate.ts`, 120 000 ms) were both
|
|
84
|
+
* sized against two parties reaching each other only through a public relay at a round trip
|
|
85
|
+
* near 1.8 s. Declaring 2 000 rounds that band up and leaves about 720 ms over the worst
|
|
86
|
+
* relayed dial measured at it (7 279 ms against a derived 8 000 ms).
|
|
87
|
+
*
|
|
88
|
+
* Raising it is how a deployment that KNOWS its link is slower moves every derived budget at
|
|
89
|
+
* once. The cost is the ordinary cost of a longer deadline: a peer that is genuinely gone holds
|
|
90
|
+
* the operation for that much longer before it is abandoned and retried. Above about 2 500 it
|
|
91
|
+
* buys nothing — see the module doc's ceiling paragraph.
|
|
92
|
+
*/
|
|
93
|
+
export const DECLARED_LINK_ROUND_TRIP_MS = 2000;
|
|
94
|
+
/**
|
|
95
|
+
* Link round trips one relayed connection setup costs: transport, encryption and multiplexer
|
|
96
|
+
* handshakes to the relay, the circuit open, then both handshakes again end to end through it.
|
|
97
|
+
* Measured at 8 one-way delays, which is 4 link round trips.
|
|
98
|
+
*/
|
|
99
|
+
export const RELAYED_DIAL_ROUND_TRIPS = 4;
|
|
100
|
+
/**
|
|
101
|
+
* Link round trips one whole reservation drive is budgeted for
|
|
102
|
+
* (`relay-reservation.ts`'s `driveRelayReservation`, whose ONE deadline covers the dial, the
|
|
103
|
+
* reservation request and the wait together).
|
|
104
|
+
*
|
|
105
|
+
* The protocol work measured is 2 — dial the relay (1) plus request the reservation (1). It is
|
|
106
|
+
* budgeted at 4, the relayed-dial count, because the wait afterwards may instead be satisfied
|
|
107
|
+
* by libp2p's own relay discovery, which repeats both legs after identify has run; 4 is
|
|
108
|
+
* therefore the largest thing this one deadline can be asked to contain, and the poll interval
|
|
109
|
+
* (`DEFAULT_RELAY_RESERVE_POLL_MS`) rounds up on top of it.
|
|
110
|
+
*/
|
|
111
|
+
export const RELAY_RESERVATION_ROUND_TRIPS = 4;
|
|
112
|
+
/**
|
|
113
|
+
* Link round trips one request-and-answer over an ALREADY-OPEN circuit costs: the protocol
|
|
114
|
+
* negotiation (1, measured at 2 one-way delays) plus the request and its response (1). It does
|
|
115
|
+
* not include a dial — a caller that may have to open the connection budgets
|
|
116
|
+
* {@link RELAYED_DIAL_ROUND_TRIPS} separately, which is exactly what the two-field shape of
|
|
117
|
+
* Optimystic's `dialTimeoutMs` / `responseTimeoutMs` pair is for.
|
|
118
|
+
*/
|
|
119
|
+
export const CIRCUIT_REQUEST_ROUND_TRIPS = 2;
|
|
120
|
+
/**
|
|
121
|
+
* What a block-transfer push message's BYTES get to cross, on top of the latency
|
|
122
|
+
* {@link CIRCUIT_REQUEST_ROUND_TRIPS} covers, in milliseconds.
|
|
123
|
+
*
|
|
124
|
+
* This part is bandwidth, not latency, so it does not scale with the declared round trip: a
|
|
125
|
+
* chunk is capped at `PeerJoinBackfillConfig.maxChunkBytes` (1 MiB by default) and crossing it
|
|
126
|
+
* costs whatever the link's throughput costs.
|
|
127
|
+
*
|
|
128
|
+
* NOTE: 6 000 ms is not a measurement of any throughput — it is the residue of the 10 000 ms
|
|
129
|
+
* this deadline shipped as before it was split into a latency part and a transfer part, chosen
|
|
130
|
+
* so that at the default declaration the derived value is the same 10 000 and no fast link got
|
|
131
|
+
* slower. Nobody has measured how long 1 MiB takes to cross a relayed mobile link. If pushes
|
|
132
|
+
* ever time out with the transfer only part done, measure that and raise THIS, not the declared
|
|
133
|
+
* round trip.
|
|
134
|
+
*/
|
|
135
|
+
export const PUSH_TRANSFER_ALLOWANCE_MS = 6000;
|
|
136
|
+
/**
|
|
137
|
+
* Resolve a host's declared link round trip, falling back to
|
|
138
|
+
* {@link DECLARED_LINK_ROUND_TRIP_MS}.
|
|
139
|
+
*
|
|
140
|
+
* Validated here rather than downstream because nothing downstream would: every consumer
|
|
141
|
+
* multiplies this value into a `setTimeout` deadline, where a zero silently turns a budget into
|
|
142
|
+
* "give up immediately" and a `NaN` turns it into "never time out".
|
|
143
|
+
*
|
|
144
|
+
* Both node bring-up paths call this EAGERLY — `CadreNode.start()`, and
|
|
145
|
+
* `StrandInstanceManager.buildStrandRuntime` behind `addStrand`/`resumeStrand` — so a bad
|
|
146
|
+
* declaration fails the same start that Optimystic's own check on `cohortQueryTimeoutMs` fails.
|
|
147
|
+
* The eager call is what makes that true: every budget derived here is behind a condition (a
|
|
148
|
+
* node with no control storage builds no catch-up, a node with no relay addrs drives no
|
|
149
|
+
* reservation), so waiting for a first consumer would let a broken declaration boot and then
|
|
150
|
+
* throw inside a best-effort path that logs and carries on.
|
|
151
|
+
*/
|
|
152
|
+
export function resolveLinkRoundTripMs(linkRoundTripMs) {
|
|
153
|
+
if (linkRoundTripMs === undefined) {
|
|
154
|
+
return DECLARED_LINK_ROUND_TRIP_MS;
|
|
155
|
+
}
|
|
156
|
+
if (!Number.isFinite(linkRoundTripMs) || linkRoundTripMs <= 0) {
|
|
157
|
+
throw new Error(`network.linkRoundTripMs must be a finite number of milliseconds above zero, not ${String(linkRoundTripMs)}`);
|
|
158
|
+
}
|
|
159
|
+
return linkRoundTripMs;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Deadline for OPENING a connection to another machine that may only be reachable through a
|
|
163
|
+
* relay: {@link RELAYED_DIAL_ROUND_TRIPS} at the declared link round trip.
|
|
164
|
+
*/
|
|
165
|
+
export function relayedDialBudgetMs(linkRoundTripMs) {
|
|
166
|
+
return RELAYED_DIAL_ROUND_TRIPS * resolveLinkRoundTripMs(linkRoundTripMs);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Deadline for one whole relay reservation drive: {@link RELAY_RESERVATION_ROUND_TRIPS} at the
|
|
170
|
+
* declared link round trip.
|
|
171
|
+
*/
|
|
172
|
+
export function relayReservationBudgetMs(linkRoundTripMs) {
|
|
173
|
+
return RELAY_RESERVATION_ROUND_TRIPS * resolveLinkRoundTripMs(linkRoundTripMs);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Deadline for one request and its answer over a circuit that is already open —
|
|
177
|
+
* {@link CIRCUIT_REQUEST_ROUND_TRIPS} at the declared link round trip, plus `transferAllowanceMs`
|
|
178
|
+
* for the payload's own bytes.
|
|
179
|
+
*/
|
|
180
|
+
export function circuitRequestBudgetMs(linkRoundTripMs, transferAllowanceMs = PUSH_TRANSFER_ALLOWANCE_MS) {
|
|
181
|
+
return CIRCUIT_REQUEST_ROUND_TRIPS * resolveLinkRoundTripMs(linkRoundTripMs) + transferAllowanceMs;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The dial and response deadlines a peer-join catch-up push needs at a declared link. One
|
|
185
|
+
* helper rather than two call-site expressions, because the two construction sites
|
|
186
|
+
* (`CadreNode`'s control catch-up and `StrandInstanceManager`'s per-strand one) and
|
|
187
|
+
* `DEFAULT_PEER_JOIN_BACKFILL` must not drift apart.
|
|
188
|
+
*/
|
|
189
|
+
export function peerJoinPushBudget(linkRoundTripMs) {
|
|
190
|
+
return {
|
|
191
|
+
dialTimeoutMs: relayedDialBudgetMs(linkRoundTripMs),
|
|
192
|
+
responseTimeoutMs: circuitRequestBudgetMs(linkRoundTripMs)
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=link-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-budget.js","sourceRoot":"","sources":["../src/link-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,2BAA2B,GA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,eAAe,CAAC;KAC1D,CAAC;AACH,CAAC"}
|
package/dist/peer-dial.d.ts
CHANGED
|
@@ -25,28 +25,41 @@
|
|
|
25
25
|
import type { Connection } from '@libp2p/interface';
|
|
26
26
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
27
27
|
/**
|
|
28
|
-
* Default limit on ONE address's dial attempt, in ms
|
|
28
|
+
* Default limit on ONE address's dial attempt, in ms, at the DEFAULT declared link round trip:
|
|
29
|
+
* `RELAYED_DIAL_ROUND_TRIPS` (4) x `DECLARED_LINK_ROUND_TRIP_MS` (2000 ms) = 8000 ms, which is
|
|
30
|
+
* what this constant was already set to as a fixed number.
|
|
29
31
|
*
|
|
30
32
|
* It has to cover the slowest address that should succeed, because an attempt
|
|
31
33
|
* that needs longer fails the same way on every retry. That is a relayed dial on
|
|
32
34
|
* a mobile link: connect to the relay (transport, encryption and multiplexer
|
|
33
35
|
* handshakes, when no relay connection is open yet), open the circuit, then run
|
|
34
|
-
* both handshakes again end to end through the relay
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
36
|
+
* both handshakes again end to end through the relay. `link-budget.ts` is where that
|
|
37
|
+
* reasoning is now a measured count instead of an estimate — four link round trips, measured at
|
|
38
|
+
* 7 279 ms on a link whose round trip is 1.8 s — so the value MOVES with a host's
|
|
39
|
+
* `NetworkConfig.linkRoundTripMs` rather than pinning the band this node can reach to whatever
|
|
40
|
+
* number was typed here. A direct dial that works is far quicker — a phone's WebSocket dial to
|
|
41
|
+
* a node forwarded over `adb reverse` measured 1.6 s end to end.
|
|
42
|
+
*
|
|
43
|
+
* Deriving it rather than leaving it fixed is deliberate: at 8000 ms fixed, the per-address
|
|
44
|
+
* limit — not libp2p's own 10 s dial timeout — was the first thing to cut a relayed dial off,
|
|
45
|
+
* from about 1000 ms of one-way link delay upward. Nothing said so, and a reader raising
|
|
46
|
+
* `DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS` below would not have found it.
|
|
40
47
|
*
|
|
41
48
|
* NOTE: a `/p2p-circuit/webrtc` address also negotiates a WebRTC session after
|
|
42
49
|
* the relay leg. If such dials are ever seen failing at exactly this limit, raise
|
|
43
|
-
*
|
|
44
|
-
* rather than the per-peer limit, which cannot help an address that is itself
|
|
50
|
+
* the declared link round trip (or `network.controlCohort.perAddressDialTimeoutMs` on the
|
|
51
|
+
* affected nodes) rather than the per-peer limit, which cannot help an address that is itself
|
|
45
52
|
* cut off.
|
|
46
53
|
*
|
|
47
54
|
* Override per node with `network.controlCohort.perAddressDialTimeoutMs`.
|
|
48
55
|
*/
|
|
49
|
-
export declare const DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS
|
|
56
|
+
export declare const DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS: number;
|
|
57
|
+
/**
|
|
58
|
+
* How many whole per-address dial attempts {@link DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS}
|
|
59
|
+
* budgets for: the address that works plus the three dead ones a lent cadre-host node is
|
|
60
|
+
* observed to report ahead of it (loopback and LAN WebSocket addresses, plus virtual adapters).
|
|
61
|
+
*/
|
|
62
|
+
export declare const CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS = 4;
|
|
50
63
|
/**
|
|
51
64
|
* Default limit on dialing ONE peer — every candidate address together — in ms.
|
|
52
65
|
*
|
|
@@ -59,18 +72,24 @@ export declare const DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS = 8000;
|
|
|
59
72
|
*
|
|
60
73
|
* Sized to fit a typical list with dead addresses ahead of the one that works:
|
|
61
74
|
* a lent cadre-host node reports two to four addresses a phone can dial
|
|
62
|
-
* (loopback and LAN WebSocket addresses, plus any virtual adapters).
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* working address sits behind four or more dropped ones does not fit, and fails
|
|
66
|
-
*
|
|
67
|
-
*
|
|
75
|
+
* (loopback and LAN WebSocket addresses, plus any virtual adapters). So it is
|
|
76
|
+
* {@link CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS} whole per-address budgets — three silently
|
|
77
|
+
* dropped addresses, then the one that works, each getting the FULL per-address limit. A peer
|
|
78
|
+
* whose working address sits behind four or more dropped ones does not fit, and fails each pass
|
|
79
|
+
* the same way; if that shows up, the remedy is ordering (try the address that last connected
|
|
80
|
+
* first), not a larger number here.
|
|
81
|
+
*
|
|
82
|
+
* Counted as whole per-address budgets rather than the flat 30_000 it was before, because the
|
|
83
|
+
* old number left only 6 s after three dropped addresses — enough for the 1.6 s direct dial the
|
|
84
|
+
* phone measured, but NOT for the relayed dial the per-address limit is sized to cover. A peer
|
|
85
|
+
* whose only working address was a relayed one behind two dead ones therefore could not be
|
|
86
|
+
* dialled at all, and the arithmetic in this comment was what said otherwise.
|
|
68
87
|
*
|
|
69
88
|
* Override per node with `network.controlCohort.dialTimeoutMs` — tests that
|
|
70
89
|
* drive dead addresses on purpose set it low so a pass's duration is a chosen
|
|
71
90
|
* number rather than a transitive libp2p default stretched by machine load.
|
|
72
91
|
*/
|
|
73
|
-
export declare const DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS
|
|
92
|
+
export declare const DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS: number;
|
|
74
93
|
/** Time limits for dialing one peer from a list of candidate addresses. */
|
|
75
94
|
export interface PeerDialBudget {
|
|
76
95
|
/** Limit on one address's attempt, in ms. */
|
package/dist/peer-dial.js
CHANGED
|
@@ -24,30 +24,44 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import debug from 'debug';
|
|
26
26
|
import { withDeadline } from './control-stream.js';
|
|
27
|
+
import { relayedDialBudgetMs } from './link-budget.js';
|
|
27
28
|
const log = debug('sereus:cadre:peer-dial');
|
|
28
29
|
/**
|
|
29
|
-
* Default limit on ONE address's dial attempt, in ms
|
|
30
|
+
* Default limit on ONE address's dial attempt, in ms, at the DEFAULT declared link round trip:
|
|
31
|
+
* `RELAYED_DIAL_ROUND_TRIPS` (4) x `DECLARED_LINK_ROUND_TRIP_MS` (2000 ms) = 8000 ms, which is
|
|
32
|
+
* what this constant was already set to as a fixed number.
|
|
30
33
|
*
|
|
31
34
|
* It has to cover the slowest address that should succeed, because an attempt
|
|
32
35
|
* that needs longer fails the same way on every retry. That is a relayed dial on
|
|
33
36
|
* a mobile link: connect to the relay (transport, encryption and multiplexer
|
|
34
37
|
* handshakes, when no relay connection is open yet), open the circuit, then run
|
|
35
|
-
* both handshakes again end to end through the relay
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* both handshakes again end to end through the relay. `link-budget.ts` is where that
|
|
39
|
+
* reasoning is now a measured count instead of an estimate — four link round trips, measured at
|
|
40
|
+
* 7 279 ms on a link whose round trip is 1.8 s — so the value MOVES with a host's
|
|
41
|
+
* `NetworkConfig.linkRoundTripMs` rather than pinning the band this node can reach to whatever
|
|
42
|
+
* number was typed here. A direct dial that works is far quicker — a phone's WebSocket dial to
|
|
43
|
+
* a node forwarded over `adb reverse` measured 1.6 s end to end.
|
|
44
|
+
*
|
|
45
|
+
* Deriving it rather than leaving it fixed is deliberate: at 8000 ms fixed, the per-address
|
|
46
|
+
* limit — not libp2p's own 10 s dial timeout — was the first thing to cut a relayed dial off,
|
|
47
|
+
* from about 1000 ms of one-way link delay upward. Nothing said so, and a reader raising
|
|
48
|
+
* `DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS` below would not have found it.
|
|
41
49
|
*
|
|
42
50
|
* NOTE: a `/p2p-circuit/webrtc` address also negotiates a WebRTC session after
|
|
43
51
|
* the relay leg. If such dials are ever seen failing at exactly this limit, raise
|
|
44
|
-
*
|
|
45
|
-
* rather than the per-peer limit, which cannot help an address that is itself
|
|
52
|
+
* the declared link round trip (or `network.controlCohort.perAddressDialTimeoutMs` on the
|
|
53
|
+
* affected nodes) rather than the per-peer limit, which cannot help an address that is itself
|
|
46
54
|
* cut off.
|
|
47
55
|
*
|
|
48
56
|
* Override per node with `network.controlCohort.perAddressDialTimeoutMs`.
|
|
49
57
|
*/
|
|
50
|
-
export const DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS =
|
|
58
|
+
export const DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS = relayedDialBudgetMs();
|
|
59
|
+
/**
|
|
60
|
+
* How many whole per-address dial attempts {@link DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS}
|
|
61
|
+
* budgets for: the address that works plus the three dead ones a lent cadre-host node is
|
|
62
|
+
* observed to report ahead of it (loopback and LAN WebSocket addresses, plus virtual adapters).
|
|
63
|
+
*/
|
|
64
|
+
export const CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS = 4;
|
|
51
65
|
/**
|
|
52
66
|
* Default limit on dialing ONE peer — every candidate address together — in ms.
|
|
53
67
|
*
|
|
@@ -60,18 +74,24 @@ export const DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS = 8000;
|
|
|
60
74
|
*
|
|
61
75
|
* Sized to fit a typical list with dead addresses ahead of the one that works:
|
|
62
76
|
* a lent cadre-host node reports two to four addresses a phone can dial
|
|
63
|
-
* (loopback and LAN WebSocket addresses, plus any virtual adapters).
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* working address sits behind four or more dropped ones does not fit, and fails
|
|
67
|
-
*
|
|
68
|
-
*
|
|
77
|
+
* (loopback and LAN WebSocket addresses, plus any virtual adapters). So it is
|
|
78
|
+
* {@link CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS} whole per-address budgets — three silently
|
|
79
|
+
* dropped addresses, then the one that works, each getting the FULL per-address limit. A peer
|
|
80
|
+
* whose working address sits behind four or more dropped ones does not fit, and fails each pass
|
|
81
|
+
* the same way; if that shows up, the remedy is ordering (try the address that last connected
|
|
82
|
+
* first), not a larger number here.
|
|
83
|
+
*
|
|
84
|
+
* Counted as whole per-address budgets rather than the flat 30_000 it was before, because the
|
|
85
|
+
* old number left only 6 s after three dropped addresses — enough for the 1.6 s direct dial the
|
|
86
|
+
* phone measured, but NOT for the relayed dial the per-address limit is sized to cover. A peer
|
|
87
|
+
* whose only working address was a relayed one behind two dead ones therefore could not be
|
|
88
|
+
* dialled at all, and the arithmetic in this comment was what said otherwise.
|
|
69
89
|
*
|
|
70
90
|
* Override per node with `network.controlCohort.dialTimeoutMs` — tests that
|
|
71
91
|
* drive dead addresses on purpose set it low so a pass's duration is a chosen
|
|
72
92
|
* number rather than a transitive libp2p default stretched by machine load.
|
|
73
93
|
*/
|
|
74
|
-
export const DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS =
|
|
94
|
+
export const DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS = CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS * DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS;
|
|
75
95
|
/** {@link PeerDialBudget} built from the two defaults above. */
|
|
76
96
|
export const DEFAULT_PEER_DIAL_BUDGET = {
|
|
77
97
|
perAddressMs: DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS,
|
package/dist/peer-dial.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer-dial.js","sourceRoot":"","sources":["../src/peer-dial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"peer-dial.js","sourceRoot":"","sources":["../src/peer-dial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;A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