Skip to content

Adapt to lightning-block-sync API changes#874

Open
jkczyz wants to merge 1 commit intolightningdevkit:mainfrom
jkczyz:2026-04-block-sync-api
Open

Adapt to lightning-block-sync API changes#874
jkczyz wants to merge 1 commit intolightningdevkit:mainfrom
jkczyz:2026-04-block-sync-api

Conversation

@jkczyz
Copy link
Copy Markdown
Contributor

@jkczyz jkczyz commented Apr 14, 2026

Update to use the new HeaderCache type instead of implementing the Cache trait, pass BestBlock instead of BlockHash to synchronize_listeners, and pass HeaderCache by value to SpvClient::new.

Also adapt to BestBlock gaining a previous_blocks field and ChannelManager deserialization returning BestBlock instead of BlockHash.

These changes are from lightningdevkit/rust-lightning#4266.

Update to use the new HeaderCache type instead of implementing the
Cache trait, pass BestBlock instead of BlockHash to
synchronize_listeners, and pass HeaderCache by value to SpvClient::new.

Also adapt to BestBlock gaining a previous_blocks field and
ChannelManager deserialization returning BestBlock instead of BlockHash.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Apr 14, 2026

I've assigned @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.

@jkczyz jkczyz changed the title Adapt to lightning-block-sync API changes Adapt to lightning-block-sync API changes Apr 14, 2026
@ldk-reviews-bot ldk-reviews-bot requested a review from tnull April 14, 2026 04:00
Copy link
Copy Markdown
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.

Thanks for looking into this, unfortunately bindings are currently broken.

Hmm, so, it seems lightningdevkit/rust-lightning#4266 fundamentally broke what BestBlock used to mean, i.e., being a simple data type for the chain tip. Really not loving the change, but I probably should have spoken up on that PR.

@TheBlueMatt any thoughts on still creating a new type for the 'best-sub-chain' that BestBlock now represents and switching the LDK APIs to that in a follow-up to lightningdevkit/rust-lightning#4266, rather than completely changing BestBlock semantics?

In any case, we need to figure something out as the changes currently broke our bindings, and the changes in BestBlock simply can't be exposed via uniffi as-is. I guess we could duplicate the old BestBlock code in this repo, but I'd really prefer if we could revert BestBlock and just use a new type for the semantics.

@TheBlueMatt
Copy link
Copy Markdown
Contributor

@TheBlueMatt any thoughts on still creating a new type for the 'best-sub-chain' that BestBlock now represents and switching the LDK APIs to that in a follow-up to lightningdevkit/rust-lightning#4266, rather than completely changing BestBlock semantics?

I don't understand this? A BestBlock is the chain tip info, its used (pretty consistently) to indicate where we last synced to and that can/should absolutely include a few recent headers. At least in lightning we don't really have a use for a "best block hash and height" type, if LDK Node has a use for such a type it could of course have an internal type for it, but its not clear to me what the use for that would be?

@tnull
Copy link
Copy Markdown
Collaborator

tnull commented Apr 14, 2026

I don't understand this? A BestBlock is the chain tip info, its used (pretty consistently) to indicate where we last synced to

For one it's a misnomer / unexpected API now. If something is called BestBlock I expect it to represent the information of a (single) block. Something like bdk_chain's CheckPoint that is made up of BlockIds (the equivalent of BestBlock) would be a much more intuitive/expected API and naming scheme, IMO. The previous_blocks field seems like information specific to how our chain syncing logic works, which preferably wouldn't leak into the public API?

It's also unnecessarily inefficient for many cases, as we for example now clone a bunch of BlockHashess when simply checking {ChannelManager, OutputSweeper, etc}::current_best_block.

and that can/should absolutely include a few recent headers.

Thankfully it's just a few hashes, not the full Headers.

At least in lightning we don't really have a use for a "best block hash and height" type, if LDK Node has a use for such a type it could of course have an internal type for it, but its not clear to me what the use for that would be?

Yeah, fair if we don't deem the inefficiency the additional clones fixing, but from my point of view a more intuitive name would still be worth adopting (before the 0.3 release), even if we just move the old BestBlock to LDK Node.

If we think previous_blocks is worth to always have as part of this 'chain check point', it would be nice if LDK could make it somewhat bindings compatible, so that we don't have to introduce yet another awkward From implementation and always have to re-allocate etc.

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.

4 participants