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

Fix protocol of channel renew and sub channel establish #116

Merged
merged 1 commit into from
Jul 10, 2023

Conversation

Tibo-lg
Copy link
Contributor

@Tibo-lg Tibo-lg commented Jul 5, 2023

This PR fixes the protocols of the channel renewal and sub channel establishment. The issue was that with the previous protocol the offering party had the ability to force close the channel without the accepting party being able to finalize the closing, which meant the offering party could chose whether to close the DLC channel using a CET or wait for a refund.

@Tibo-lg Tibo-lg added bug Something isn't working channel Related to DLC channels ln labels Jul 5, 2023
@Tibo-lg Tibo-lg requested a review from luckysori July 5, 2023 02:54
@Tibo-lg Tibo-lg force-pushed the fix/channel-renew-ln-dlc-establish branch 2 times, most recently from a127efd to ae4d228 Compare July 5, 2023 06:45
Copy link
Collaborator

@luckysori luckysori left a comment

Choose a reason for hiding this comment

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

Nice work! This looks like a step in the right direction. Most of the comments are to check my understanding.

.github/workflows/rust.yml Show resolved Hide resolved
dlc-messages/src/sub_channel.rs Show resolved Hide resolved
dlc-messages/src/sub_channel.rs Show resolved Hide resolved
dlc-messages/src/sub_channel.rs Show resolved Hide resolved
dlc-messages/src/sub_channel.rs Show resolved Hide resolved
dlc-manager/src/sub_channel_manager.rs Show resolved Hide resolved
dlc-manager/src/sub_channel_manager.rs Show resolved Hide resolved
Comment on lines +2916 to +2918
party_points: dlc_channel.counter_points,
per_update_point: dlc_channel.counter_per_update_point,
Copy link
Collaborator

Choose a reason for hiding this comment

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

How come these have gone from own to counter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the code used to be for the offer party side, but now it's in the accept party side.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is slightly confusing still. I have two questions:

  • Are we interpreting these fields differently depending on the value of is_offer_party? For example, if is_offer_party == false, do we take party_points to mean the offerer's points which are therefore the counterparty's?
  • What does the counter_party field below mean if these fields depend on is_offer_party. It looks like we also need to flip that to be consistent with this change.

It might help to take an absolute perspective in this message, with fields belonging to "sender" and "receiver" rather than "ours" and "theirs". The is_offer_party field would remain inherently relative as constructed, although we could instead say pubkey_offer_party so that each side can compare against their own pubkey. Not sure if it's worth it though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we interpreting these fields differently depending on the value of is_offer_party? For example, if is_offer_party == false, do we take party_points to mean the offerer's points which are therefore the counterparty's?

Yes

What does the counter_party field below mean if these fields depend on is_offer_party. It looks like we also need to flip that to be consistent with this change.

The counter_party field is actually just the counter party pubkey, regardless of the is_offer_party value.

It might help to take an absolute perspective in this message, with fields belonging to "sender" and "receiver" rather than "ours" and "theirs".

So pretty much all fields are the ones of the "sender", there is really nothing about the "receiver".

The is_offer_party field would remain inherently relative as constructed, although we could instead say pubkey_offer_party so that each side can compare against their own pubkey. Not sure if it's worth it though.

If you find it clearer or easier I'm ok with such a refactor, but maybe not as part of this PR :). I agree it might prevent some errors (where the field is set incorrectly).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for clarifying!

If you find it clearer or easier I'm ok with such a refactor, but maybe not as part of this PR :). I agree it might prevent some errors (where the field is set incorrectly).

I agree that we shouldn't do it with this PR. I might give it a go in the future 😄

dlc-manager/src/sub_channel_manager.rs Show resolved Hide resolved
dlc-manager/src/sub_channel_manager.rs Show resolved Hide resolved
Copy link
Collaborator

@luckysori luckysori left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to respond to my previous review! I think we can go ahead with this. I left some more comments, but we can always address them later.

dlc-manager/src/sub_channel_manager.rs Outdated Show resolved Hide resolved
dlc-manager/src/sub_channel_manager.rs Show resolved Hide resolved
dlc-manager/src/sub_channel_manager.rs Show resolved Hide resolved
dlc-manager/src/sub_channel_manager.rs Show resolved Hide resolved
dlc-manager/src/sub_channel_manager.rs Show resolved Hide resolved
Comment on lines +2916 to +2918
party_points: dlc_channel.counter_points,
per_update_point: dlc_channel.counter_per_update_point,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is slightly confusing still. I have two questions:

  • Are we interpreting these fields differently depending on the value of is_offer_party? For example, if is_offer_party == false, do we take party_points to mean the offerer's points which are therefore the counterparty's?
  • What does the counter_party field below mean if these fields depend on is_offer_party. It looks like we also need to flip that to be consistent with this change.

It might help to take an absolute perspective in this message, with fields belonging to "sender" and "receiver" rather than "ours" and "theirs". The is_offer_party field would remain inherently relative as constructed, although we could instead say pubkey_offer_party so that each side can compare against their own pubkey. Not sure if it's worth it though.

dlc-messages/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@luckysori luckysori left a comment

Choose a reason for hiding this comment

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

If you address/dismiss https://github.com/p2pderivatives/rust-dlc/pull/116/files#r1257590214 I have no further comments. LGTM!

@Tibo-lg Tibo-lg force-pushed the fix/channel-renew-ln-dlc-establish branch from 00b952e to 7560cad Compare July 10, 2023 01:05
@Tibo-lg Tibo-lg merged commit 572afbb into feature/ln-dlc-channels Jul 10, 2023
136 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working channel Related to DLC channels ln
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants