@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.
Files changed (257) hide show
  1. package/{readme.md → README.md} +688 -668
  2. package/dist/src/cluster/block-transfer-service.d.ts +133 -10
  3. package/dist/src/cluster/block-transfer-service.d.ts.map +1 -1
  4. package/dist/src/cluster/block-transfer-service.js +155 -9
  5. package/dist/src/cluster/block-transfer-service.js.map +1 -1
  6. package/dist/src/cluster/block-transfer.d.ts +67 -7
  7. package/dist/src/cluster/block-transfer.d.ts.map +1 -1
  8. package/dist/src/cluster/block-transfer.js +127 -24
  9. package/dist/src/cluster/block-transfer.js.map +1 -1
  10. package/dist/src/cluster/certified-claims.d.ts +170 -0
  11. package/dist/src/cluster/certified-claims.d.ts.map +1 -0
  12. package/dist/src/cluster/certified-claims.js +200 -0
  13. package/dist/src/cluster/certified-claims.js.map +1 -0
  14. package/dist/src/cluster/client-signature-verifier.d.ts +23 -0
  15. package/dist/src/cluster/client-signature-verifier.d.ts.map +1 -0
  16. package/dist/src/cluster/client-signature-verifier.js +33 -0
  17. package/dist/src/cluster/client-signature-verifier.js.map +1 -0
  18. package/dist/src/cluster/cluster-policy.d.ts +9 -3
  19. package/dist/src/cluster/cluster-policy.d.ts.map +1 -1
  20. package/dist/src/cluster/cluster-policy.js +111 -27
  21. package/dist/src/cluster/cluster-policy.js.map +1 -1
  22. package/dist/src/cluster/cluster-repo.d.ts +140 -11
  23. package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
  24. package/dist/src/cluster/cluster-repo.js +485 -29
  25. package/dist/src/cluster/cluster-repo.js.map +1 -1
  26. package/dist/src/cluster/commit-proof.d.ts +134 -0
  27. package/dist/src/cluster/commit-proof.d.ts.map +1 -0
  28. package/dist/src/cluster/commit-proof.js +263 -0
  29. package/dist/src/cluster/commit-proof.js.map +1 -0
  30. package/dist/src/cluster/quorum-restore.d.ts +95 -8
  31. package/dist/src/cluster/quorum-restore.d.ts.map +1 -1
  32. package/dist/src/cluster/quorum-restore.js +113 -14
  33. package/dist/src/cluster/quorum-restore.js.map +1 -1
  34. package/dist/src/cluster/rebalance-monitor.d.ts +84 -0
  35. package/dist/src/cluster/rebalance-monitor.d.ts.map +1 -1
  36. package/dist/src/cluster/rebalance-monitor.js +207 -5
  37. package/dist/src/cluster/rebalance-monitor.js.map +1 -1
  38. package/dist/src/cluster/reconcile-block.d.ts +27 -7
  39. package/dist/src/cluster/reconcile-block.d.ts.map +1 -1
  40. package/dist/src/cluster/reconcile-block.js +179 -38
  41. package/dist/src/cluster/reconcile-block.js.map +1 -1
  42. package/dist/src/cluster/service.d.ts +21 -4
  43. package/dist/src/cluster/service.d.ts.map +1 -1
  44. package/dist/src/cluster/service.js +28 -17
  45. package/dist/src/cluster/service.js.map +1 -1
  46. package/dist/src/cluster/spread-on-churn.d.ts +8 -2
  47. package/dist/src/cluster/spread-on-churn.d.ts.map +1 -1
  48. package/dist/src/cluster/spread-on-churn.js +7 -7
  49. package/dist/src/cluster/spread-on-churn.js.map +1 -1
  50. package/dist/src/cohort-topic/host.d.ts.map +1 -1
  51. package/dist/src/cohort-topic/host.js +8 -7
  52. package/dist/src/cohort-topic/host.js.map +1 -1
  53. package/dist/src/cohort-topic/stream-util.d.ts +7 -6
  54. package/dist/src/cohort-topic/stream-util.d.ts.map +1 -1
  55. package/dist/src/cohort-topic/stream-util.js +14 -41
  56. package/dist/src/cohort-topic/stream-util.js.map +1 -1
  57. package/dist/src/dispute/cascade.d.ts +7 -8
  58. package/dist/src/dispute/cascade.d.ts.map +1 -1
  59. package/dist/src/dispute/cascade.js +24 -7
  60. package/dist/src/dispute/cascade.js.map +1 -1
  61. package/dist/src/dispute/dispute-service.d.ts +5 -0
  62. package/dist/src/dispute/dispute-service.d.ts.map +1 -1
  63. package/dist/src/dispute/dispute-service.js +13 -3
  64. package/dist/src/dispute/dispute-service.js.map +1 -1
  65. package/dist/src/dispute/invalidation.d.ts +33 -15
  66. package/dist/src/dispute/invalidation.d.ts.map +1 -1
  67. package/dist/src/dispute/invalidation.js +127 -34
  68. package/dist/src/dispute/invalidation.js.map +1 -1
  69. package/dist/src/dispute/service.d.ts.map +1 -1
  70. package/dist/src/dispute/service.js +2 -1
  71. package/dist/src/dispute/service.js.map +1 -1
  72. package/dist/src/index.d.ts +7 -0
  73. package/dist/src/index.d.ts.map +1 -1
  74. package/dist/src/index.js +7 -0
  75. package/dist/src/index.js.map +1 -1
  76. package/dist/src/libp2p-key-network.d.ts +78 -6
  77. package/dist/src/libp2p-key-network.d.ts.map +1 -1
  78. package/dist/src/libp2p-key-network.js +136 -57
  79. package/dist/src/libp2p-key-network.js.map +1 -1
  80. package/dist/src/libp2p-node-base.d.ts +38 -7
  81. package/dist/src/libp2p-node-base.d.ts.map +1 -1
  82. package/dist/src/libp2p-node-base.js +150 -62
  83. package/dist/src/libp2p-node-base.js.map +1 -1
  84. package/dist/src/logger.d.ts +2 -2
  85. package/dist/src/logger.js +2 -2
  86. package/dist/src/network/open-protocol-stream.d.ts +56 -0
  87. package/dist/src/network/open-protocol-stream.d.ts.map +1 -0
  88. package/dist/src/network/open-protocol-stream.js +60 -0
  89. package/dist/src/network/open-protocol-stream.js.map +1 -0
  90. package/dist/src/network/register-protocol-handler.d.ts +66 -0
  91. package/dist/src/network/register-protocol-handler.d.ts.map +1 -0
  92. package/dist/src/network/register-protocol-handler.js +51 -0
  93. package/dist/src/network/register-protocol-handler.js.map +1 -0
  94. package/dist/src/peer-address-book.d.ts +128 -1
  95. package/dist/src/peer-address-book.d.ts.map +1 -1
  96. package/dist/src/peer-address-book.js +198 -15
  97. package/dist/src/peer-address-book.js.map +1 -1
  98. package/dist/src/pend-validation.d.ts +65 -0
  99. package/dist/src/pend-validation.d.ts.map +1 -0
  100. package/dist/src/pend-validation.js +69 -0
  101. package/dist/src/pend-validation.js.map +1 -0
  102. package/dist/src/reactivity/notify-transport.d.ts.map +1 -1
  103. package/dist/src/reactivity/notify-transport.js +2 -1
  104. package/dist/src/reactivity/notify-transport.js.map +1 -1
  105. package/dist/src/reactivity/push-state-gossip.d.ts.map +1 -1
  106. package/dist/src/reactivity/push-state-gossip.js +2 -1
  107. package/dist/src/reactivity/push-state-gossip.js.map +1 -1
  108. package/dist/src/repo/cluster-coordinator.d.ts +32 -6
  109. package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
  110. package/dist/src/repo/cluster-coordinator.js +44 -10
  111. package/dist/src/repo/cluster-coordinator.js.map +1 -1
  112. package/dist/src/repo/coordinator-repo.d.ts +181 -25
  113. package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
  114. package/dist/src/repo/coordinator-repo.js +650 -62
  115. package/dist/src/repo/coordinator-repo.js.map +1 -1
  116. package/dist/src/repo/served-repo-proxy.d.ts +30 -0
  117. package/dist/src/repo/served-repo-proxy.d.ts.map +1 -0
  118. package/dist/src/repo/served-repo-proxy.js +50 -0
  119. package/dist/src/repo/served-repo-proxy.js.map +1 -0
  120. package/dist/src/repo/service.d.ts +22 -1
  121. package/dist/src/repo/service.d.ts.map +1 -1
  122. package/dist/src/repo/service.js +25 -13
  123. package/dist/src/repo/service.js.map +1 -1
  124. package/dist/src/reputation/types.d.ts +3 -1
  125. package/dist/src/reputation/types.d.ts.map +1 -1
  126. package/dist/src/reputation/types.js +3 -1
  127. package/dist/src/reputation/types.js.map +1 -1
  128. package/dist/src/rn.d.ts +24 -2
  129. package/dist/src/rn.d.ts.map +1 -1
  130. package/dist/src/rn.js +33 -4
  131. package/dist/src/rn.js.map +1 -1
  132. package/dist/src/routing/libp2p-known-peers.d.ts.map +1 -1
  133. package/dist/src/routing/libp2p-known-peers.js +5 -0
  134. package/dist/src/routing/libp2p-known-peers.js.map +1 -1
  135. package/dist/src/storage/block-archive.d.ts +153 -0
  136. package/dist/src/storage/block-archive.d.ts.map +1 -0
  137. package/dist/src/storage/block-archive.js +194 -0
  138. package/dist/src/storage/block-archive.js.map +1 -0
  139. package/dist/src/storage/block-latch.d.ts +92 -0
  140. package/dist/src/storage/block-latch.d.ts.map +1 -0
  141. package/dist/src/storage/block-latch.js +132 -0
  142. package/dist/src/storage/block-latch.js.map +1 -0
  143. package/dist/src/storage/block-storage.d.ts +169 -12
  144. package/dist/src/storage/block-storage.d.ts.map +1 -1
  145. package/dist/src/storage/block-storage.js +415 -152
  146. package/dist/src/storage/block-storage.js.map +1 -1
  147. package/dist/src/storage/cached-raw-storage.d.ts +5 -1
  148. package/dist/src/storage/cached-raw-storage.d.ts.map +1 -1
  149. package/dist/src/storage/cached-raw-storage.js +16 -1
  150. package/dist/src/storage/cached-raw-storage.js.map +1 -1
  151. package/dist/src/storage/cached-store-driver.d.ts +14 -4
  152. package/dist/src/storage/cached-store-driver.d.ts.map +1 -1
  153. package/dist/src/storage/cached-store-driver.js +39 -5
  154. package/dist/src/storage/cached-store-driver.js.map +1 -1
  155. package/dist/src/storage/i-block-storage.d.ts +70 -19
  156. package/dist/src/storage/i-block-storage.d.ts.map +1 -1
  157. package/dist/src/storage/i-block-storage.js +21 -1
  158. package/dist/src/storage/i-block-storage.js.map +1 -1
  159. package/dist/src/storage/i-raw-storage.d.ts +38 -0
  160. package/dist/src/storage/i-raw-storage.d.ts.map +1 -1
  161. package/dist/src/storage/kv-raw-storage.d.ts +14 -8
  162. package/dist/src/storage/kv-raw-storage.d.ts.map +1 -1
  163. package/dist/src/storage/kv-raw-storage.js +29 -9
  164. package/dist/src/storage/kv-raw-storage.js.map +1 -1
  165. package/dist/src/storage/memory-store-driver.d.ts +4 -1
  166. package/dist/src/storage/memory-store-driver.d.ts.map +1 -1
  167. package/dist/src/storage/memory-store-driver.js +22 -2
  168. package/dist/src/storage/memory-store-driver.js.map +1 -1
  169. package/dist/src/storage/raw-store-codec.js +2 -2
  170. package/dist/src/storage/raw-store-driver.d.ts +44 -3
  171. package/dist/src/storage/raw-store-driver.d.ts.map +1 -1
  172. package/dist/src/storage/shared-cache-pool.d.ts +60 -3
  173. package/dist/src/storage/shared-cache-pool.d.ts.map +1 -1
  174. package/dist/src/storage/shared-cache-pool.js +68 -4
  175. package/dist/src/storage/shared-cache-pool.js.map +1 -1
  176. package/dist/src/storage/storage-repo.d.ts +204 -26
  177. package/dist/src/storage/storage-repo.d.ts.map +1 -1
  178. package/dist/src/storage/storage-repo.js +422 -119
  179. package/dist/src/storage/storage-repo.js.map +1 -1
  180. package/dist/src/storage/store-identity.d.ts +21 -0
  181. package/dist/src/storage/store-identity.d.ts.map +1 -0
  182. package/dist/src/storage/store-identity.js +33 -0
  183. package/dist/src/storage/store-identity.js.map +1 -0
  184. package/dist/src/storage/struct.d.ts +15 -0
  185. package/dist/src/storage/struct.d.ts.map +1 -1
  186. package/dist/src/storage/with-read-cache.d.ts +92 -0
  187. package/dist/src/storage/with-read-cache.d.ts.map +1 -0
  188. package/dist/src/storage/with-read-cache.js +132 -0
  189. package/dist/src/storage/with-read-cache.js.map +1 -0
  190. package/dist/src/sync/service.d.ts +13 -3
  191. package/dist/src/sync/service.d.ts.map +1 -1
  192. package/dist/src/sync/service.js +7 -30
  193. package/dist/src/sync/service.js.map +1 -1
  194. package/dist/src/testing/mesh-harness.d.ts +75 -2
  195. package/dist/src/testing/mesh-harness.d.ts.map +1 -1
  196. package/dist/src/testing/mesh-harness.js +193 -81
  197. package/dist/src/testing/mesh-harness.js.map +1 -1
  198. package/dist/src/testing/raw-storage-conformance.d.ts +8 -0
  199. package/dist/src/testing/raw-storage-conformance.d.ts.map +1 -1
  200. package/dist/src/testing/raw-storage-conformance.js +97 -2
  201. package/dist/src/testing/raw-storage-conformance.js.map +1 -1
  202. package/package.json +5 -6
  203. package/src/cluster/block-transfer-service.ts +528 -312
  204. package/src/cluster/block-transfer.ts +547 -424
  205. package/src/cluster/certified-claims.ts +319 -0
  206. package/src/cluster/client-signature-verifier.ts +34 -0
  207. package/src/cluster/cluster-policy.ts +294 -203
  208. package/src/cluster/cluster-repo.ts +2501 -2034
  209. package/src/cluster/commit-proof.ts +344 -0
  210. package/src/cluster/quorum-restore.ts +348 -223
  211. package/src/cluster/rebalance-monitor.ts +539 -254
  212. package/src/cluster/reconcile-block.ts +404 -203
  213. package/src/cluster/service.ts +308 -293
  214. package/src/cluster/spread-on-churn.ts +352 -346
  215. package/src/cohort-topic/host.ts +8 -7
  216. package/src/cohort-topic/stream-util.ts +14 -43
  217. package/src/dispute/cascade.ts +31 -15
  218. package/src/dispute/dispute-service.ts +706 -696
  219. package/src/dispute/invalidation.ts +162 -52
  220. package/src/dispute/service.ts +126 -125
  221. package/src/index.ts +7 -0
  222. package/src/libp2p-key-network.ts +142 -58
  223. package/src/libp2p-node-base.ts +1793 -1675
  224. package/src/logger.ts +27 -27
  225. package/src/network/open-protocol-stream.ts +87 -0
  226. package/src/network/register-protocol-handler.ts +85 -0
  227. package/src/peer-address-book.ts +360 -149
  228. package/src/pend-validation.ts +89 -0
  229. package/src/reactivity/notify-transport.ts +145 -144
  230. package/src/reactivity/push-state-gossip.ts +292 -291
  231. package/src/repo/cluster-coordinator.ts +65 -11
  232. package/src/repo/coordinator-repo.ts +729 -71
  233. package/src/repo/served-repo-proxy.ts +55 -0
  234. package/src/repo/service.ts +332 -313
  235. package/src/reputation/types.ts +3 -1
  236. package/src/rn.ts +34 -4
  237. package/src/routing/libp2p-known-peers.ts +31 -26
  238. package/src/storage/block-archive.ts +242 -0
  239. package/src/storage/block-latch.ts +144 -0
  240. package/src/storage/block-storage.ts +787 -498
  241. package/src/storage/cached-raw-storage.ts +21 -1
  242. package/src/storage/cached-store-driver.ts +898 -859
  243. package/src/storage/i-block-storage.ts +172 -116
  244. package/src/storage/i-raw-storage.ts +40 -0
  245. package/src/storage/kv-raw-storage.ts +34 -9
  246. package/src/storage/memory-store-driver.ts +26 -2
  247. package/src/storage/raw-store-codec.ts +42 -42
  248. package/src/storage/raw-store-driver.ts +45 -3
  249. package/src/storage/shared-cache-pool.ts +516 -452
  250. package/src/storage/storage-repo.ts +1421 -1014
  251. package/src/storage/store-identity.ts +41 -0
  252. package/src/storage/struct.ts +52 -34
  253. package/src/storage/with-read-cache.ts +182 -0
  254. package/src/sync/service.ts +178 -198
  255. package/src/testing/cohort-topic-mesh-harness.ts +673 -673
  256. package/src/testing/mesh-harness.ts +524 -344
  257. package/src/testing/raw-storage-conformance.ts +114 -2
