Skip to content

Conversation

@andrei-21
Copy link
Contributor

In order to generate a snapshot with information about a channel, it needs two channel updates (one for each end). The change is for Regtest because usually there are only few channels.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Oct 27, 2025

I've assigned @TheBlueMatt as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

src/tracking.rs Outdated
if chain_hash == ChainHash::REGTEST {
// There must be two channel updates (one for each end)
// to generate a snapshot with information about the channel.
is_caught_up_with_gossip = new_message_count < 20 && previous_announcement_count > 0 && previous_update_count > 0 && counter.channel_updates > 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, why are we being more strict on regtest than on mainnet? Presumably if its not ever getting to the finished state on regtest we should be removing conditions not adding ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that I start RGS, open a channel, RGS receives an announcement with one channel update, it sees that it caught up and generates snapshots, but they are empty because we need two channel updates for one channel to include channel information into snapshots. Empty snapshots are pretty much useless.
Here I want to wait for two channel updates, such that snapshots have information about the channel.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, okay, that makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just do this globally, not only for regtest then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, on mainnet is normal to receive only one update for a channel (if it existed before and just one end got updated).

Copy link
Contributor

Choose a reason for hiding this comment

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

We're definitely not done syncing mainnet if the total number of channel updates we've seen is only one :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is counter.channel_updates only increasing? If yes, then I agree, it makes sense for any environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TheBlueMatt just tell me what you think and I will implement.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, counter.channel_updates should be strictly increasing forever.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I removed the Regtest condition.

In order to generate a snapshot with information about a channel, it
needs two channel updates (one for each end).
@andrei-21 andrei-21 force-pushed the feature/wait-for-two-channel-updates branch from 10439b8 to 90e6e4a Compare November 18, 2025 09:10
@andrei-21 andrei-21 changed the title Require two channel updates in Regtest mode Require two channel updates Nov 18, 2025
Copy link
Contributor

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Thanks!

@TheBlueMatt TheBlueMatt merged commit ad07970 into lightningdevkit:main Nov 18, 2025
5 checks passed
@andrei-21 andrei-21 deleted the feature/wait-for-two-channel-updates branch November 18, 2025 14:56
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

Successfully merging this pull request may close these issues.

3 participants