-
Notifications
You must be signed in to change notification settings - Fork 266
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
Prepare InteractiveTxBuilder
to support splicing
#2595
Conversation
eclair-core/src/main/scala/fr/acinq/eclair/channel/fund/InteractiveTxBuilder.scala
Outdated
Show resolved
Hide resolved
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.
As discussed offline, this works well and I was able to rebase the splices PR on top of it (see branch splices-20230210), but there are two potential leads that we may want to explore:
- keeping msat granularity when building the post-splice commitment
- deferring more things to the
purpose
field: PrepareInteractiveTxBuilder
to support splicing #2595 (comment)
4e0f3fe
to
4809fbc
Compare
This is rebased on top of #2598 to make e2e testing of the splice prototype easier. The second commit re-works the It also moves the There is one caveat which we need to think about: if those two fields aren't saved with the |
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 love the change made to SharedTransaction
in 4809fbc.
However, I'm more skeptical about the changes made to:
InteractiveTxBuilder
: this breaks the convention that things related to building the transaction are to be put inInteractiveTxParams
, and things related to building the commitments are to be put inInteractiveTxBuilder
. Furthermore, swap-out is probably the main case where we will want to RBF the splice (user pays the fee, so will probably undershoot).DATA_WAIT_FOR_DUAL_FUNDING_CREATED
: I don't see the point of removingCommon
. It removes the symmetry withParams
, and introduces a little bit of redundancy since initialization oflocalCommitIndex
/remoteCommitIndex
is done in two places now (when creatingPurpose
, and then independently when creatingCommon
). Curious what motivated this change.
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/ChannelOpenDualFunded.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fund/InteractiveTxBuilder.scala
Outdated
Show resolved
Hide resolved
Adding splicing to the InteractiveTxBuilder requires: - adding a shared input (the current funding output) - adding outputs (when splicing out) The `localAmount` and `remoteAmount` provided are the amounts each peer contributes to the new funding output. Those amounts should be computed by the caller depending on what they intend to do (splice funds in/out). This model allows batching operations: if the caller wants to do several splices in and several splices out, this is easy to do by iterating over these operations and updating the targeted `localAmount` accordingly, the InteractiveTxFunder will take care of the rest. Note that when splicing, we currently truncate previous balances to sats. This results in 1 sat being given away to miners as fees, and a passive participant losing up to 999 msat of their balance. This can be changed in the future depending on the final spec choice, and shouldn't need a codec update since the previous balances come from the commitment field provided in the purpose. When splicing, the tx_add_input message we send for the shared input doesn't contain the previous transaction. There are two reasons for that: - it potentially doesn't fit into a lightning message (if > 65kB) - we don't need it, we know it correctly uses segwit
4809fbc
to
9e9f048
Compare
This is now rebased on |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #2595 +/- ##
==========================================
+ Coverage 85.50% 85.63% +0.12%
==========================================
Files 208 211 +3
Lines 16578 16913 +335
Branches 693 742 +49
==========================================
+ Hits 14175 14483 +308
- Misses 2403 2430 +27
|
And only unlock local inputs, not the shared input.
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.
💯
Adding splicing to the
InteractiveTxBuilder
requires:The
localAmount
andremoteAmount
provided are the amounts each peer contributes to the new funding output. Those amounts should be computed by the caller depending on what they intend to do (splice funds in/out). This model allows batching operations: if the caller wants to do several splices in and several splices out, this is easy to do by iterating over these operations and updating the targetedlocalAmount
accordingly, theInteractiveTxFunder
will take care of the rest.Note that when splicing, we currently truncate previous balances to sats. This results in
1 sat
being given away to miners as fees, and a passive participant losing up to999 msat
of their balance. This can be changed in the future depending on the final spec choice, and shouldn't need a codec update since the previous balances come from the commitment field provided in the purpose.When splicing, the
tx_add_input
message we send for the shared input doesn't contain the previous transaction. There are two reasons for that:The changes aren't that big, but some of them are a bit subtle. The tests are quite verbose and contain some duplication, but I find them very easy to read and useful that way, most of the refactoring I tried made them less clear, so I chose to keep them that way for now. Let me know if you think some duplication should be removed.