-
Notifications
You must be signed in to change notification settings - Fork 23
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
Offers: send invoice request #87
Conversation
18e33d6
to
6aa2814
Compare
6aa2814
to
a1f47ef
Compare
a1f47ef
to
9af927d
Compare
It looks like the clippy error is coming from configure_me. |
src/lib.rs
Outdated
// MessengerState tells us whether our onion messenger is still starting up is ready to start | ||
// forwarding messages. | ||
#[derive(Debug)] | ||
pub enum MessengerState { |
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.
Rather than add a whole state machine, can we have a one-shot channel and close it when we're done with startup? Also comes with the benefit that we can select on shutdown / channel close and then we don't have to have any X second / magic number wait -> it'll either exit if we've given up or yield exactly when the onion messenger has started up.
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.
Yeah that sounds good. I changed the MessengerState to a channel, though I couldn't quite get a oneshot channel to work because it requires a "self" method receiver, which doesn't work for us. So I used a normal mpsc channel instead.
d932363
to
d64e534
Compare
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.
Major comments about "readynesss" channel and checking up on whether we can always rely on having an advertised IP (not sure that we can).
pub struct LndkOnionMessenger { | ||
pub offer_handler: OfferHandler, |
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 don't follow the logic of an onion messenger containing an offer handler?
To me the reverse makes more sense: we have an offer handler, and one of the things that it managed is an onion messenger?
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 guess to me it seems like LndkOnionMessenger encompasses any sort of activity dealing with onion messaging, and then offer_handling is a more specific application of onion messaging that we support. And perhaps in the future we might add other applications of onion messaging that might eventually branch off the LndkOnionMessenger struct
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 guess to me it seems like LndkOnionMessenger encompasses any sort of activity dealing with onion messaging,
That ordering doesn't make sense to me. Sure we may have multiple things using onion messaging one day, but ideally that would just be an abstracted messaging layer that each application interacts with. Maybe I'm missing something, but this layout is analogous to having a top level HTTP
struct which has multiple websites inside of it?
Especially with the way that LDK has structured the API for the onion messenger (handlers for different functionality), I think it's far cleaner to have each piece of functionality standalone and referring to the onion messenger. Say we add asynchronous payments, I think that approach 2 here makes way more sense for a modular codebase:
Approach 1:
LndkOnionMessenger{
OfferHandler,
AsyncHandler,
}
vs
Approach 2:
OfferHandler{
OnionMessenger
}
AsyncHandler{
OnionMessenger
}
cb6764b
to
e14f2b4
Compare
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 fully on board with the architecture chosen here, but I don't want to unnecessarily block on a difference of opinion.
Would be in support of:
- Merging the first few commits that have been unchanged for a while
- Merging as is (pending small fixups suggested in here) once we have E2E testing paying an offer working and then coming back to refactor
/// otherwise we creae a blinded path directly to ourselves. | ||
pub async fn create_reply_path( | ||
&self, | ||
mut connector: impl PeerConnector + std::marker::Send + 'static, |
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.
Doesn't need to be 'static
?
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.
without it I get error[E0310]: the parameter type
impl MessageSigner + std::marker::Send may not live long enough
And the parameter type
impl MessageSigner + std::marker::Send must be valid for the static lifetime...
src/lndk_offers.rs
Outdated
// Wait for onion messenger to give us the signal that it's ready. Once the onion messenger drops | ||
// the channel sender, recv will return None and we'll stop blocking here. | ||
while (started.recv().await).is_some() { | ||
println!("Error: we shouldn't receive any messages on this channel"); |
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.
Error rather than println?
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.
Do we need a loop here? Can't we just recv().await
and then proceed?
if started.recv().await.is_some(){
return Err(unexpected signal)
}
... continue with logic here
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.
Ah yup good catch, I think that was leftover from when I had put a RefCell in there
@carlaKC Sounds good, I like option 2. I can see what you're saying above about modularity and I'd be down to switch to your approach. But I like the idea of merging it as is (once we have e2e working, etc), then going back to refactor. Going back and interactive rebasing that big of a change sounds like a royal pain and I'd love to avoid it if possible, ha ha. |
To allow external callers to shutdown lndk, we provide a shutdown trigger and listener to the onion messenger, replacing the single use channels that we previously used. This is useful for itests, so that we can cleanly shut down and for callers of the library to manage execution.
Provides the end user with something to interact with when they want to pay offers.
For our integration tests to work properly we need to use a custom version of lnd's RPC that allows signing the tagged hash (BIP 340) of a message. This was introduced in LND at commit dacb86f.
For the integration tests to work we need to add the walletrpc subservice to the lnd make process so we can use the DeriveKey RPC call.
Bumps rust-lightning to a custom version that allows us to sign the invoice request's tagged hash.
With Rust 1.75.0, we get an unused import error from configure_me, which we can't change on our end. We ignore this warning so the CI runs properly.
Before we can send an invoice request, LNDK's onion messenger needs to be fully started and running. We use a channel close to signal when the messenger is ready.
We bump ldk-sample to a version that can open channels and broadcasts the node announcement at a more frequent interval so we can pull ldk's address from the node graph in our integration tests.
d4694ef
to
b85cad4
Compare
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.
Thanks for the quick rebase!
Rewrote the send invoice logic with #85 in mind. I agree it seems cleaner :) I realize #85 wasn't intended for merge, but I didn't need to make many significant changes to the structure, so I just made a few tweaks to the commits here.
Also about to write a few thoughts/questions inline.
Replaces #81.