Repository navigation
Commit 075baef
committed
fix(metrics): mirror the guarded tip into smartrouter_latest_block on every poll observation
MAG-2629 — the router-wide latest-block gauge was written only in the relay-
harvest path (SetRouterLatestBlock had exactly one call site), while the
ChainState tip it reports has TWO feeders: polls and relay harvest. On a router
serving no relay traffic the gauge froze at the last relay's value as polls kept
the real tip fresh — dashboards read "falling behind head" on an idle pod,
indistinguishable from a genuinely stuck tip, and contradicting the poll-fed
rpc_endpoint_latest_block beside it. Archaeology: T3 rewired the gauge to the
guarded tip in the relay path; Topic C later added the poll feeder to ChainState
and no matching metric write came with it.
The OnTipObservation closure becomes a named method (onTipObservation) that
feeds ChainState as before and then mirrors the gated GetLatestBlock() into the
gauge. Same only-when-fresh semantics as the relay-path write: a stale tip
leaves the gauge alone (zeroing would turn TTL expiry into a false "chain
reset"), and the gauge always carries the GUARDED tip, never the raw block, so
a lying-high endpoint cannot inflate it through this path either. The harvest-
path write stays — redundant now, kept as the explicit relay-side guarantee.
Regression pin: TestOnTipObservation_GaugeAdvancesUnderPollOnlyTraffic drives
the hook with poll-only traffic and requires the gauge to seed, advance, and
hold under a warped-stale read; verified to FAIL against the pre-fix wiring
("smartrouter_latest_block not reported"). The gauge-reading helper is lifted
to file scope and shared with the existing harvest-path test.
Verified live against ETH1 mainnet (PublicNode + Tenderly, zero relays sent):
pre-fix gauge +0 over 65s while endpoints advanced +6; post-fix gauge +3 over
40s, 1 block behind the live head.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Took 2 hours 27 minutes1 parent 8205771 commit 075baef
2 files changed
Lines changed: 123 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
| 371 | + | |
396 | 372 | | |
397 | 373 | | |
398 | 374 | | |
| |||
655 | 631 | | |
656 | 632 | | |
657 | 633 | | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
224 | 223 | | |
225 | 224 | | |
226 | 225 | | |
| |||
2451 | 2450 | | |
2452 | 2451 | | |
2453 | 2452 | | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
2454 | 2490 | | |
2455 | 2491 | | |
2456 | 2492 | | |
| |||
2495 | 2531 | | |
2496 | 2532 | | |
2497 | 2533 | | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
2498 | 2539 | | |
2499 | 2540 | | |
2500 | 2541 | | |
| |||
0 commit comments