Commit e577fe0
fix: robust syncing, misc changes (#591)
* fix: robust syncing
* fix recency calc for fc tree log
* chain: queue gossip blocks that arrive before forkchoice ticks to the… (#593)
* chain: queue gossip blocks that arrive before forkchoice ticks to their slot
When a peer gossips a block for slot N and our local interval timer
hasn't yet advanced the forkchoice clock to N*INTERVALS_PER_SLOT,
forkChoice.onBlockUnlocked returns FutureSlot and the block is dropped.
Fix by queuing such blocks in BeamChain.pending_blocks (an ArrayList
of SSZ-cloned SignedBlockWithAttestation). After validateBlock passes,
we check if block.slot * INTERVALS_PER_SLOT > fcStore.time; if so the
block is cloned into the queue instead of being processed immediately.
In onInterval, after forkChoice.onInterval has advanced the clock, the
new processPendingBlocks helper iterates the queue and replays every
entry whose slot is now reachable (slot * INTERVALS_PER_SLOT <= fc_time)
by calling onBlock + onBlockFollowup in the normal way. Entries still
in the future stay in the queue for the next tick.
https://claude.ai/code/session_0116R4pk8fiu5Ve5PAfjE3op
* node: call processPendingBlocks from onInterval and fetch missing roots
Move the processPendingBlocks call out of chain.onInterval and into
node.onInterval so that any missing attestation-head roots discovered
while replaying queued blocks can be immediately fetched via
fetchBlockByRoots, mirroring the pattern used after onGossip in
handleGossipProcessingResult.
- Make processPendingBlocks pub and change its return type from void to
[]types.Root, accumulating all missing roots across every replayed
block into a single caller-owned slice.
- Remove the processPendingBlocks call from chain.onInterval (it now
belongs to the node layer).
- In node.onInterval, call chain.processPendingBlocks() right after
chain.onInterval() and pass the returned roots to fetchBlockByRoots.
https://claude.ai/code/session_0116R4pk8fiu5Ve5PAfjE3op
---------
Co-authored-by: Claude <noreply@anthropic.com>
* further improvs
* remove redudant check and improve the comment
---------
Co-authored-by: harkamal <gajinder@zeam.in>
Co-authored-by: zclawz <claw@zeam.in>
Co-authored-by: Claude <noreply@anthropic.com>1 parent f05c9dd commit e577fe0
File tree
10 files changed
+344
-65
lines changed- .github/workflows
- pkgs
- api/src
- cli/test
- node/src
- types/src
10 files changed
+344
-65
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
| 208 | + | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
280 | 280 | | |
281 | | - | |
| 281 | + | |
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | | - | |
| 318 | + | |
319 | 319 | | |
320 | | - | |
| 320 | + | |
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | | - | |
| 130 | + | |
132 | 131 | | |
133 | 132 | | |
134 | | - | |
| 133 | + | |
135 | 134 | | |
136 | 135 | | |
137 | 136 | | |
| |||
552 | 551 | | |
553 | 552 | | |
554 | 553 | | |
| 554 | + | |
| 555 | + | |
555 | 556 | | |
556 | 557 | | |
557 | 558 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
| |||
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
| 77 | + | |
72 | 78 | | |
73 | | - | |
| 79 | + | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
79 | 85 | | |
| 86 | + | |
80 | 87 | | |
81 | 88 | | |
82 | 89 | | |
| |||
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
88 | 98 | | |
89 | 99 | | |
90 | 100 | | |
| |||
104 | 114 | | |
105 | 115 | | |
106 | 116 | | |
| 117 | + | |
107 | 118 | | |
108 | | - | |
| 119 | + | |
109 | 120 | | |
110 | 121 | | |
111 | 122 | | |
112 | 123 | | |
113 | 124 | | |
114 | 125 | | |
| 126 | + | |
115 | 127 | | |
116 | 128 | | |
117 | 129 | | |
| |||
120 | 132 | | |
121 | 133 | | |
122 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
123 | 138 | | |
124 | 139 | | |
125 | 140 | | |
| |||
217 | 232 | | |
218 | 233 | | |
219 | 234 | | |
220 | | - | |
| 235 | + | |
221 | 236 | | |
222 | 237 | | |
223 | 238 | | |
| |||
237 | 252 | | |
238 | 253 | | |
239 | 254 | | |
240 | | - | |
| 255 | + | |
241 | 256 | | |
242 | 257 | | |
243 | 258 | | |
| |||
270 | 285 | | |
271 | 286 | | |
272 | 287 | | |
273 | | - | |
| 288 | + | |
274 | 289 | | |
275 | 290 | | |
276 | 291 | | |
277 | 292 | | |
278 | 293 | | |
279 | 294 | | |
280 | 295 | | |
281 | | - | |
| 296 | + | |
282 | 297 | | |
283 | 298 | | |
284 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| |||
380 | 381 | | |
381 | 382 | | |
382 | 383 | | |
| 384 | + | |
383 | 385 | | |
384 | 386 | | |
385 | 387 | | |
| |||
395 | 397 | | |
396 | 398 | | |
397 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
398 | 407 | | |
399 | 408 | | |
400 | 409 | | |
401 | 410 | | |
| 411 | + | |
402 | 412 | | |
403 | 413 | | |
404 | 414 | | |
| |||
499 | 509 | | |
500 | 510 | | |
501 | 511 | | |
| 512 | + | |
502 | 513 | | |
503 | 514 | | |
504 | 515 | | |
| |||
519 | 530 | | |
520 | 531 | | |
521 | 532 | | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
527 | 536 | | |
528 | 537 | | |
529 | 538 | | |
530 | 539 | | |
531 | 540 | | |
532 | | - | |
533 | | - | |
534 | 541 | | |
535 | 542 | | |
536 | 543 | | |
| |||
549 | 556 | | |
550 | 557 | | |
551 | 558 | | |
552 | | - | |
| 559 | + | |
553 | 560 | | |
554 | 561 | | |
555 | 562 | | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
563 | 567 | | |
564 | | - | |
565 | | - | |
566 | | - | |
| 568 | + | |
567 | 569 | | |
568 | | - | |
569 | | - | |
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
| 573 | + | |
| 574 | + | |
573 | 575 | | |
574 | 576 | | |
575 | 577 | | |
| |||
0 commit comments