Use CLTV as tie-breaker for offered htlc output sorting#790
Conversation
Codecov Report
@@ Coverage Diff @@
## master #790 +/- ##
==========================================
+ Coverage 86.20% 86.44% +0.23%
==========================================
Files 119 119
Lines 9202 9219 +17
Branches 390 400 +10
==========================================
+ Hits 7933 7969 +36
+ Misses 1269 1250 -19
|
|
Let's bring back this PR to life! 👻 |
|
I still finds this too complex, and it does not fix the hack we introduced with the "outputs already used" set. I think instead we should address this in 2 steps:
To implement the first step, when we build the commit tx and HTLC txs:
WDYT ? |
|
I agree it's too complex, i initially tried to link outputs with HTLCs with the type alias but it's clearly not readable enough. I like the suggestion of creating a stronger link between the |
|
I have an idea for that, I'll open a PR so we can discuss it |
|
I'm curious to see your proposal :), in any case i just pushed mine in f646576. It removes both the type alias for |
|
I've updated my code to use some of your ideas and published it there https://github.com/ACINQ/eclair/tree/link-committx-outputs |
f646576 to
2f97a5c
Compare
t-bast
left a comment
There was a problem hiding this comment.
This touches some very important parts of the protocol, before merging this we must make sure we've done extensive testing with lnd and c-lightning for identical HTLCs. Once we're close to merging it, can you please list the E2E tests done?
b3e42f9 to
dddac35
Compare
|
I think we should re-do the E2E test once we agree on the changes to the code (IIRC i did some test after opening the PR but it has passed a year now), also there is lightning/bolts#539 that can help with interop testing. |
|
Commit 453c7d0 applies the new naming, if there isn't other feedback we can go ahead with testing. |
t-bast
left a comment
There was a problem hiding this comment.
I went more in-depth, and now it makes much more sense to me.
I think it's a great clean-up, I like it!
Let's discuss my current comments and then I think we can start compat' testing.
t-bast
left a comment
There was a problem hiding this comment.
LGTM!
Let's do E2E tests and it's all good on my side 🚀
I'll do some tests on my side right now and will report back.
|
I've finished my compatibility testing. |
517ed54 to
d4703fc
Compare
|
Following yesterday's conversation and hoping to get everyone on board i'm proposing to type |
We are going in the right direction (pun intended), but the |
|
How do we store a |
If it's only needed in the codecs, that's an enum we can put closer to the codec code? Or we keep that enum here and use it only for the codec. |
We now use a small hierarchy of classes to represent HTLC directions. There is also a type alias for a collection of commitment output links.
748acd4 to
f59111a
Compare
|
Last update only addresses the PR feedback, i will push another commit for the removal of |
| val htlcCodec: Codec[DirectedHtlc] = ( | ||
| ("direction" | directionCodec) :: | ||
| ("add" | updateAddHtlcCodec)).as[DirectedHtlc] | ||
| ("add" | updateAddHtlcCodec)).xmap( |
There was a problem hiding this comment.
Can't you get the result of the directionCodec here? I think we have some codecs that do that, I'll look around.
There was a problem hiding this comment.
Told you it had the potential to be rabbit hole-y 🤣
There was a problem hiding this comment.
Actually your proposal works fine, I like it. I just find the indentation a bit confusing, what about:
val htlcCodec: Codec[DirectedHtlc] = (("direction" | directionCodec) :: ("add" | updateAddHtlcCodec)).xmap(
{
case IN :: add :: HNil => IncomingHtlc(add)
case OUT :: add :: HNil => OutgoingHtlc(add)
},
{
htlc => htlc.direction :: htlc.add :: HNil
}
)And we should put the import shapeless.:: at the top of the file IMHO, not a big fan of scattering imports in the file.
There was a problem hiding this comment.
Will do, i also don't like the scattered imports but i'd make an exception for shapeless.:: if imported at the top of the file it's very hard to understand what :: does if it's from scala's collection or shapeless.
|
Can we postpone the removal of |
t-bast
left a comment
There was a problem hiding this comment.
LGTM, thanks for this long-standing work!
If you don't have time in the next few days, I can work on the leftover refactoring we mentioned.
I think i can work on the refactoring, by the way before merging this PR i'd like to do a final E2E test. |
pm47
left a comment
There was a problem hiding this comment.
This is missing non-reg tests for the codec change, a failure here could be catastrophic.
|
At 60ba2e4 i applied the latest feedback by @pm47 (including the non-reg test). I also tested the compatibility with CL and it went okay (i compared the commitment transactions after adding HTLCs with same amount and preimage but different CLTV), i didn't test with LND master yet as there is a known issue that is being fixed. |
#1360) * removed the `Direction` class * improved the non-reg test for htlcs - check actual content instead of only success and roundtrip - use randomized data for all fields instead of all-zero - check the remaining data, not only the decoded value (codecs are chained so a regression here will cause the next codec to fail) Co-Authored-By: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
Fixes lightning/bolts#448 , by using the CLTV value from the htlc-timeout-tx when sorting the htlc_sigs in the commit_signature message.