Don't round the returned last seen timestamp #18
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Good morning,
This is an attempt to address issue #17.
I realize that this is a classical example of Chesterton’s Fence, but even after reading related server and client code I wasn't able to understand why the rounding to the nearest day was here in the first place, so please help me out :)
On the other hand, the motivation for not rounding the value is to avoid confusion for the rapid gossip sync client that uses this timestamp to derive the time for a batch of updates (e.g. in lightning-rapid-gossip-sync::update_network_graph_from_byte_stream function).
Here is an example of how things could go wrong:
0. Let D_SEC be the rounded timestamp for the current day
last_seen_timestamp
rounded to D_SEC (because of the logic under question)last_seen_timestamp
rounded to D_SECTo resolve this the client either needs to apply U2 even if the timestamp is the same as in the previous update or the update U2 should have timestamp > U1 timestamp, which is achieved with this change.
Additional issues arise when this timestamp is used to derive
last_rapid_gossip_sync_timestamp
as this leads to duplicate update messages that need to be ignored and causes lightningdevkit/rust-lightning#1746 (but arguably it shouldn't be used in this situation at all and instead we should use the actual current time as seen by the Rapid Gossip Server Postgres instance).