Commit 181e48b
harness(rg3): fix K2 baseline block-skip race + empty-string MOCK_TRACE guard (#169)
* harness(rg3): fix K2 baseline block-skip race (per-connection stream cursor)
The K2 baseline (turnDelayMs:450) aborted at K2-midstream: the mock's /stream
delivered 100→101→103, skipping 102, so the product correctly fataled on a
corrupt sequence (portal-realtime.ts:1101 "unknown parent").
Root cause (mock artifact, NOT a product bug): handleBlocks iterated block
numbers off a MODULE-LEVEL `streamCursor`. K2's 450ms inter-block delay lets the
client open an overlapping /stream (a legitimate reconnect on the finalized-head
advancing 100→103 mid-stream). Two concurrent handleBlocks turns then read+wrote
the one shared cursor across their delays and interleaved: conn1 wrote 102 and
set cursor=102, conn2 woke, read cursor=102 and wrote 103 — skipping 102 on
conn2, the connection the client consumed. Fast classes (K3) never hit it: the
window is too small to overlap. Confirmed via MOCK_TRACE request-interleave.
Fix: seed a per-connection `localCursor` from the request's fromBlock and do all
per-block arithmetic against it; a real Portal serves each /stream connection
independently. The shared `streamCursor` is still mirrored best-effort for the
fromBlock-less default of a subsequent request. Also adds MOCK_TRACE-gated
(no-op when unset) request/cursor tracing for future harness debugging.
No product code under portal/ is touched.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* harness(rg3): treat empty-string MOCK_TRACE as tracing-off
orchestrate.sh forwards MOCK_TRACE via `${MOCK_TRACE:-}`, so a caller that
never sets it (the acceptance capstone) reaches node as an empty string, not
undefined. The `=== undefined` guard let that empty value through to
appendFileSync(''), which throws ENOENT — returned as a 500 on the very first
/finalized-head probe and surfacing as a spurious "cannot establish finality
boundary" fatal on every non-tracing run (i.e. the whole capstone). Guard on
`!TRACE_FILE` so unset and empty both mean off; a real trace path is unaffected.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 4c73eb1 commit 181e48b
2 files changed
Lines changed: 73 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
40 | 56 | | |
41 | 57 | | |
42 | 58 | | |
| |||
646 | 662 | | |
647 | 663 | | |
648 | 664 | | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
649 | 671 | | |
650 | 672 | | |
651 | 673 | | |
| |||
670 | 692 | | |
671 | 693 | | |
672 | 694 | | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
673 | 702 | | |
674 | 703 | | |
675 | 704 | | |
| |||
797 | 826 | | |
798 | 827 | | |
799 | 828 | | |
| 829 | + | |
| 830 | + | |
800 | 831 | | |
801 | | - | |
802 | | - | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
803 | 850 | | |
804 | 851 | | |
805 | 852 | | |
806 | 853 | | |
807 | | - | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
808 | 862 | | |
809 | 863 | | |
810 | 864 | | |
| |||
833 | 887 | | |
834 | 888 | | |
835 | 889 | | |
| 890 | + | |
836 | 891 | | |
| 892 | + | |
837 | 893 | | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
838 | 900 | | |
839 | 901 | | |
840 | 902 | | |
| |||
1016 | 1078 | | |
1017 | 1079 | | |
1018 | 1080 | | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
1019 | 1088 | | |
1020 | 1089 | | |
1021 | 1090 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| |||
0 commit comments