Skip to content

Conversation

moisesPompilio
Copy link
Contributor

Ensure CLN block height is synced before opening channel

This adds a loop that waits for cln_client.getinfo().blockheight > 0 before opening the channel.

Without this, CLN may crash when persisting the channel if the internal block height hasn't been updated yet. The crash happens because CLN checks whether the current block height is greater than the channel's first_blocknum, and if not, it fails an assertion.

This typically occurs when the chain starts and blocks are mined quickly, causing CLN to miss the update before the channel open process begins.

For more context, see comment.

fix #527

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jul 1, 2025

👋 Thanks for assigning @tnull 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.

@ldk-reviews-bot ldk-reviews-bot requested a review from tankyleo July 1, 2025 01:54
@tnull tnull requested review from tnull and removed request for tankyleo July 1, 2025 07:39
Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Thank you for looking into this!

@tnull tnull merged commit 3385495 into lightningdevkit:main Jul 1, 2025
14 of 15 checks passed
@tnull tnull mentioned this pull request Aug 14, 2025
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.

test_cln is flaky now
3 participants