Commit f9f33d3
feat: implement proximity-based update forwarding
Peers that cache contracts via PUT/GET may not establish proper upstream
subscriptions for updates, creating "disconnected subtrees" that never
receive updates. This PR fixes that by introducing a proximity cache
protocol.
## Problem
When a peer calls `seed_contract()` to cache a contract locally, it does
NOT automatically establish an upstream subscription in the broadcast
tree. Result: a peer can cache a contract but have no path to receive
UPDATEs for it.
## Solution
Introduce `ProximityCacheManager` that:
1. Tracks which contracts each neighbor has cached
2. Announces cache state changes to neighbors via new `ProximityCache`
messages
3. Enhances UPDATE forwarding to include proximity neighbors alongside
explicit subscribers
The subscription tree (explicit downstream interest) and proximity cache
(nearby seeders) remain independent mechanisms, combined only at the
broadcast targeting point using HashSet deduplication.
## Changes
- Add `ProximityCacheMessage` protocol (CacheAnnounce, CacheStateRequest,
CacheStateResponse)
- Add `ProximityCacheManager` to track neighbor contract caches
- Integrate into OpManager and message routing
- Call `announce_contract_cached()` after `seed_contract()` in PUT/GET
- Enhance `get_broadcast_targets_update()` to include proximity neighbors
Supersedes #2002 (fresh implementation due to 109-commit divergence and
PeerId→PeerKeyLocation routing refactor).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 42bfc46 commit f9f33d3
File tree
10 files changed
+528
-12
lines changed- crates/core/src
- node
- network_bridge
- operations
10 files changed
+528
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
333 | 335 | | |
334 | 336 | | |
335 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
336 | 362 | | |
337 | 363 | | |
338 | 364 | | |
| |||
357 | 383 | | |
358 | 384 | | |
359 | 385 | | |
| 386 | + | |
360 | 387 | | |
361 | 388 | | |
362 | 389 | | |
| |||
416 | 443 | | |
417 | 444 | | |
418 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
419 | 450 | | |
420 | 451 | | |
421 | 452 | | |
| |||
495 | 526 | | |
496 | 527 | | |
497 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
498 | 532 | | |
499 | 533 | | |
500 | 534 | | |
| |||
529 | 563 | | |
530 | 564 | | |
531 | 565 | | |
| 566 | + | |
532 | 567 | | |
533 | 568 | | |
534 | 569 | | |
| |||
541 | 576 | | |
542 | 577 | | |
543 | 578 | | |
| 579 | + | |
544 | 580 | | |
545 | 581 | | |
546 | 582 | | |
| |||
553 | 589 | | |
554 | 590 | | |
555 | 591 | | |
| 592 | + | |
556 | 593 | | |
557 | 594 | | |
558 | 595 | | |
| |||
572 | 609 | | |
573 | 610 | | |
574 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
575 | 615 | | |
576 | 616 | | |
577 | 617 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
864 | 865 | | |
865 | 866 | | |
866 | 867 | | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
867 | 875 | | |
868 | 876 | | |
869 | 877 | | |
| |||
1105 | 1113 | | |
1106 | 1114 | | |
1107 | 1115 | | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
1108 | 1140 | | |
1109 | 1141 | | |
1110 | 1142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1271 | 1271 | | |
1272 | 1272 | | |
1273 | 1273 | | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
1274 | 1295 | | |
1275 | 1296 | | |
1276 | 1297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
| 219 | + | |
| 220 | + | |
216 | 221 | | |
217 | 222 | | |
218 | 223 | | |
| |||
228 | 233 | | |
229 | 234 | | |
230 | 235 | | |
| 236 | + | |
231 | 237 | | |
232 | 238 | | |
233 | 239 | | |
| |||
284 | 290 | | |
285 | 291 | | |
286 | 292 | | |
| 293 | + | |
| 294 | + | |
287 | 295 | | |
288 | 296 | | |
289 | 297 | | |
| |||
295 | 303 | | |
296 | 304 | | |
297 | 305 | | |
| 306 | + | |
298 | 307 | | |
299 | 308 | | |
300 | 309 | | |
| |||
0 commit comments