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

feat: allow collab and force close DLC channel #1806

Merged
merged 5 commits into from
Jan 9, 2024

Conversation

bonomat
Copy link
Contributor

@bonomat bonomat commented Jan 8, 2024

resolves #1785
resolves #1786

Copy link
Contributor

@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.

Looks mostly good to me!

crates/ln-dlc-node/src/node/dlc_channel.rs Outdated Show resolved Hide resolved
Comment on lines 219 to 232
tracing::error!( state = %channel.state, "Can't collaboratively close a channel with an open position.");
bail!("Can't collaboratively close a channel with an open position");
Copy link
Contributor

Choose a reason for hiding this comment

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

🔧 Why not?

Also, it's weird to log and return an error for the same error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, it's weird to log and return an error for the same error.

I started doing this because I stopped trusting where errors are being logged (or even ignored) and with this it's easier to find them.

🔧 Why not?

Mhm, good question. We had this in the past, so I kept it. Happy to change 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.

Thinking about it more. It's easier to tell the user to close the position first because otherwise we will need to calculate the PnL here and think about how to handle the otherside of the trade.

Copy link
Contributor

@luckysori luckysori Jan 10, 2024

Choose a reason for hiding this comment

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

I started doing this because I stopped trusting where errors are being logged (or even ignored) and with this it's easier to find them.

@bonomat: Hmmm, I'm not happy with this because we will end up spamming the logs with redundant messages, which makes debugging harder. We just need to fix the spots where errors are being swallowed. I don't think there can be many of those.

What do you think, @holzeis?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about it more. It's easier to tell the user to close the position first because otherwise we will need to calculate the PnL here and think about how to handle the otherside of the trade.

Fair. It's not strictly necessary and it's nice to keep things simple.

crates/ln-dlc-node/src/node/dlc_channel.rs Outdated Show resolved Hide resolved
crates/ln-dlc-node/src/node/dlc_channel.rs Outdated Show resolved Hide resolved
crates/ln-dlc-node/src/tests/dlc_channel.rs Outdated Show resolved Hide resolved
..
})
| Some(SignedChannel {
state: SignedChannelState::RenewFinalized { .. },
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Is this really how it works? Doesn't the channel go back to Established after this one? I'd consider this state part of Pending.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Afaik we end in RenewFinalized or Settled after any off-chain action and Established is only once the channel has been set up in the first place

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, we should verify this.

mobile/native/src/ln_dlc/channel_status.rs Outdated Show resolved Hide resolved
mobile/native/src/ln_dlc/channel_status.rs Outdated Show resolved Hide resolved
crates/fund/examples/fund.rs Show resolved Hide resolved
crates/ln-dlc-node/src/node/dlc_channel.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@holzeis holzeis left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

channel_id = %channel_id_hex,
"Closing DLC channel collaboratively"
);
self.is_safe_to_close_dlc_channel_collaboratively(&channel)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

🔧 It looks like this function does not add any additional value as it is already covered by the match below.

Signed-off-by: Philipp Hoenisch <philipp@coblox.tech>
Signed-off-by: Philipp Hoenisch <philipp@coblox.tech>
Signed-off-by: Philipp Hoenisch <philipp@coblox.tech>
@bonomat bonomat force-pushed the feat/collab-close-channel branch from 59a4b7c to 62660ee Compare January 9, 2024 09:39
@bonomat bonomat enabled auto-merge January 9, 2024 09:55
@bonomat bonomat added this pull request to the merge queue Jan 9, 2024
Merged via the queue into main with commit 1fbcff9 Jan 9, 2024
9 checks passed
@bonomat bonomat deleted the feat/collab-close-channel branch January 9, 2024 10:09
Copy link
Contributor

@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 addressing my review!

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.

Allow force-close dlc-channel Allow collab close dlc-channel
3 participants