-
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
[lnwallet] Only Forward Committed Settles and Fails #1293
Conversation
de276a4
to
4033b59
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.
Nice! This is definitely a bug that has been lingering for some time. I've modified this patch locally to remove the initial "fix" commit and confirmed that the added test does indeed fail at the proper location.
Noted one minor aspect: in that we can make our assertion on forwarded fails more accurate to ensure the correct HTLC failure is forwarded, and not just any failure.
lnwallet/channel_test.go
Outdated
t.Fatalf("alice shouldn't forward any HTLC's, instead wants to "+ | ||
"forward %v htlcs", len(fwdPkg.Adds)) | ||
} | ||
if len(fwdPkg.SettleFails) != 1 { |
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.
We can strengthen this check a bit by ensuring the _proper failed HTLC is what's being forwarded.
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.
Fixed.
4033b59
to
c285c32
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.
utACK
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 👾
This PR fixes an issue that would cause us to forward a settle or fail prematurely, i.e. we would forward a settle or fail before it was fully committed by both commitment transactions.
Previously, we had such a check for
Add
htlcs, and ensure that neither theaddCommitHeightRemote
andaddCommitHeightLocal
were both non-zero. Here, we add the same constraints toremoveCommitHeightRemote
andremoveCommitHeightLocal
.We also change the logic around when an
Fail
orSettle
should be forwarded by requiring equality between the remote height andremoveCommitHeightRemote
. Currently, we use>=
to determine when we should forward an HTLC in order to mimic the logic forAdd
s.This change is more minor, and shouldn't result in any observed difference in behavior, but should provide an additional protection against forwarding the same settle or fail twice. The difference lies in that
Add
updates can persist in the log across multiple commitments after being added, whileSettle
s andFail
s are always removed immediately after being locked in.Fixes #1124.
Fixes #1053.
Fixes #977.