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

Wait for 'FUNDING_LOCKED' in dualopend, not channeld #4293

Merged
merged 87 commits into from
Jan 10, 2021

Conversation

niftynei
Copy link
Collaborator

@niftynei niftynei commented Dec 21, 2020

Prework for allowing RBF of dual funded channel opens. We need to wait for FUNDING_LOCKED in dualopend, so that handling a request to RBF the channel can transition smoothly back to the 'opening' message flow.

To do this, we move all of the tx_sigs + psbt handling out of channeld, back into dualopend. We also add handling for reconnections, shutdown requests, and waiting for FUNDING_LOCKED to dualopend.

This looks like a big PR (because it is), but most of the stuff is small tweaks to the test suite to have tests pass for dual-funded channel flows. These aren't turned on here; waiting for the move over to dual-funding being a runtime flag (instead of compile flag).

Update: now based on top of #4294.

Changelog-None

@niftynei niftynei added this to the v0.9.3 milestone Dec 21, 2020
@niftynei niftynei force-pushed the nifty/df-rbf branch 2 times, most recently from 31a33e4 to 96510ad Compare December 22, 2020 19:29
tests/test_plugin.py Outdated Show resolved Hide resolved
tests/test_plugin.py Outdated Show resolved Hide resolved
Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

Verified up until commit 9e151f4.

Since we change the state machine to use two new states that might have been persisted in the DB, I'm a bit worried that we might break channels that were initiated before the upgrade, then loaded after the upgrade and no longer functional. Specifically I'm thinking about CHANNELD_AWAITING_LOCKIN vs. DUALOPEND_AWAITING_LOCKIN.

Can you confirm that this has been taken care of and works as expected?

I'll finish up the review asap, but thought some early feedback might be good 🎄🎅

openingd/dualopend.c Outdated Show resolved Hide resolved
openingd/dualopend.c Show resolved Hide resolved
openingd/dualopend.c Outdated Show resolved Hide resolved
openingd/dualopend.c Show resolved Hide resolved
lightningd/dual_open_control.c Outdated Show resolved Hide resolved
lightningd/dual_open_control.c Show resolved Hide resolved
lightningd/dual_open_control.c Outdated Show resolved Hide resolved
openingd/dualopend_wire.csv Outdated Show resolved Hide resolved
wallet/db.c Outdated Show resolved Hide resolved
wallet/wallet.c Outdated Show resolved Hide resolved
@niftynei
Copy link
Collaborator Author

Lots of great feedback here, thanks!

Since we change the state machine to use two new states that might have been persisted in the DB, I'm a bit worried that we might break channels that were initiated before the upgrade, then loaded after the upgrade and no longer functional. Specifically I'm thinking about CHANNELD_AWAITING_LOCKIN vs. DUALOPEND_AWAITING_LOCKIN.

Can you confirm that this has been taken care of and works as expected?

I don't believe this is a necessary concern, given that as it stands currently in master, there's no way for you to have opened a channel using dualopend unless you've manually edited the source code to add OPT_DUAL_FUND to the options added in lightningd. The code is only built if you're using EXPERIMENTAL_FEATURES but even then dual-funding hasn't been flagged on. So the possibility of a user having a channel in a state that'd need handling for this is very low and won't be a common case.

Given that the code is 'still dark', do you think it's reasonable to add handling/test for this case?

Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

Three quarters through and it's looking good 👍

lightningd/dual_open_control.c Show resolved Hide resolved
lightningd/channel_control.c Show resolved Hide resolved
lightningd/dual_open_control.c Outdated Show resolved Hide resolved
lightningd/peer_control.c Show resolved Hide resolved
openingd/dualopend.c Outdated Show resolved Hide resolved
contrib/pyln-testing/pyln/testing/utils.py Show resolved Hide resolved
contrib/pyln-testing/pyln/testing/utils.py Show resolved Hide resolved
tests/test_connection.py Show resolved Hide resolved
tests/test_misc.py Outdated Show resolved Hide resolved
tests/test_plugin.py Outdated Show resolved Hide resolved
@cdecker
Copy link
Member

cdecker commented Jan 4, 2021

Reviewed up to 204f2a5 of PR version 96510ad. Will finish up asap.

@cdecker cdecker self-assigned this Jan 4, 2021
Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

Turns out that the remainder wasn't that much, mostly tests and infra for tests.
Just some minor feedback that needs to be addressed, otherwise LGTM 👍

openingd/dualopend.c Show resolved Hide resolved
@cdecker
Copy link
Member

cdecker commented Jan 8, 2021

Thanks @niftynei for the update, I went through the range-diff and marked the addressed feedback as resolved.

The only ones that are not addressed yet are:

Could you comment on those?

@cdecker
Copy link
Member

cdecker commented Jan 8, 2021

btw, the size of the PR made me update my range-diff tool so I can navigate it easier and with colors xD

Copy link
Collaborator Author

@niftynei niftynei left a comment

Choose a reason for hiding this comment

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

Could you comment on those?

Forgot to submit these with the updates 🤦

lightningd/dual_open_control.c Outdated Show resolved Hide resolved
openingd/dualopend.c Outdated Show resolved Hide resolved
lightningd/channel_state.h Show resolved Hide resolved
lightningd/dual_open_control.c Show resolved Hide resolved
lightningd/dual_open_control.c Outdated Show resolved Hide resolved
lightningd/options.c Outdated Show resolved Hide resolved
contrib/pyln-testing/pyln/testing/utils.py Show resolved Hide resolved
contrib/pyln-testing/pyln/testing/utils.py Show resolved Hide resolved
tests/test_connection.py Show resolved Hide resolved
openingd/dualopend.c Show resolved Hide resolved
@cdecker
Copy link
Member

cdecker commented Jan 8, 2021

ACK 2d82765

@cdecker
Copy link
Member

cdecker commented Jan 8, 2021

Rebased on top of master to get rid of the conflicts on generated files.

ACK cbcddf2

@cdecker cdecker force-pushed the nifty/df-rbf branch 2 times, most recently from bdaa094 to 6fb51d5 Compare January 9, 2021 09:47
@cdecker
Copy link
Member

cdecker commented Jan 9, 2021

I'm afraid that merging #4271 caused a conflict in channeld.c that requires rebasing and fixing before we can merge. @niftynei can you do that, I failed miserably since it conflicts inside of a switch and nested #if statement xD

Non-functional yet, but this gets all the pieces in the right places,
rips the signature signing functionality out of channeld.
Suggested-By: Christian Decker (@cdecker)
We weren't sending a channel_open notification for dual-funded channels.

This is only sent for the 'accepter' side. We send it as soon as both
funding_tx sigs have been exchanged, even though it's possible the
funding transaction might be published without this having been the case.

Since we fail the channel if this happens, only notifying for good/valid
channels reaching the broadcast state is the right way to handle this.
Move pid collection down to when dualopend is definitely dead
We don't need it anymore. Normally it gets cleaned up by `cmd` but we're
done with it here.
we got rid of push_msats for dual funded channels. this assumes that hte
peer will match an equal amount of sats as ours (the df_accepter.py
plugin will do this)
Method for setting a ceiling on the fund matching capabilities of
df_accepter. Setting it to zero means we don't fund the channel anymore.
nodes need to be using the accepter plugin, so they'll match funding.
we used to use push_msat for this, but v2 gets rid of it.

*sad trombone*
Test connection/reconnection handling for v2 opens. We needed to fixup
the accepter plugin so that we were freeing up inputs on
disconnect/failure.
We're still ignoring multifundchannel failure tests, but now we use the
'dual-fund' flag instead of a blanket true.
Reject a peer's request to open a channel while we're already in progress
@cdecker
Copy link
Member

cdecker commented Jan 10, 2021

Tiny fixup to address a python lint. Merging asap :-)

@cdecker
Copy link
Member

cdecker commented Jan 10, 2021

ACK 92b0337

@cdecker cdecker merged commit 9906236 into ElementsProject:master Jan 10, 2021
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