@@ -1,5 +1,5 @@
1
1
  import { peerIdFromString } from '@libp2p/peer-id';
2
- import { BlockTransferClient } from './block-transfer-service.js';
2
+ import { BlockTransferClient, sourceBlockCertification } from './block-transfer-service.js';
3
3
  import { createLogger } from '../logger.js';
4
4
  const log = createLogger('block-transfer');
5
5
  /**
@@ -24,7 +24,15 @@ export class BlockTransferCoordinator {
24
24
  inFlight = new Set();
25
25
  concurrency = 0;
26
26
  waitQueue = [];
27
- constructor(repo, peerNetwork, restorationCoordinator, partitionDetector, protocolPrefix = '', config = {}) {
27
+ constructor(
28
+ /**
29
+ * The node's OWN store, proof accessor REQUIRED (not the optional `ArchiveServingRepo`
30
+ * shape): every push this class makes is certified out of it, and a repo without the
31
+ * accessor would make `sourceBlockCertification` return meta-only for every block — so
32
+ * every push would be refused by a receiver running the default `requirePushCertificate`,
33
+ * silently and with no type error. Same reasoning as `createServedRepoProxy`'s.
34
+ */
35
+ repo, peerNetwork, restorationCoordinator, partitionDetector, protocolPrefix = '', config = {}) {
28
36
  this.repo = repo;
29
37
  this.peerNetwork = peerNetwork;
30
38
  this.restorationCoordinator = restorationCoordinator;
@@ -78,21 +86,92 @@ export class BlockTransferCoordinator {
78
86
  * hole (`docs/arachnode-ring-handoff.md` § Why the current code violates it #2).
79
87
  */
80
88
  async handleRebalanceEvent(event) {
81
- log('rebalance:start gained=%d lost=%d floor=%d', event.gained.length, event.lost.length, event.floor);
89
+ log('rebalance:start gained=%d lost=%d grown=%d floor=%d', event.gained.length, event.lost.length, event.grown.size, event.floor);
82
90
  const floor = Math.max(1, event.floor);
83
- const [pullResult, confirmResult] = await Promise.all([
91
+ const [pullResult, confirmResult, growResult] = await Promise.all([
84
92
  event.gained.length > 0 ? this.pullBlocks(event.gained) : { succeeded: [], failed: [] },
85
93
  event.lost.length > 0 && event.newOwners.size > 0
86
94
  ? this.confirmReplicated(event.lost, event.newOwners, floor)
87
- : { confirmed: [], unconfirmed: [...event.lost] }
95
+ : { confirmed: [], unconfirmed: [...event.lost] },
96
+ this.replicateGrown(event.grown, floor)
88
97
  ]);
89
- log('rebalance:done pull=%d/%d released=%d/%d', pullResult.succeeded.length, event.gained.length, confirmResult.confirmed.length, event.lost.length);
98
+ log('rebalance:done pull=%d/%d released=%d/%d replicated=%d/%d', pullResult.succeeded.length, event.gained.length, confirmResult.confirmed.length, event.lost.length, growResult.confirmed.length, event.grown.size);
90
99
  return {
91
100
  pulled: pullResult.succeeded,
92
101
  released: confirmResult.confirmed,
93
- retained: confirmResult.unconfirmed
102
+ retained: confirmResult.unconfirmed,
103
+ replicated: growResult.confirmed,
104
+ underReplicated: growResult.unconfirmed,
105
+ growth: growResult.growth
94
106
  };
95
107
  }
108
+ /**
109
+ * Push each GROWN block (still owned; new peers became co-responsible) to its newly
110
+ * co-responsible peers, reusing {@link executeConfirm} per block. The per-block floor is
111
+ * `min(event floor, new-peer count)`: passing the raw event floor would be wrong when fewer new
112
+ * peers exist than the floor — `executeConfirm` could then never reach the floor and would burn
113
+ * `maxRetries` re-pushing peers that already accepted. Nothing is released off this path (the
114
+ * node KEEPS the block either way); the confirmed/unconfirmed split is reporting only. The
115
+ * in-flight `confirm:<id>` key dedups against a concurrent lost-confirm for the same block —
116
+ * such a block gets NO `growth` entry (no information), so the monitor leaves it untouched.
117
+ * `enablePush` deliberately does not gate this (same rationale as the NOTE in
118
+ * {@link confirmReplicated}); the growth arm as a whole is gated by the `rebalance.enabled`
119
+ * wiring in `libp2p-node-base`.
120
+ *
121
+ * Per-block {@link GrowthOutcome} rules:
122
+ * - floor met → all reported peers satisfied, complete. Deliberately includes peers
123
+ * `executeConfirm` skipped once the floor was reached — the block is adequately replicated,
124
+ * and re-pushing the remainder on every check forever would be a live loop.
125
+ * - no local data → all reported peers satisfied, complete (nothing to replicate; see NOTE).
126
+ * - otherwise → only the peers that actually confirmed, incomplete (retried by the monitor).
127
+ */
128
+ async replicateGrown(grown, floor) {
129
+ const confirmed = [];
130
+ const unconfirmed = [];
131
+ const growth = new Map();
132
+ if (grown.size === 0) {
133
+ return { confirmed, unconfirmed, growth };
134
+ }
135
+ if (this.partitionDetector.detectPartition()) {
136
+ // Mirrors confirmReplicated's guard (replicateGrown drives executeConfirm directly). An
137
+ // incomplete outcome with nothing satisfied keeps every reported peer un-seen AND counts an
138
+ // attempt, so a partition mid-reaction is retried like any other failed push.
139
+ log('grow:partition-detected, leaving %d blocks unconfirmed', grown.size);
140
+ for (const [blockId, newPeers] of grown) {
141
+ if (newPeers.length === 0)
142
+ continue;
143
+ unconfirmed.push(blockId);
144
+ growth.set(blockId, { satisfiedPeers: [], complete: false });
145
+ }
146
+ return { confirmed, unconfirmed, growth };
147
+ }
148
+ await Promise.all([...grown.entries()].map(async ([blockId, newPeers]) => {
149
+ if (newPeers.length === 0)
150
+ return;
151
+ const result = await this.executeConfirm(blockId, new Map([[blockId, newPeers]]), Math.min(floor, newPeers.length) // both ≥ 1 here: the caller clamps floor, empty newPeers returned above
152
+ );
153
+ if (result === null)
154
+ return; // confirm already in flight — no information, no entry
155
+ if (result.confirmed) {
156
+ confirmed.push(blockId);
157
+ growth.set(blockId, { satisfiedPeers: [...newPeers], complete: true });
158
+ }
159
+ else if (result.noLocalData) {
160
+ // NOTE: nothing local to replicate (the gained∩grown first-observation case) — the
161
+ // reported peers are recorded satisfied so this does not become a permanent retry loop
162
+ // (those cohort peers are the pull's own source). If the node later obtains the block by
163
+ // another route (a fresh local commit, a spread push), these peers stay recorded and are
164
+ // never pushed — benign today, since a gained block's data comes from these very peers.
165
+ unconfirmed.push(blockId);
166
+ growth.set(blockId, { satisfiedPeers: [...newPeers], complete: true });
167
+ }
168
+ else {
169
+ unconfirmed.push(blockId);
170
+ growth.set(blockId, { satisfiedPeers: [...result.confirmedPeers], complete: false });
171
+ }
172
+ }));
173
+ return { confirmed, unconfirmed, growth };
174
+ }
96
175
  /**
97
176
  * Confirm each block is replicated to at least `floor` qualifying owners — the gate the ring-shift
98
177
  * handoff (Phase B) and the rebalance release both open before a block may stop being served.
@@ -127,7 +206,12 @@ export class BlockTransferCoordinator {
127
206
  const confirmed = [];
128
207
  const unconfirmed = [];
129
208
  const ids = blockIds.filter(id => !this.inFlight.has(`confirm:${id}`));
130
- await Promise.all(ids.map(id => this.executeConfirm(id, owners, floor, confirmed, unconfirmed)));
209
+ await Promise.all(ids.map(async (id) => {
210
+ const result = await this.executeConfirm(id, owners, floor);
211
+ if (result === null)
212
+ return; // raced into flight after the filter — no information
213
+ (result.confirmed ? confirmed : unconfirmed).push(id);
214
+ }));
131
215
  return { confirmed, unconfirmed };
132
216
  }
133
217
  async executePull(blockId, succeeded, failed) {
@@ -188,12 +272,17 @@ export class BlockTransferCoordinator {
188
272
  return;
189
273
  }
190
274
  const blockData = new TextEncoder().encode(JSON.stringify(blockResult.block));
275
+ // Revision metadata AND the cohort proof for that revision, from this one unpinned
276
+ // read. A receiver running the default `requirePushCertificate` rejects a push with
277
+ // no proof, so a block whose proof this node never retained (pre-proof history, a
278
+ // diverged commit) simply fails to place here and is retried/kept as today.
279
+ const certification = await sourceBlockCertification(this.repo, blockId, blockResult);
191
280
  // Push to at least one new owner
192
281
  for (const ownerPeerIdStr of owners) {
193
282
  try {
194
283
  const peerId = peerIdFromString(ownerPeerIdStr);
195
284
  const client = new BlockTransferClient(peerId, this.peerNetwork, this.protocolPrefix);
196
- const response = await this.withTimeout(client.pushBlocks([blockId], [blockData]), this.transferTimeoutMs);
285
+ const response = await this.withTimeout(client.pushBlocks([blockId], [blockData], 'rebalance', certification), this.transferTimeoutMs);
197
286
  if (response && !response.missing.includes(blockId)) {
198
287
  pushed = true;
199
288
  log('push:ok block=%s peer=%s', blockId, ownerPeerIdStr);
@@ -227,22 +316,29 @@ export class BlockTransferCoordinator {
227
316
  }
228
317
  }
229
318
  /**
230
- * Confirm one block replicated to ≥ `floor` distinct qualifying owners. Reads the local block once,
231
- * pushes to each candidate owner (stopping once the floor is reached), and counts distinct owners
232
- * that report holding it (not `missing`). Retries the whole round up to `maxRetries` before giving
233
- * up. Records the block in `confirmed` iff the floor was met, otherwise in `unconfirmed`.
319
+ * Confirm one block replicated to ≥ `floor` distinct qualifying owners. Reads the local block once
320
+ * per attempt, pushes to each candidate owner (stopping once the floor is reached), and counts
321
+ * distinct owners that report holding it (not `missing`). Retries the whole round up to
322
+ * `maxRetries` before giving up.
323
+ *
324
+ * Returns `null` when a confirm for this block is already in flight (no information — the caller
325
+ * must not record anything for it). Otherwise: `confirmed` iff the floor was met; `confirmedPeers`
326
+ * is the union of owners that confirmed across every attempt (a peer that accepted a push holds a
327
+ * replica even if a later round missed it — the floor decision itself stays per-round, unchanged);
328
+ * `noLocalData` marks the nothing-local-to-push case. The lost-block release path uses only
329
+ * `confirmed`; the growth arm consumes the other two.
234
330
  */
235
- async executeConfirm(blockId, owners, floor, confirmed, unconfirmed) {
331
+ async executeConfirm(blockId, owners, floor) {
236
332
  const key = `confirm:${blockId}`;
237
333
  if (this.inFlight.has(key))
238
- return;
334
+ return null;
239
335
  this.inFlight.add(key);
240
336
  try {
337
+ const allConfirmedPeers = new Set();
241
338
  const candidateOwners = owners.get(blockId) ?? [];
242
339
  if (candidateOwners.length === 0) {
243
340
  // No qualifying holder to confirm against — cannot release; keep serving.
244
- unconfirmed.push(blockId);
245
- return;
341
+ return { confirmed: false, confirmedPeers: allConfirmedPeers, noLocalData: false };
246
342
  }
247
343
  for (let attempt = 0;; attempt++) {
248
344
  await this.acquireSemaphore();
@@ -254,10 +350,12 @@ export class BlockTransferCoordinator {
254
350
  if (!blockResult?.block) {
255
351
  // No local bytes to prove replication with — cannot confirm; keep serving.
256
352
  log('confirm:no-local-data block=%s', blockId);
257
- unconfirmed.push(blockId);
258
- return;
353
+ return { confirmed: false, confirmedPeers: allConfirmedPeers, noLocalData: true };
259
354
  }
260
355
  const blockData = new TextEncoder().encode(JSON.stringify(blockResult.block));
356
+ // See executePush: meta + proof are built together from this one unpinned read, so a
357
+ // confirming holder either takes a certified replica or reports the block missing.
358
+ const certification = await sourceBlockCertification(this.repo, blockId, blockResult);
261
359
  // Count DISTINCT owners that hold a current replica; stop once the floor is reached.
262
360
  const confirmedPeers = new Set();
263
361
  for (const ownerPeerIdStr of candidateOwners) {
@@ -266,9 +364,16 @@ export class BlockTransferCoordinator {
266
364
  try {
267
365
  const peerId = peerIdFromString(ownerPeerIdStr);
268
366
  const client = new BlockTransferClient(peerId, this.peerNetwork, this.protocolPrefix);
269
- const response = await this.withTimeout(client.pushBlocks([blockId], [blockData]), this.transferTimeoutMs);
367
+ const response = await this.withTimeout(client.pushBlocks([blockId], [blockData], 'rebalance', certification), this.transferTimeoutMs);
270
368
  if (response && !response.missing.includes(blockId)) {
271
369
  confirmedPeers.add(ownerPeerIdStr);
370
+ // NOTE: allConfirmedPeers never un-records a peer. A holder that confirms in one
371
+ // round and reports `missing` in a later one stays recorded, on the reasoning that
372
+ // `handlePush` answers non-missing only after persisting. If the receiver ever
373
+ // gains a path that drops a just-persisted block (an eviction sweep, a rejected
374
+ // revision), the growth arm would record a peer that no longer holds a replica —
375
+ // intersect against the LAST round's confirmedPeers instead of unioning.
376
+ allConfirmedPeers.add(ownerPeerIdStr);
272
377
  }
273
378
  }
274
379
  catch (err) {
@@ -282,8 +387,7 @@ export class BlockTransferCoordinator {
282
387
  }
283
388
  if (confirmCount >= floor) {
284
389
  log('confirm:ok block=%s holders=%d/%d', blockId, confirmCount, floor);
285
- confirmed.push(blockId);
286
- return;
390
+ return { confirmed: true, confirmedPeers: allConfirmedPeers, noLocalData: false };
287
391
  }
288
392
  if (attempt < this.maxRetries) {
289
393
  log('confirm:retry block=%s holders=%d/%d attempt=%d', blockId, confirmCount, floor, attempt + 1);
@@ -291,8 +395,7 @@ export class BlockTransferCoordinator {
291
395
  continue;
292
396
  }
293
397
  log('confirm:unmet block=%s holders=%d/%d', blockId, confirmCount, floor);
294
- unconfirmed.push(blockId);
295
- return;
398
+ return { confirmed: false, confirmedPeers: allConfirmedPeers, noLocalData: false };
296
399
  }
297
400
  }
298
401
  finally {
@@ -1 +1 @@
1
- {"version":3,"file":"block-transfer.js","sourceRoot":"","sources":["../../../src/cluster/block-transfer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,GAAG,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;AA6B3C;;;;;;;;GAQG;AACH,MAAM,OAAO,wBAAwB;IAUlB;IACA;IACA;IACA;IACA;IAbD,cAAc,CAAS;IACvB,iBAAiB,CAAS;IAC1B,UAAU,CAAS;IACnB,UAAU,CAAU;IAC7B,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAC7B,WAAW,GAAG,CAAC,CAAC;IACP,SAAS,GAAsB,EAAE,CAAC;IAEnD,YACkB,IAAW,EACX,WAAyB,EACzB,sBAA8C,EAC9C,iBAAoC,EACpC,iBAAyB,EAAE,EAC5C,SAA8B,EAAE;QALf,SAAI,GAAJ,IAAI,CAAO;QACX,gBAAW,GAAX,WAAW,CAAc;QACzB,2BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,mBAAc,GAAd,cAAc,CAAa;QAG5C,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,IAAI,KAAK,CAAC;QAC3D,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,MAAM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,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO;QACR,CAAC;QACD,MAAM,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC,WAAW,EAAE,CAAC;IACpB,CAAC;IAEO,gBAAgB;QACvB,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACpC,IAAI,IAAI;YAAE,IAAI,EAAE,CAAC;IAClB,CAAC;IAED,kBAAkB;IAEV,SAAS,CAAC,OAAe;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;IAEO,KAAK,CAAC,EAAU;QACvB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;IAEO,WAAW,CAAI,OAAmB,EAAE,EAAU;QACrD,OAAO,OAAO,CAAC,IAAI,CAAC;YACnB,OAAO;YACP,IAAI,OAAO,CAAY,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;SAC3E,CAAC,CAAC;IACJ,CAAC;CACD"}
@@ -0,0 +1,170 @@
1
+ import type { ActionId, BlockId, IBlock } from "@optimystic/db-core";
2
+ import { type BlockCommitProof, type ProofClaim, type ProofFailure, type ProofThresholds } from "./commit-proof.js";
3
+ /**
4
+ * Certification of repair claims by cohort commit proof — the shared layer both block-restoration
5
+ * paths (read-repair in `CoordinatorRepo`, reconcile in `reconcile-block`) run a peer-attached
6
+ * {@link BlockCommitProof} through before marking a `RevClaim` / `BlockHashCandidate` as
7
+ * `certified` for the selection helpers in `quorum-restore.ts`.
8
+ *
9
+ * Mirrors the layered posture of `verifyInvalidationCertificate` (`dispute/invalidation.ts`):
10
+ *
11
+ * - **Layer 1 (always)**: offline cryptographic verification — thresholds of Ed25519 votes from
12
+ * the proof's own signer list (`verifyBlockCommitProofClaim` / `...Content`), preceded by the
13
+ * {@link MAX_PROOF_SIGNERS} cap this module owes the verifier (its caller obligation #2:
14
+ * verification cost is attacker-chosen, so bound the cohort BEFORE any hashing).
15
+ * - **Layer 2 (optional, observational)**: {@link ProofAnchoring.recomputeBlockCohort} re-derives
16
+ * the block's cohort from the caller's own topology view and the overlap with the proof's
17
+ * signers is LOGGED — never gated on. Historic cohort rotation makes zero overlap legitimate
18
+ * for old data; gating would re-create the very lone-holder-unreadable defect the certified
19
+ * path exists to fix. Like invalidation's `recomputeArbitratorSet`, no production caller wires
20
+ * this yet (see the note at the `clusterMember` construction in `libp2p-node-base.ts`).
21
+ * - **Degradation**: with no recompute capability, or an infeasible recompute, an accepted proof
22
+ * is certified anyway but never silently — logged, and surfaced via
23
+ * {@link ProofAnchoring.onUnanchored} so callers can count/report the residual, exactly as
24
+ * invalidation's `acceptUnanchored` does.
25
+ */
26
+ /**
27
+ * Verdict from a {@link RecomputeBlockCohort}:
28
+ * - `{ feasible: false }` — the caller could not re-derive the block's current cohort (no routing
29
+ * view, lookup failed); anchoring degrades to accept-and-surface.
30
+ * - `{ feasible: true, cohortPeerIds }` — the currently-derived cohort, compared (log-only)
31
+ * against the proof's signer list.
32
+ */
33
+ export type CohortRecomputeVerdict = {
34
+ readonly feasible: false;
35
+ } | {
36
+ readonly feasible: true;
37
+ readonly cohortPeerIds: string[];
38
+ };
39
+ /**
40
+ * Injected layer-2 capability: re-derive the block's responsible cohort from the caller's own
41
+ * topology view. A real implementation would come from `IKeyNetwork.findCluster` — the same source
42
+ * `deriveExpectedCluster` uses in `libp2p-node-base.ts`. NOT wired in production yet; the overlap
43
+ * it enables is observational (logged), never a gate.
44
+ */
45
+ export type RecomputeBlockCohort = (blockId: BlockId) => Promise<CohortRecomputeVerdict>;
46
+ /** Reported when a proof is accepted on layer-1 cryptography alone — see {@link ProofAnchoring.onUnanchored}. */
47
+ export type UnanchoredProofAcceptance = {
48
+ readonly blockId: BlockId;
49
+ readonly rev: number;
50
+ readonly actionId: ActionId;
51
+ /** Size of the proof's signer list (`proof.peerIds.length`). */
52
+ readonly signerCount: number;
53
+ /** Why the anchoring layer did not run to a comparison. */
54
+ readonly reason: 'no-recompute-capability' | 'recompute-infeasible';
55
+ };
56
+ /** Optional anchoring capabilities a caller threads into {@link certifyClaim} / {@link certifyContent}. */
57
+ export type ProofAnchoring = {
58
+ /** Layer-2 recompute; omitted → layer-1-only certification with the documented surfacing. */
59
+ readonly recomputeBlockCohort?: RecomputeBlockCohort;
60
+ /**
61
+ * Invoked when a proof is accepted without a cohort comparison (capability absent or
62
+ * infeasible). Lets a caller surface "certified a claim it could not anchor to topology"
63
+ * alongside the internal log. Exceptions thrown from it are swallowed (logged), never allowed
64
+ * to un-certify an already-verified proof.
65
+ */
66
+ readonly onUnanchored?: (info: UnanchoredProofAcceptance) => void;
67
+ };
68
+ /** Everything {@link ProofFailure} names, plus the pre-verification cap decline this module adds. */
69
+ export type CertifyFailure = ProofFailure | 'oversized-cohort';
70
+ /**
71
+ * Hard bound on `proof.peerIds.length`, enforced BEFORE any hashing or signature work. Nothing on
72
+ * the repair wire bounds a proof's cohort count — only byte caps apply (1 MiB control / 8 MiB sync
73
+ * response), which would still admit ~80k signature verifications — so this module enforces the
74
+ * bound `commit-proof.ts` declares as its caller obligation #2. 256 is far above any plausible
75
+ * cohort (deployments run ~10) while keeping the worst-case verification cost trivial.
76
+ *
77
+ * NOTE: this cap bounds the SIGNATURE count (at most `MAX_PROOF_SIGNERS` Ed25519 verifies per
78
+ * round, since `countApprovals` skips signers outside `peerIds` before any crypto). It does NOT
79
+ * bound the proof's serialized SIZE: `computeClusterMessageHash` / `...PromiseHash` /
80
+ * `...CommitHash` canonically serialize `message`, `promises` and `commits`, whose entry counts a
81
+ * peer chooses freely inside the transport byte cap. That cost is linear and today bounded by the
82
+ * 1 MiB control-message cap; if repair verification ever shows up in a profile, or a deployment
83
+ * raises those transport caps, add a serialized-size bound here alongside the signer count.
84
+ */
85
+ export declare const MAX_PROOF_SIGNERS = 256;
86
+ /**
87
+ * Failure reasons that must NEVER become a reputation penalty for the serving peer — the `false`
88
+ * half of {@link ATTRIBUTABLE_PROOF_FAILURES}, derived so the set and
89
+ * {@link isAttributableProofFailure} cannot drift apart. Prefer the predicate; this set is exported
90
+ * for callers that want to name the whole population (logs, tests).
91
+ */
92
+ export declare const NON_ATTRIBUTABLE_PROOF_FAILURES: ReadonlySet<CertifyFailure>;
93
+ /**
94
+ * May this failure be held against the peer that served the proof? One predicate so the two repair
95
+ * paths cannot drift on the classification — see {@link ATTRIBUTABLE_PROOF_FAILURES} for the
96
+ * per-reason rationale.
97
+ */
98
+ export declare function isAttributableProofFailure(failure: CertifyFailure): boolean;
99
+ /**
100
+ * The {@link ProofThresholds} both repair paths verify against, from the cohort's configured
101
+ * `superMajorityThreshold`.
102
+ *
103
+ * `simpleMajorityThreshold` is hardcoded 0.5 — NOT the deployment's configured value (0.51 by
104
+ * default): cohort members enforce `count > total / 2` (`ClusterMember.hasMajority`), and
105
+ * `ProofThresholds` requires a verifier to mirror what the members actually enforced. Verifying
106
+ * against the configured value would reject proofs real cohorts produce.
107
+ *
108
+ * One function so the read path (`CoordinatorRepo.queryClusterForLatest`) and the commit-path
109
+ * reconcile (`cluster/reconcile-block.ts`) cannot drift on the one number that has to match
110
+ * `hasMajority`.
111
+ */
112
+ export declare function proofThresholds(superMajorityThreshold: number): ProofThresholds;
113
+ /**
114
+ * Certification verdict for a claim — a discriminated union, mirroring `ProofVerdict`
115
+ * (`commit-proof.ts`) so "certified" and "why not" cannot disagree: a failure reason is REQUIRED
116
+ * when uncertified and unrepresentable when certified.
117
+ */
118
+ export type ClaimCertification =
119
+ /** The proof certifies `claim` — cap passed, thresholds of valid cohort signatures met. */
120
+ {
121
+ certified: true;
122
+ }
123
+ /** Classify the reason via {@link isAttributableProofFailure} before penalizing anyone. */
124
+ | {
125
+ certified: false;
126
+ failure: CertifyFailure;
127
+ };
128
+ /**
129
+ * Certification verdict for a claim AND the block bytes served for it. Three reachable outcomes,
130
+ * spelled as three arms so an impossible mix (content certified while the rev is not, a failure
131
+ * alongside full success) cannot be constructed:
132
+ */
133
+ export type ContentCertification =
134
+ /** Both halves passed: the proof certifies `(blockId, rev, actionId)` AND these exact bytes. */
135
+ {
136
+ revCertified: true;
137
+ contentCertified: true;
138
+ }
139
+ /**
140
+ * The claim half passed, the content half did not: `digest-mismatch` (attributable — drop AND
141
+ * penalize the served bytes) or `no-digest-declared` (drop only; the cohort declared nothing to
142
+ * compare against). The `(rev, actionId)` is certified either way.
143
+ */
144
+ | {
145
+ revCertified: true;
146
+ contentCertified: false;
147
+ failure: 'digest-mismatch' | 'no-digest-declared';
148
+ }
149
+ /** The claim half failed, so nothing is certified. Classify via {@link isAttributableProofFailure}. */
150
+ | {
151
+ revCertified: false;
152
+ contentCertified: false;
153
+ failure: CertifyFailure;
154
+ };
155
+ /**
156
+ * Certify a repair claim by its attached cohort commit proof: cap the cohort, verify offline
157
+ * ({@link verifyBlockCommitProofClaim}), then run the anchoring layer on success. Total on hostile
158
+ * input like the verifier it wraps — never throws.
159
+ */
160
+ export declare function certifyClaim(proof: BlockCommitProof, claim: ProofClaim, thresholds: ProofThresholds, anchoring?: ProofAnchoring): Promise<ClaimCertification>;
161
+ /**
162
+ * Certify a claim AND the served block bytes ({@link verifyBlockCommitProofContent}). The two
163
+ * halves are reported separately because the content checks (`digest-mismatch` /
164
+ * `no-digest-declared`) only run after the claim half has already PASSED — a proof that certifies
165
+ * the revision while the bytes disagree still certifies the revision; the caller drops (and, for
166
+ * `digest-mismatch`, penalizes) the bytes. Anchoring runs whenever the claim half passed: that is
167
+ * the moment a proof was accepted as evidence.
168
+ */
169
+ export declare function certifyContent(proof: BlockCommitProof, claim: ProofClaim, block: IBlock, thresholds: ProofThresholds, anchoring?: ProofAnchoring): Promise<ContentCertification>;
170
+ //# sourceMappingURL=certified-claims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certified-claims.d.ts","sourceRoot":"","sources":["../../../src/cluster/certified-claims.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAEN,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAC/E,MAAM,mBAAmB,CAAC;AAK3B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAC/B;IAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEzF,iHAAiH;AACjH,MAAM,MAAM,yBAAyB,GAAG;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,sBAAsB,CAAC;CACpE,CAAC;AAEF,2GAA2G;AAC3G,MAAM,MAAM,cAAc,GAAG;IAC5B,6FAA6F;IAC7F,QAAQ,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;I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