fixup! Use CLTV as tie-breaker for offered htlc output sorting (#790) #1360
fixup! Use CLTV as tie-breaker for offered htlc output sorting (#790) #1360
Conversation
- 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) cc @araspitzu
eclair-core/src/main/scala/fr/acinq/eclair/transactions/CommitmentSpec.scala
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/payment/PostRestartHtlcCleanerSpec.scala
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalStateSpec.scala
Outdated
Show resolved
Hide resolved
|
I wonder if we should make a type alias or case class for |
eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala
Outdated
Show resolved
Hide resolved
| spec.findHtlcById(htlcId, direction.opposite) match { | ||
| case Some(htlc) if direction == OUT => spec.copy(toLocal = spec.toLocal + htlc.add.amountMsat, htlcs = spec.htlcs - htlc) | ||
| case Some(htlc) if direction == IN => spec.copy(toRemote = spec.toRemote + htlc.add.amountMsat, htlcs = spec.htlcs - htlc) | ||
| def fulfillOutgoingHtlc(spec: CommitmentSpec, htlcId: Long): CommitmentSpec = { |
There was a problem hiding this comment.
I think the naming becomes counter-intuitive with this refactoring.
It made sense to say fulfillHtlc(spec, OUT, id) to mean that you were the one sending the fulfill (and fulfillHtlc(spec, IN, id) when you were the one receiving the fulfill).
Now it's really weird because we're saying fulfillOutgoingHtlc for an incoming HTLC, and fulfillIncomingHtlc for an outgoing HTLC...I would reverse that: fulfillOutgoingHtlc should fulfill an HTLC you sent, and fulfillIncomingHtlc should fulfill one you received.
It's the same for the failXXX functions below.
There was a problem hiding this comment.
Agree, this file is a mess, surely we can do better.
eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalStateSpec.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/wire/ChannelCodecsSpec.scala
Outdated
Show resolved
Hide resolved
t-bast
left a comment
There was a problem hiding this comment.
Nice, it's much better with these partial functions
eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/wire/ChannelCodecsSpec.scala
Outdated
Show resolved
Hide resolved
…pec.scala Co-Authored-By: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
araspitzu
left a comment
There was a problem hiding this comment.
Just a final nit on my side but the rest is ACK
eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala
Outdated
Show resolved
Hide resolved
t-bast
left a comment
There was a problem hiding this comment.
Do you want to address https://github.com/ACINQ/eclair/pull/1360/files#r400825220 right now or do you want to do it in a follow-up PR? I think the current naming of the functions is really backwards
|
I'm not sure, tbh I started this just with 617e2e6 in mind and pulled the thread... I think if we don't have a better idea right now, let's merge this now, we can always improve later. |
|
My proposal is to simply switch the names between the two functions, what do you think?
That sounds simple enough and coherent, is there an issue with that? |
Codecov Report
@@ Coverage Diff @@
## master #1360 +/- ##
==========================================
+ Coverage 86.35% 86.45% +0.10%
==========================================
Files 119 119
Lines 9253 9259 +6
Branches 398 390 -8
==========================================
+ Hits 7990 8005 +15
+ Misses 1263 1254 -9
|
That sounds entirely reasonable, done with 33977e5. |
This is a follow-up to #790 with more refactoring.