discovery: start live update horizon in the past #11634
Since lnd peers now replay the last 10 minutes from their DB on every active-sync (re)start and rotation (3 active syncers, rotated every 20 min by default), do we have a rough sense of the extra traffic on mainnet? And can that replay delay fresh live updates under peer-msg-rate-bytes? Fine as a follow-up if it's negligible.
How was 10 minutes chosen? With the default 90s trickledelay per hop, an update relayed over a few hops can reach the peer several minutes after signing, so the slack needs to stay above that. Would a lower value (e.g. ~5m) still leave enough margin, to cut the replay traffic from the comment above? Not asking for a config flag, just checking the trade-off.
Is there an issue/PR tracking the test-side fix (bootstrapper redial) so the nightly bw-compat test goes green before a release with this? Also, do we want this backported to 0.20.x, since routing failures from a missing policy hit users on that line too?
Worth adding that peers may now resend up to 10 minutes of gossip when sync starts or rotates, so operators who see a burst of duplicate updates in debug logs know why?
Thanks for tracking this down. The log timeline makes the gap clear, and fixing it on the requesting side means users benefit as soon as they upgrade, whatever their peers run. No blockers from my side. My questions are about the cost/coverage trade-off of the 10-minute window, and release follow-through (the nightly test fix and a possible 0.20.x backport). Happy for any of them to be follow-ups.
Good catch on the rate limit. The backlog replay (ApplyGossipFilter → sendToPeerSync) and the live relay (FilterGossipMsgs → sendToPeer) go through the same per-peer limiter in sendMsgRateLimited (default 50 KiB/s), so while a peer replays the window to us, live updates from that peer wait behind it. A ChannelUpdate is ~150 bytes, so that budget is roughly 340 updates/s, and a replay of a few thousand updates delays live gossip by seconds. Live updates are delayed, not dropped. Peers running with ignore-historical-gossip-filters don't replay at all.
I lowered the window to 5 minutes (27a47bab5), which halves the replay. I don't have mainnet numbers yet. Happy to measure the update rate per window on a mainnet node as a follow-up.
Agreed, 10 minutes was more than needed. The window only has to cover a message still in flight at the peer when our sync starts: validation there plus a few relay hops at the 90s trickle delay. On a rotation, the other active syncers keep delivering live updates, so the case that really matters is startup or reconnect. 5 minutes covers ~3 worst-case hops. Lowered in 27a47bab5, with the reasoning in the constant's comment.
The trigger in both nightly failures was a needless reconnect: initialPeerBootstrap reuses the ignore list from startup for all its retries, so a peer connected right after (via connectpeer in the test) gets dialed again, and the new outbound connection replaces the working one. The Nov 23 nightly failed the same way, see the timeline in the description. I'm keeping that out of this PR. With the horizon fix, such a reconnect no longer loses updates, so the redial is only a minor startup glitch, and this PR stays focused on the root cause. We're also not hiding it on the test side.
The nightly can't confirm the fix yet, though. Alice is the node that loses the policy, and she stays on the base release (v0.20.0-beta) for the whole test. Only bob and dave are upgraded. The plan is to backport this to v0.21.x-branch after merge, then bump the bw-compat base to the 0.21.x patch release that includes it, so alice runs the fix. There won't be another 0.20.x release, so no backport there. Until the bump, the nightly can still flake.
Added in 63c8a2ca1 (now five minutes).
Thanks for addressing all four. The 5-minute window and the release-note wording look good. The 0.21.x backport plus the bw-compat base bump covers the nightly follow-through. Let's keep an eye on replay traffic on mainnet once this ships.
Created backport PR for v0.21.x-branch:
Please cherry-pick the changes locally and resolve any conflicts.
git fetch origin backport-11634-to-v0.21.x-branch
git worktree add --checkout .worktree/backport-11634-to-v0.21.x-branch backport-11634-to-v0.21.x-branch
cd .worktree/backport-11634-to-v0.21.x-branch
git reset --hard HEAD^
git cherry-pick -x fa5931fcdcb2020fc2bbacca14525566a0941b43 fba5dd90cd2189648c0534854202f21fcb5e1094 ccc7d65937ae0776c3c320694cfe3676c307d407 27a47bab54e4db0fb4a544bbf3cba4e890ad0acd 63c8a2ca184af3b64b4682e698b03ca30653243f
git push --force-with-lease
saubyk
ziggie1984
Found while debugging the recurring backwards compatibility test failure in the nightly (run):
no route from alice to dave for 10000 sat within 60s.This PR doesn't stop that flake on its own. The fix is on the requesting side: only a node running it is protected. In the test, the node that lost the policy (alice) runs the base release for the whole run. Only bob and dave are upgraded. The plan:
1. Merge this PR.
2. Backport it to
v0.21.x-branch. There won't be another 0.20.x release.3. Once a 0.21.x patch release includes the fix, bump the test's base version (
LND_LATEST_VERSION, currentlyv0.20.0-beta) to it. Then alice runs the fix, and the nightly exercises it under the same conditions that triggered the failure.Until step 3 the nightly can still hit this race. We're keeping the test unchanged on purpose instead of hiding the trigger (e.g. with
--nobootstrap).Problem
When we switch a peer to an active sync, we send it a
GossipTimestampRangestarting attime.Now(). The peer filters relayed gossip by the timestamp the message was signed with (FilterGossipMsgs), not by when it accepted the message itself.We learn the peer's graph from two sources, and they're supposed to add up to everything:
1. Query replies: a snapshot of what the peer has committed at the time it answers.
2. Live relay: what the peer accepts afterwards, filtered to
signed timestamp ≥ our horizon.An update that is signed before our horizon but still in flight at the peer when it answers (queued for validation, waiting on its channel announcement, or relayed to it late over several hops) isn't in either one. A range sync only compares channel IDs, so that half of the channel policy is never requested again.
From the bw-compat node logs (all nodes on v0.20.0, so this isn't a recent regression):
Alice never gets charlie's direction and can't route to dave.
The Nov 23 nightly failed the same way, with a different channel:
Fix
Start the live update horizon
updateHorizonSlack(5 minutes) in the past. That covers validation at the peer and a few relay hops at the default 90s trickle delay. The cost is the peer re-sending that window's updates from its DB on each active-sync (re)start and rotation, unless it runs withignore-historical-gossip-filters. We drop those updates as stale. The replay shares the peer's per-peer gossip rate limit (default 50 KiB/s) with live updates, so it can delay live updates by a few seconds while it runs, but it doesn't drop them. This stays within BOLT 7: we only ask for a wider window.Testing
TestGossipSyncerLiveHorizonCoversInFlightUpdatesdrives the horizon from a real active-sync transition into the peer-side relay filter, using an update signed 3s earlier. It fails with the slack set to 0 (in-flight channel update was not relayed) and passes with the fix.TestGossipSyncerSyncTransitionsnow asserts the shifted horizon.