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

Custom Keysmanager and openchannel_without_peer_addr added #138

Closed
wants to merge 2 commits into from

Conversation

Psycho-Pirate
Copy link
Contributor

@Psycho-Pirate Psycho-Pirate commented Jan 16, 2025

MyKeysManager is a custom keysmanager that can be used to set custom channel secrets. Setting custom channel is essential for interacting with Lnprototest.
A cli command openchannel_without_peer_addr is also added. This allows creating a channel with a peer that is already connected. This is also needed for Lnprototest tests regarding open channel.

A test run with Lnprototest can be found here https://github.com/Psycho-Pirate/lnprototest/actions/runs/12806099333/job/35703810589

MyKeysManager is a custom keysmanager that can be used to set custom channel secrets. Setting custom channel is essential for
interacting with Lnprototest.
A method called openchannel_without_peer_addr is also added. This allows creating a channel with a peer that is already connected. This is also needed for Lnprototest tests regarding open channel.
@@ -74,6 +76,53 @@ pub(crate) fn poll_for_user_input(
if let Some(word) = words.next() {
match word {
"help" => help(),
"openchannel_without_peer_addr" => {

Choose a reason for hiding this comment

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

I am not sure that we need a new cli command like openchannel_without_peer_addr, but probably it is required just to allow a less restrictive parser in the ldk-sample by assuming that if the address is not specified the peer is already connected (or exist inside the ldk gossip map already)

What do you think about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that should be better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, lets definitely just update the existing openchannel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding this, openchannel command should be followed by either pubkey@host:port or pubkey.

  • If it is just pubkey,
    • if that peer is already connected, open the fund channel
    • otherwise return error
  • if it is pubkey@host:port, proceed with the old behavior

Does this sound good?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, sounds great!

Copy link
Contributor

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Aside from the openchannel command, I'm not entirely convinced it makes sense to upstream all the key changes to LDK "sample" on the main branch. We could certainly, however, take them upstream on a branch. Would that make sense for you?

@@ -74,6 +76,53 @@ pub(crate) fn poll_for_user_input(
if let Some(word) = words.next() {
match word {
"help" => help(),
"openchannel_without_peer_addr" => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, lets definitely just update the existing openchannel.

@Psycho-Pirate
Copy link
Contributor Author

Aside from the openchannel command, I'm not entirely convinced it makes sense to upstream all the key changes to LDK "sample" on the main branch. We could certainly, however, take them upstream on a branch. Would that make sense for you?

I agree on having a seperate branch for Lnprototest. I would also like to add the an Lnprototest folder inside LDK-Sample, so that we can have the entire testing suite along with the runner script I made inside this new branch. For reference rustyrussell/lnprototest#131

@TheBlueMatt
Copy link
Contributor

Sure, makes sense. We could even do it as a separate repo. Might be easier that way vs always referencing a branch?

@Psycho-Pirate
Copy link
Contributor Author

A seperate repo would be even better!

@arik-so
Copy link

arik-so commented Feb 18, 2025

If you're considering a separate repo, does that mean you don't intend to update this PR?

@Psycho-Pirate
Copy link
Contributor Author

If you're considering a separate repo, does that mean you don't intend to update this PR?

If a seperate repo is created, I will make a new PR to that repo. I will still make changes to the openchannel as discussed above in the main ldk-sample branch

@arik-so
Copy link

arik-so commented Feb 19, 2025

in that case, pending the separate repo, do you think we should still add the cfg-gating here as @tnull suggested?

@vincenzopalazzo
Copy link

in that case, pending the separate repo, do you think we should still add the cfg-gating here as @tnull suggested?

Sorry if I jump it there. IMHO this should always be under a cfg-gating because you do not want to ship in production code that can mess up with channels keys! This is the approach that I did in lampo, but also the same approach that core lightning had a while back (now this should be changed IIRC)

The only thing that lnprototest needs are compatible API to interact with the node - e.g: while connecting with a peer without specifying the address, lnprototest will expect that the implementation will consider the peers that are already connected.

What the separate repo should contains IMHO is just a runner for ldk that is what you need to write tests, and at the same time include these runners inside the lnprototest repository to be able to run the common tests that all the implementation have to pass (we are still thinking about the 'common tests')

@TheBlueMatt
Copy link
Contributor

Alright, so it sounds like (a) this PR should be updated to only include the changes to openchannel (which are of general interest), (b) we should make a new repo in the ldk org which is just a copy of this one which you'll open a new PR against to include the rest of the changes (as well as a README update, presumably). If that sounds good I'll go ahead and create the repo.

@Psycho-Pirate
Copy link
Contributor Author

Psycho-Pirate commented Feb 19, 2025

Alright, so it sounds like (a) this PR should be updated to only include the changes to openchannel (which are of general interest), (b) we should make a new repo in the ldk org which is just a copy of this one which you'll open a new PR against to include the rest of the changes (as well as a README update, presumably). If that sounds good I'll go ahead and create the repo.

Sounds good to me! I will add cfg to the new PR.

Regarding openchannel, should I make changes to this PR or make another PR to LDK-Sample?

@vincenzopalazzo
Copy link

(a) Sounds good to me.

(b) The second repository IMHO should include the Python project to implement the runner, similar to https://github.com/vincenzopalazzo/lampo.rs/tree/main/tests/lnprototest. (@Psycho-Pirate has already done something similar that just needs to be refactored, as seen in rustyrussell/lnprototest#131). This separate repository should contain all the prototest tests that LDK wants to have inside their repo. With this setup, it’s possible to deploy the lnprototest-ldk-runner to PyPI, which we can also use in the main lnprototest repo for basic testing.

I’m still not sure where the channel key change will be implemented, but this is another modification that lnprototest requires.

P.S.: It is also possible that @Psycho-Pirate could create the repository initially, and then we can take it over when the code is ready to be integrated into LDK.

@TheBlueMatt
Copy link
Contributor

The second repository IMHO should include the Python project to implement the runner

Yep, sounds great to me.

P.S.: It is also possible that @Psycho-Pirate could create the repository initially, and then we can take it over when the code is ready to be integrated into LDK.

Sure, also sounds good to me. Feel free to just create a new repo and we'll import it once its ready.

@Psycho-Pirate
Copy link
Contributor Author

Psycho-Pirate commented Feb 24, 2025

As per our discussion, I have made a new openchannel PR
#139

I will be closing this PR and making the new repo as well.

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