Skip to content

Conversation

@Roasbeef
Copy link
Member

In this commit, we adds extra validation of the channel_update and node_announcement during the decoding process to ensure that the timestamp is not zero. Per BOLT 7:

For channel_update:
  "MUST set timestamp to greater than 0, AND to greater than any
  previously-sent channel_update for this short_channel_id."

@Roasbeef Roasbeef added wire protocol Encoding of messages for the communication between nodes spec labels Dec 30, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @Roasbeef, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of the lnwire package by introducing explicit validation during the decoding of channel_update and node_announcement gossip messages. It ensures that these messages comply with the BOLT 7 specification, which mandates that their timestamps must be greater than zero, thereby preventing the propagation and processing of malformed or invalid network announcements.

Highlights

  • Enforce Non-Zero Timestamps: Implemented validation for channel_update and node_announcement messages to ensure their timestamps are not zero, adhering to the BOLT 7 specification.
  • New Test Cases: Added dedicated test cases for ChannelUpdate1 and NodeAnnouncement1 to verify the correct rejection of messages with zero timestamps and acceptance of valid ones.
  • Test Message Generation Update: Modified the RandTestMessage functions for both ChannelUpdate1 and NodeAnnouncement1 to generate timestamps starting from 1, preventing the creation of invalid test messages.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Roasbeef Roasbeef force-pushed the lnwire-timestamp-validation branch from 480671b to 3cdd93f Compare December 30, 2025 03:05
@Roasbeef Roasbeef added this to the v0.20.1 milestone Dec 30, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly enforces that timestamps in channel_update and node_announcement gossip messages are non-zero, aligning with BOLT 7 specifications. The changes are well-implemented with corresponding unit tests to validate the new behavior. I have a couple of minor suggestions to improve code comments for better clarity and consistency.

@Roasbeef
Copy link
Member Author

Roasbeef commented Jan 3, 2026

Switched the approach here to just do this at the gossip validation layer. In recent time we had issue re making parsing too strict, which then prevented us from reading old data we had written from disk (eg: chan upd w/ zero timestamp that we already accepted).

@Roasbeef Roasbeef force-pushed the lnwire-timestamp-validation branch from 3cdd93f to e9c8f18 Compare January 3, 2026 02:18
@saubyk saubyk added this to lnd v0.20 Jan 4, 2026
@saubyk saubyk moved this to In progress in lnd v0.20 Jan 4, 2026
@ziggie1984 ziggie1984 self-requested a review January 5, 2026 19:51
Copy link
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can you retrigger the itests they were failing due to an unrelated reason which is fixed now.

moreover linter is still not passing

@ziggie1984 ziggie1984 added no-changelog backport-v0.20.x-branch This label is used to trigger the creation of a backport PR to the branch `v0.20.x-branch`. labels Jan 5, 2026
@saubyk saubyk moved this from In progress to In review in lnd v0.20 Jan 6, 2026
@saubyk saubyk requested a review from gijswijs January 6, 2026 17:37
@Roasbeef Roasbeef force-pushed the lnwire-timestamp-validation branch from 73106eb to caccd09 Compare January 7, 2026 02:13
@Roasbeef
Copy link
Member Author

Roasbeef commented Jan 7, 2026

Pushed, linter should be good. Added release notes.

In this commit, we add validation for channel updates and node
announcements to ensure that we reject gossip messages with zero
timestamps at the discovery layer.

From BOLT 7:
  "MUST set timestamp to greater than 0, AND to greater than any
  previously-sent channel_update for this short_channel_id."

This validation is performed in the gossip handlers (handleNodeAnnouncement
and handleChanUpdate) rather than at the wire protocol level. This approach
ensures we can still decode messages from disk or embedded in onion errors
while rejecting invalid gossip from peers.

Remote peers sending zero-timestamp gossip will have their ban score
incremented.
@Roasbeef Roasbeef force-pushed the lnwire-timestamp-validation branch from caccd09 to 149e1f4 Compare January 7, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v0.20.x-branch This label is used to trigger the creation of a backport PR to the branch `v0.20.x-branch`. no-changelog spec wire protocol Encoding of messages for the communication between nodes

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants