Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to LDK 0.1-beta1 #137

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

TheBlueMatt
Copy link
Contributor

No description provided.

This used to be disabled at compile-time, but the feature was
removed as it didn't net substantial performance gain, so now we
disable them at runtime.
@TheBlueMatt
Copy link
Contributor Author

Need to switch to using the new inbound payment paymentid.

@TheBlueMatt TheBlueMatt force-pushed the main branch 2 times, most recently from 2b42d4f to fa96ed2 Compare January 13, 2025 20:10
@@ -226,10 +235,42 @@ impl BitcoindClient {
});
}

fn run_future_in_blocking_context<F: Future + Send + 'static>(&self, future: F) -> F::Output
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, given this is the sample I don't think we'd want to advise users to employ such hacky manners? Instead, can we just switch to a pattern that avoids block_on altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what alternative we have? I'm not aware of another option.

Copy link
Contributor

@tnull tnull Jan 15, 2025

Choose a reason for hiding this comment

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

I'm not sure what alternative we have? I'm not aware of another option.

I think there are a bunch of options, but one would to create an actor that is driven by a task spawned upon intialization. Then any of these blocking trait calls could communicate with that actor via MPSC channels, for example. This should work and would keep the blocking and async contexts more or less separate, no?
(although we might still run into issues when, depending on the actual callstack, we'd block the current thread, as other tasks might still try to run on the same runtime thread, IIUC. But that seems like an orthogonal issue we can't really resolve until we have proper async support/traits throughout the codebase, AFAICT).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there are a bunch of options, but one would to create an actor that is driven by a task spawned upon intialization. Then any of these blocking trait calls could communicate with that actor via MPSC channels, for example. This should work and would keep the blocking and async contexts more or less separate, no?

I don't believe the net-impact of that is any different than what we're already doing by spawning the task on a background task at the time we need it.

But that seems like an orthogonal issue we can't really resolve until we have proper async support/traits throughout the codebase, AFAICT

It looks like the only use of the sync->async inversion in the current ldk-sample codebase is in the anchor spend paths (ChangeDestinationSource+WalletSource) so it may be practical to make that whole thing dual-sync-async upstream pretty easily (with some proc macro, I assume)?

See the comment in the commit for more info on why we have to do
this.
// part of a tokio runtime (which in this case it is - the main tokio runtime). Thus, we
// have to `spawn` the `future` on the secondary runtime and then `block_on` the resulting
// `JoinHandle` on the main runtime.
tokio::task::block_in_place(move || {
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, note that this block_in_place will act on whatever runtime context is present here. This might or might not be the main runtime, it also could result being a no-op.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I think all of that is fine? Its generally expected to be the main runtime, but the point is just to tell the runtime "hey, this is gonna take some time, go ahead and make sure there's another thread to run actually-async things". Its just opportunistic, but we don't rely on it - we'll eventually return and the runtime will be happy.

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.

2 participants