-
Notifications
You must be signed in to change notification settings - Fork 95
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
Conversation
76cc0a2
to
04aaa24
Compare
Need to switch to using the new inbound payment paymentid. |
2b42d4f
to
fa96ed2
Compare
@@ -226,10 +235,42 @@ impl BitcoindClient { | |||
}); | |||
} | |||
|
|||
fn run_future_in_blocking_context<F: Future + Send + 'static>(&self, future: F) -> F::Output |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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 spawn
ing 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)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)?
I'm not quite sure this is true, due to ChangeDestinationSource
being used in OutputSweeper
's spending method which in turn is triggered by Confirm
/Listen
. So if we make the traits async-optional, we'd also need to propagate it up the chain syncing logic, including all the traits and connected methods, no? But let's probably continue this discussion on lightningdevkit/rust-lightning#3540.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grrrrr
f7eb75b
to
21f12a5
Compare
// 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 || { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.
See the comment in the commit for more info on why we have to do this.
Actually doesn't make sense since we track payments since invoice creation, so need to index by payment hash. Updated to 0.1 release, this should be good to go! |
Hmm, well, but it might be a good point in time to actually change that as it's kind of weird to have a behavioral difference between BOLT11 and BOLT12 here? FWIW, we have the same issue in LDK Node, but there we'll only be able to remedy it via introducing a new metadata store holding on to offers and invoices (cf. lightningdevkit/ldk-node#425). |
Good idea, added HRN support. |
Yea, we probably should eventually change the inbound payment store here to associate OfferIds with the inbound payment, but that's a bigger overhaul and we can do it another time, I think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Discussed offline to accept the last commit as a temporary workaround, but that we will see to ship a proper fix (async traits) in LDK 0.2
No description provided.