Commit 4795352
committed
Read the RGS sync timestamp from the network graph
Previously, after each successful Rapid Gossip Sync update the
background task wrote `latest_rgs_snapshot_timestamp` to the persisted
`NodeMetrics` immediately, while the network graph itself is only
flushed to disk later by LDK's background processor. A crash in that
window left the on-disk metric ahead of the on-disk graph — on restart
we'd resume RGS from the newer timestamp and permanently skip the
updates that were never persisted together with the graph.
Instead, seed the RGS start timestamp from
`NetworkGraph::get_last_rapid_gossip_sync_timestamp`, which is part of
the graph's own serialized state and therefore lands on disk atomically
with the channel updates it describes. The same source now backs the
RGS timestamp reported via `NodeStatus::latest_rgs_snapshot_timestamp`,
so the reported value always matches what's reflected in the graph.
Worst case after a crash is that we refetch the snapshots since the
last persisted graph — an idempotent operation — rather than silently
losing them.
The `latest_rgs_snapshot_timestamp` field is retired from `NodeMetrics`,
and TLV slot 6 is kept readable for backwards compatibility via LDK's
`legacy` TLV grammar. Old persisted records still deserialize; new
records no longer carry slot 6. The dead "reset RGS timestamp on
gossip-source switch" block in the P2P builder branch also goes away,
since the graph's timestamp remains the correct resume point across a
P2P→RGS switch.
Fixes lightningdevkit#615. Disclosing the use of an AI coding assistant.
Co-Authored-By: HAL 90001 parent 59a4790 commit 4795352
2 files changed
Lines changed: 57 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
1770 | 1770 | | |
1771 | 1771 | | |
1772 | 1772 | | |
1773 | | - | |
1774 | | - | |
1775 | | - | |
1776 | | - | |
1777 | | - | |
1778 | | - | |
1779 | | - | |
1780 | | - | |
1781 | 1773 | | |
1782 | 1774 | | |
1783 | 1775 | | |
1784 | 1776 | | |
1785 | | - | |
| 1777 | + | |
1786 | 1778 | | |
1787 | 1779 | | |
1788 | 1780 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
301 | 300 | | |
302 | | - | |
303 | 301 | | |
304 | 302 | | |
305 | 303 | | |
| |||
315 | 313 | | |
316 | 314 | | |
317 | 315 | | |
318 | | - | |
| 316 | + | |
319 | 317 | | |
320 | 318 | | |
321 | 319 | | |
322 | 320 | | |
323 | 321 | | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | 322 | | |
334 | 323 | | |
335 | 324 | | |
| |||
780 | 769 | | |
781 | 770 | | |
782 | 771 | | |
783 | | - | |
| 772 | + | |
784 | 773 | | |
785 | 774 | | |
786 | 775 | | |
| |||
2110 | 2099 | | |
2111 | 2100 | | |
2112 | 2101 | | |
2113 | | - | |
2114 | 2102 | | |
2115 | 2103 | | |
2116 | 2104 | | |
| |||
2121 | 2109 | | |
2122 | 2110 | | |
2123 | 2111 | | |
2124 | | - | |
2125 | 2112 | | |
2126 | 2113 | | |
2127 | 2114 | | |
| |||
2133 | 2120 | | |
2134 | 2121 | | |
2135 | 2122 | | |
2136 | | - | |
| 2123 | + | |
| 2124 | + | |
2137 | 2125 | | |
2138 | 2126 | | |
2139 | 2127 | | |
| |||
2174 | 2162 | | |
2175 | 2163 | | |
2176 | 2164 | | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
0 commit comments