-
Notifications
You must be signed in to change notification settings - Fork 23
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
Implementing the LN-DLC node #34
Comments
what do you mean by "settle into the DLC channel"?
Is that possible without closing and reopening the DLC? This could be very handy in case parts of the position will get closed. |
Should we add "create lightning channel on an incoming payment"? Its related to the open a lightning channel, but a bit more complex imho. |
It might help to compare this feature with what was possible in ItchySats. In ItchySats we could: rollover, by rebuilding the commit transaction and subsequent transactions (off-chain); settle collaboratively, by publishing a new transaction spending from the fund transaction (on-chain); settle non-collaboratively, by publishing a previously signed commitment transaction and a CET or refund transaction later (on-chain). In 10101 we want to be able to collaboratively settle without going on-chain. This necessitates the introduction of a DLC channel where you can have outputs other than DLCs. In practice, I think it's as simple as expanding the commitment transaction to support both DLCs and outputs that pay directly to either party. Interestingly, those outputs also need to be timelocked since commitment transactions can be revoked. But |
With the DLC channel I described above, we can increase and reduce the size of the DLC without going on-chain. It's like rolling over, but a bit more versatile. But in that case, if you're looking to increase the size of the DLC, you are limited to the funds pre-allocated to the DLC channel's buffer transaction. If you want to have access to more funds, then you need to consider moving funds using the split transaction. That's a bit more involved as it affects the Lightning channel too, but it's off-chain. And beyond that, you can consider splicing into the split transaction, but that's an on-chain procedure. |
I've modified the issue description to take into account recent discussions. Particularly the ones pertaining to the scope of the MVP. Each entry in the features section corresponds to a feature that we expect to see in 10101 that is related to the LN-DLC node. They're labelled with "could", "should" or "must" to indicate their importance. Here's Philipp's original description for this issue. There is nothing wrong with it and there might still be useful information here, but I wanted to rework it based on the MVP scope discussions.
|
These test descriptions come from #34. The file structure is inspired by https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html#Rules-of-Thumb.
Hi all, was notified of this by Philipp, excited that you’re considering using rust-dlc! Just some comments:
It’s not really a question of time. I’d incorporate more code within rust-lightning if I knew that they’d merge it. The main reason to keep things minimal is to make rebasing easier. What I’d mainly do is move the channel splitting logic there to avoid the awkward API to update the fund tx output.
I just rebased the branch on 0.113 I hope it didn’t break things for you, I didn’t realized you were already working on that!
Not sure what you’re referring to here?
At the moment the way to do it is to close the DLC channel and reopen it with a different amount. I think it’s possible to directly reconstruct a new split transaction (without having an intermediary commitment transaction) but it’s not currently implemented.
If you go with this option there is code somewhere for interacting with Surebits oracle, I can dig it out.
I guess even if you use the extra output on commitment tx you’d still have to keep track of DLC related revocation. The extra thing you need to track here is the split transaction.
There is no api for that at the moment, but I think it should be feasible.
What do you call “party” outputs? At the moment there is support for settling the DLC off chain, keeping the DLC channel open so that you can make a new one within the same channel. Instead of a buffer tx it uses a settle tx which is also revokable. Also I'm in the process of cleaning up the code. I'm considering moving the sub-channel thing into the DLC manager as at the end it doesn't feel really useful to have them separate, but let me know if you have an opinion on that. |
Regarding testing what is really missing at the moment are tests with 3 or 4 nodes, trying to make payment at the same time/ in the middle of the channel splitting process. I think some issues will probably appear. |
Hey, @Tibo-lg! Thanks for having a look at what we are doing ;D
Optimising for ease of rebasing makes a lot of sense since it's hard to anticipate if/when the changes will be upstreamed.
Good to know! At this stage we've opted for forking these two repos including your branches in case we need to make quick changes, but I do expect us to stay in sync with any changes you introduce as soon as possible. I did have to make some very minor changes to both
Yeah, sorry, this is not very clear. I ties in with another part of your message so I'll respond to it all together.
What I was expecting or wanting from the buffer transaction was support for (1) DLC(s) and (2) outputs that pay directly to one of the two parties (the "party" outputs). The purpose of this would be to increase and reduce the value of a DLC without having to redirect the funds to the Lightning side of the split transaction, because I don't want to recompute signatures for that side of things if I can help it. What I'm hearing from you is that you can instead replace the entire DLC in the buffer transaction with a new type of transaction which only holds the settlement outputs. That's cool and I completely overlooked the fact that you can actually revoke and replace that settle transaction with a new buffer transaction. It is slightly different than what I had in mind, but what I had in mind might not even be necessary for our use case at the moment.
What actually happens when you close the DLC channel? My guesses would be either:
It would certainly be more convenient if we could just remake the split transaction with different amounts and recompute the children based on that. But it shouldn't be a deal breaker at this stage.
That would be very helpful. I reckon rolling with Suredbits is best for us atm.
My understanding was that by embedding the DLC directly into the commitment transaction, any update to the channel, be it payments-related or DLC-related, would just result in a new commitment transaction, so revocation of old DLCs would come for free. I suppose it depends how the DLC is embedded. If you embed the DLC directly as an output that reuses the revocation key of the current commitment transaction, I think it would work. If you embed an output that is spent by a buffer transaction containing the DLC, then you do have to introduce your own revocation scheme independent of Lightning.
I see. So at the moment you can't go back from a published split transaction. That's only a little bit limiting, because I think the ideal mode of operation very rarely leads to this happening anyway. I suppose in theory you should be able to reinterpret the published split transaction as a funding transaction, and then you could start over.
Thanks for the heads-up! At this stage we do expect breaking changes because we know we are depending on a feature branch haha. It's a bit early for us to have formed an opinion on these APIs, but we're gonna start to use them over the next few days, so we'll let you know. For what it's worth, it was a bit surprising to find a dedicated |
This reminds me that the testing that we are intending to do in this repository might be a bit redundant in the long run and we may just want to help you write some of these (if they don't exist already) in The overall purpose of writing these tests here at the moment is to familiarise ourselves with the APIs and attempt to figure out if there is a common interface involving |
Yeah looks like the update to 0.0.113 did break things sorry! Also if you have some Clippy rules that you require as long as they’re not too annoying I’m ok with applying them in the root repo.
Ok I see what you mean, and I think it’s definitely doable, but I’m a bit unsure what you gain from it rather than just adjusting the output amounts of the DLC? I guess the user can access the funds a bit more quickly in case of unilateral close, but is there anything else?
The second. Indeed it’d be better to renew the split tx, I’ll let you know when I end up implemented it (or let me know if you want to have a go at it).
Just realized it’s actually part of the ln/dlc branch. It’s this commit.
You’re right hadn’t considered that you could just revoke the commit tx.
Yeah tbh it’s quite a small change to enable this, there is internally two separate calls being made to close the DLC channel and the LN channel, so you’d just need to split them at the API level.
It’d definitely be helpful if you add more test and push them back to the rust-dlc repo! I’ve also looked at |
These test descriptions come from #34. The file structure is inspired by https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html#Rules-of-Thumb.
These test descriptions come from #34. The file structure is inspired by https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html#Rules-of-Thumb.
These test descriptions come from #34. The file structure is inspired by https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html#Rules-of-Thumb.
These test descriptions come from #34. The file structure is inspired by https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html#Rules-of-Thumb.
Once I fix the issue with using 0.0.113 I'll refactor things and put everything under the DlcManager. I don't recall exactly why I wanted to separate things originally but I also feel like it was not a good choice. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
I guess we did it! (The missing tasks are not priorities right now.) |
This epic assumes that we have chosen to follow the approach outlined in this blog post to build a node that supports Lightning and DLC channels side-by-side.
This decision to use this protocol will be documented in:
The early development of this node will be carried out in a separate
ln-dlc-node
crate within this workspace, but ultimately the goal is to use the node as a long running process within the coordinator and mobile app binaries.Notes on
rust-dlc
+rust-lightning
Forks
For the moment we focus on working on our own forks to speed up development, but eventually we are aiming to use a stable release of
rust-dlc
and evenrust-lightning
.rust-dlc
: https://github.com/get10101/rust-dlc/tree/feature/split-tx-manager-2rust-lightning
: https://github.com/get10101/rust-lightning/tree/split-tx-experimentmain
if we need new features.Observations
DLC channel does not yet support multiple outputs
Multiple DLCs
Not needed until StableSats or multiple contract symbols.
DLC + regular output
Needed to be able to open and close positions without affecting Lightning channel. This may affect ergonomics, because we don't know how long it takes to remake the split transaction and how smoothly it works.
Theoretically it's not necessary though.
rust-dlc
doesn't supportOlivia
Different attestation scheme
Olivia
uses a simpler, bespoke attestation scheme, whereasrust-dlc
conforms todlcspecs
.Different API
Olivia
uses bespoke messages, whereasrust-dlc
conforms todlcspecs
.Olivia
.General
Tasks to prepare the codebase for the introduction of the
ln-dlc-node
crate:ln-dlc-node
sub-crate #45.Define the public API oflnd-dlc-node
crate #46.Features
Receive and send payments via Lightning (must)
This should be a given if we use
rust-lightning
and we don't mess with thecommitment_transaction
. In the 10101 PoC we did mess with thecommitment_transaction
and we broke it when the DLC was present.Deposit into Lightning wallet using Lightning (must)
This is effectively the same as receiving a payment without having a channel with the coordinator beforehand.
Options
We figured out that routing the payment all the way to the coordinator first was best and also feasible. We list the other option in case we missed something and we end up needing a backup plan.
Route payment all the way to the coordinator first
Flow
Open channel between coordinator and user first
Flow
Drawbacks
Receive and send on-chain (must)
In
10101-poc
we achieved this by involvingbdk
via a fork of thebdk-ldk
crate. Soon after we started using that code, the maintainer noted that the project was no longer maintained and suggestedldk-node
as an alternative.Transfer between DLC channel and Lightning wallet (must)
split_transaction
always present even if only one of the channels is active?split_transaction
and children.Send on-chain from the Lightning wallet (could)
Using submarine swaps. We may not need to implement this service ourselves.
Create a CFD based on a price event from an oracle (must)
Use the APIs already provided by
rust-dlc
.Oracle options
Use
Olivia
Will require code changes:
rust_dlc::Oracle
trait.rust-dlc
to supportOlivia
's attestation scheme.Use a
p2pderivatives
oracle instance hosted by us.Use a
dlcspecs
-compliant oracle, such as the ones listed by Suredbits.Create multiple CFDs at once (could)
This might only be needed when we support multiple contract symbols.
Punish publication of revoked DLC channel buffer transaction (should)
should
label.Settling a DLC (must)
Non-collaboratively (must)
buffer_transaction
,CETs
andrefund_transaction
must work, but this is already done byrust-dlc
.split_transaction
is the experimental component introduced by Tibo's recentrust-dlc
branch. We should verify that it is properly tested and add tests if necessary.Collaboratively (must)
Options
DLC into DLC channel "party" outputs
buffer_transaction
's revocation timeout.rust-dlc
does not yet support "party" outputs. We would need to extend the library for that.DLC into Lightning channel "party" outputs
split_transaction
, moving the coins to the Lightning channel.split_transaction
would need to change, affecting all the other Lightning-related transactions.The text was updated successfully, but these errors were encountered: