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: Sync wallet when contract is not confirmed yet. #2570

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

holzeis
Copy link
Contributor

@holzeis holzeis commented May 27, 2024

This is covering an edge case where the user opens a dlc channel and wants to close the position within the sync window of the coordinator.

It allows to instantly close the position without having to manually sync the wallet after the dlc channel has been created.


It's probably not the most important feature for prod, but it makes testing a bit easier... Happy to close this PR if the reviewer thinks that this is an unnecessary overhead.

@holzeis holzeis requested review from bonomat and luckysori May 27, 2024 12:53
@holzeis holzeis self-assigned this May 27, 2024
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.

I'm not a fan of this :(

I think it makes sense to sync eagerly in some cases. But when I call is_dlc_channel_confirmed I don't always want the sync to trigger e.g. in certain tests.

I would be okay with defining a separate API with similar behaviour, to be called in certain spots.

.is_dlc_channel_confirmed(&dlc_channel_id)
.await?
{
bail!("Did not see funding tx in mempool yet.");
Copy link
Contributor

Choose a reason for hiding this comment

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

🔧 I don't like this change because it assumes that the DLC channel will always be confirmed as soon as the transaction hits mempool, but this may not always be the case.

I think the original error message is fine, but if you want better error messages you could adapt the is_dlc_channel_confirmed API to return more information to build a better error message here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🔧 I don't like this change because it assumes that the DLC channel will always be confirmed as soon as the transaction hits mempool, but this may not always be the case.

I thought this was the case. When do we have to wait for a confirmation?

Copy link
Contributor

Choose a reason for hiding this comment

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

What I mean is that the error message now reflects an implementation detail: that the number of required confirmations is always 0. And the implementation detail may change in the future, but this error message is independent of that and could easily get stale.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough! I will adapt the message.

@holzeis
Copy link
Contributor Author

holzeis commented May 28, 2024

I think it makes sense to sync eagerly in some cases. But when I call is_dlc_channel_confirmed I don't always want the sync to trigger e.g. in certain tests.

hmm.. Can you explain in what tests you would not want to eagerly sync if the dlc channel is signed, but the contract is not confirmed? I thought this could only be the case if we are missing a sync, because use 0-conf everywhere.

I would be okay with defining a separate API with similar behaviour, to be called in certain spots.

I can definitely do that, but I guess I will replace all calls to the current is_dlc_channel_confirmed function, so maybe a rename would be enough?

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.

I do dislike the way we are sneakily triggering the on-chain sync from a method called is_dlc_channel_confirmed, so I would prefer something a more explicit name.

But this is definitely useful in a few spots, so I don't want to block the PR.

.is_dlc_channel_confirmed(&dlc_channel_id)
.await?
{
bail!("Did not see funding tx in mempool yet.");
Copy link
Contributor

Choose a reason for hiding this comment

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

What I mean is that the error message now reflects an implementation detail: that the number of required confirmations is always 0. And the implementation detail may change in the future, but this error message is independent of that and could easily get stale.

@holzeis
Copy link
Contributor Author

holzeis commented May 31, 2024

I will see to rename the function to make it clearer.

@holzeis holzeis force-pushed the fix/adapt-unconfirmed-dlc-channel-message branch from a177ac0 to 4e62b51 Compare June 3, 2024 09:50
@holzeis holzeis enabled auto-merge June 3, 2024 09:51
@holzeis holzeis added this pull request to the merge queue Jun 3, 2024
Merged via the queue into main with commit 921e9ed Jun 3, 2024
23 checks passed
@holzeis holzeis deleted the fix/adapt-unconfirmed-dlc-channel-message branch June 3, 2024 10:23
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.

2 participants