Skip to content

BUG: The initial snapshot has latest_seen_timestamp 0 #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrei-21 opened this issue Apr 28, 2025 · 3 comments
Closed

BUG: The initial snapshot has latest_seen_timestamp 0 #95

andrei-21 opened this issue Apr 28, 2025 · 3 comments

Comments

@andrei-21
Copy link
Contributor

Description:
The initial snapshot has latest_seen_timestamp 0.

Steps to Reproduce:

  1. Start a regtest lightning network with no channels
  2. Start RGS server in regtest mode
  3. Open a lightning channel, let RGS learn and issue snapshots
  4. Access the initial snapshot 0.bin
  5. See zeros after chain hash
$ hexdump 0.bin
0000000 444c 014b 2206 466e 1a11 590b afca 6012
0000010 eb43 bf5b c328 3a4f 335e 1f2a b2c7 3cb7
0000020 88f1 0f91 0000 0000 0000 0000 0000 0000
0000030 0000 0000                              
0000034

Expected Behavior:
A reasonable timestamp.

Additional Context:
If I restart the server, it generates new snapshots with non-zero latest_seen_timestamp.

$ hexdump 0.bin
0000000 444c 014b 2206 466e 1a11 590b afca 6012
0000010 eb43 bf5b c328 3a4f 335e 1f2a b2c7 3cb7
0000020 88f1 0f91 0f68 c06d 0000 0200 8402 9643
0000030 00d5 3863 2ac0 6e8b f14d 9d32 ed99 468d
0000040 ee1f 726a 8a4e 492a 970a 9a01 03fd 9861
0000050 e24f 3ca0 94c5 7de9 23e4 46bf 9610 26dd
0000060 2ea5 fe77 68da 0351 f377 e460 d430 0000
0000070 0100 0000 00ff d100 0000 0001 0000 0001
0000080 0000 0002 0006 0000 0000 0000 0000 0000
0000090 0001 0000 000a 0000 0c17 1edc ff00 0000
00000a0 00d1 0100 0000 0000 0001               
00000a9

See attached log files: rgs-server.logs.txt.
Database snapshot after the first start: db.1.sql.txt.
Database snapshot after the second start: db.2.sql.txt.

TheBlueMatt added a commit to TheBlueMatt/rapid-gossip-sync-server that referenced this issue Apr 29, 2025
When we write an update, we have to include a timestamp that
represents both the the time that the client will use to fetch the
next diff and the timestamp used as a reference point when adding
updates to the network graph (the client actually uses the included
timestamp minus two weeks).

Because of the second use, updates were being generated with the
highest timestmap of all included updates, rounded down to the
nearest update-interval multiple (because of the first use).

In practice, because we expect to see many updates in any hour
window, this meant we were really calculating the generation
reference timestamp in a very indirect way. Here we simply change
to using the reference timestamp directly.

This updates regtest results when generating an initial sync
against an empty graph to include a real timestamp, rather than 0,
though this shouldn't impact clients' correctness.

Fixes lightningdevkit#95
@TheBlueMatt
Copy link
Contributor

Fixed in #96 though I'm not entirely sure why this is an issue in practice.

@andrei-21
Copy link
Contributor Author

Hm, I see, maybe the issue is not that latest_seen_timestamp is 0, but that there are no channels in the initial snapshot after the first run, but there are after the second. However channel_announcements and channel_updates stay the same between runs (if you look into the sql dumps).

@TheBlueMatt
Copy link
Contributor

Hmm, so looking at your logs, it looks like at 2025-04-28 13:47:18 we created the first update, but didn't include any channels because we didn't have channel_updates in both directions for the one channel (the second update was received, per the DB at 2025-04-28 13:47:38.654678) which we always avoid routing over (as its generally likely one side of the channel is offline in such a case) but by 2025-04-28 13:49:30 we generated a second round of updates, this time with the one channel in question because we had both updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants