-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Do not enforce new reserved value in PSBT midstep #5539
Do not enforce new reserved value in PSBT midstep #5539
Conversation
This allows adding additional funds to the wallet in the channel open transaction which may be required to reserve funds for anchor commitments. This needs lightningnetwork/lnd#5539 to work with an empty LND wallet.
Ping, could someone check if this is at least going in the right direction? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR must've slipped below the radar, sorry for the delay.
I think this is going into the right direction. Especially when reading that comment I think that was the intended behavior from the beginning but a refactor/fix somehow changed it.
This should be covered by an integration test I think, just to make sure nothing else in the funding flow breaks.
lnwallet/wallet.go
Outdated
// If no chanFunder was provided, then we'll assume the default | ||
// assembler, which is backed by the wallet's internal coin selection. | ||
if req.ChanFunder == nil { | ||
enforceNewReservedValue = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three types of ChanFunder
: PSBT, canned (used for Pool) and the wallet assembler. We only want to skip this check for the wallet assembler. So I think we should use the default value true
and only disable it for the PSBT funder (with a type check).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understood you correctly, so I added another commit. Is that what you had in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is what I meant. But it should be done in the same commit.
I agree it should have test. Unfortunately I have literally zero experience with writing tests in Go and LND. If you could give me a few bullet points on where to put it and how to structure it that'd be very helpful. |
See |
That wouldn't help and I think it's not needed. We can use a third node to fund PSBT. |
Is there a way to run a specific test only? The tests are slow and failing for what seem to be unrelated reasons, so I'd like to focus on getting this working. |
b5cd0b7
to
5695a4b
Compare
Strangely when I wrote my test, I tried to check if it actually fails without the change and it didn't. I couldn't figure out why and then life dragged me into bunch of other things. I still intend to try resolve this but if someone can help that'd be appreciated. |
5695a4b
to
f4841b4
Compare
Figured it out - forgot to enable anchors 🤦♂️ I rebased the changes and added the test which fails before the fix and passes after the fix. I only need to add release notes, but I don't know which version. Would it be possible to add this to point release, please? I was originally hoping to get this into 0.14... |
Let's try with 0.14.1. |
4de952a
to
e7b35ed
Compare
e7b35ed
to
c3f36ec
Compare
c3f36ec
to
632c54a
Compare
632c54a
to
91fed51
Compare
LOL, was looking at test and thinking why they don't run yet. :D Done. |
1c92ec3
to
2964679
Compare
Looks like same unrelated/flakes again. |
2964679
to
b6d720d
Compare
Updated release notes version to 0.14.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
b6d720d
to
77e2315
Compare
Rebased |
77e2315
to
cf65ee7
Compare
cf65ee7
to
d1bf897
Compare
This change avoids enforcing new reserved value when PSBT funding is not finished yet as new inputs and outputs may still be added that could change the outcome of the check. This originally failed in the scenario when funding a channel from external wallet *and depositing to on-chain wallet* was done simultaneously in a single transaction. If such transaction confirms then reserved UTXO is guaranteed to be available but the check didn't take it into account. The enforcement still occurs in the final step of PSBT funding flow, so it is safe. It also occurs in case of non-PSBT funding.
This adds an integration test that makes sure channel can be funded from empty wallet using PSBT if the funding transaction contains an output belonging to the wallet, satisfying the reserve.
d1bf897
to
333fe39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎎
Unrelated test failures again. |
This change avoids enforcing new reserved value when PSBT funding is not
finished yet as new inputs and outputs may still be added that could
change the outcome of the check.
This originally failed in the scenario when funding a channel from
external wallet and depositing to on-chain wallet was done
simultaneously in a single transaction. If such transaction confirms
then reserved UTXO is guaranteed to be available but the check didn't
take it into account.
The enforcement still occurs in the final step of PSBT funding flow, so
it is safe. It also occurs in case of non-PSBT funding.
This partially fixes #5363 (comment)
For full fix it'd be great to be able to optionally avoid anchor commitments (to improve privacy).
I will look at tests later, I mainly wanted to get initial feedback on this. If anyone would like to help with writing tests I'd be happy to accept. :)
Pull Request Checklist
Contribution Guidelines
the positive and negative (error paths) conditions (if applicable)
the bug being fixed to prevent regressions
logging level
go fmt
lnrpc/**/*.proto
) have been formatted withmake rpc-format
and compiled withmake rpc
sample-lnd.conf
(the tab character should be counted as 8 characters, not 4, as some IDEs do
per default)
make check
does not fail any testsgo vet
does not report any issuesmake lint
does not report any new issues that did notalready exist
cases it can be justifiable to violate this condition. In that case, the
reason should be stated in the commit message.