Skip to content

Conversation

@tnull
Copy link
Collaborator

@tnull tnull commented Nov 10, 2025

Previously, we'd still use KVStoreSync for persistence of our event queue, which also meant calling the sync persistence through our otherwise-async background processor/event handling flow.

Here we switch our EventQueue persistence to be async, which gets us one step further towards async-everything.

@tnull tnull requested a review from joostjager November 10, 2025 12:52
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Nov 10, 2025

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

@tnull tnull added this to the 0.7 milestone Nov 10, 2025
@tnull tnull mentioned this pull request Nov 10, 2025
8 tasks
joostjager
joostjager previously approved these changes Nov 11, 2025
Copy link
Contributor

@joostjager joostjager left a comment

Choose a reason for hiding this comment

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

Straight forward change


pub(crate) fn add_event(&self, event: Event) -> Result<(), Error> {
{
pub(crate) async fn add_event(&self, event: Event) -> Result<(), Error> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was looking at what's left in EventQueue that is sync. Just next_event. Unrelated to this PR, but in every test where that method is used, the test is already async. So it could use the async version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was looking at what's left in EventQueue that is sync. Just next_event. Unrelated to this PR, but in every test where that method is used, the test is already async. So it could use the async version?

But next_event doesn't do anything that would require async operation? It doesn't repersist or anything?

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we set the example and use the async api of eventqueue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah maybe the naming isn't optimally clear. next_event_async waits, and next_event does not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The former returns a future, the second one could be named try_next_event.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that would be an improvement indeed.

pub fn event_handled(&self) -> Result<(), Error> {
self.event_queue.event_handled().map_err(|e| {
// We use our runtime for the sync variant to ensure `tokio::task::block_in_place` is
// always called if we'd ever hit this in an outer runtime context.
Copy link
Contributor

Choose a reason for hiding this comment

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

Every time I read this, the same question marks pop up. It feels so strange to have regular sync code and worry about an outer runtime. And then we also make it more complicated because our own block_on variant isn't using the internal handle if there is already a context.

@tnull
Copy link
Collaborator Author

tnull commented Nov 11, 2025

Straight forward change

Not so straightforward after all. This is blocked as the currently the upstream TestStore changes now require to manually complete any writes, i.e., in all these tests we'd need to exactly know what writes there are and which ones to complete

Recently, `rust-lightning` broke the (async) API of the `TestStore`,
making it ~impossible to use in regular tests.

Here, we un-DRY our `TestStore` implementation and simply copy over the
previous `TestStore` version, now named `InMemoryStore` to discern the
objects. We also switch all feasible instances over to use
`InMemoryStore` rather than LDK's `test_utils::TestStore`.
Previously, we'd still use `KVStoreSync` for persistence of our event
queue, which also meant calling the sync persistence through our
otherwise-async background processor/event handling flow.

Here we switch our `EventQueue` persistence to be async, which gets us
one step further towards async-everything.
@tnull tnull force-pushed the 2025-11-async-event-persistence branch from 3e8464e to 4c72541 Compare November 13, 2025 12:48
@tnull tnull requested a review from joostjager November 13, 2025 12:48
@tnull
Copy link
Collaborator Author

tnull commented Nov 13, 2025

Now fixed the CI failure by introducing InMemoryStore, our own version of the previously-upstreamed, but now broken TestStore.

@tnull tnull self-assigned this Nov 13, 2025
@tnull tnull moved this to Goal: Merge in Weekly Goals Nov 13, 2025
@tnull tnull merged commit 8cf64ec into lightningdevkit:main Nov 13, 2025
17 checks passed
@github-project-automation github-project-automation bot moved this from Goal: Merge to Done in Weekly Goals Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants