-
Notifications
You must be signed in to change notification settings - Fork 411
Improve documentation for InboundHTLCState enum states. #634
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
Improve documentation for InboundHTLCState enum states. #634
Conversation
Codecov Report
@@ Coverage Diff @@
## master #634 +/- ##
=======================================
Coverage 91.26% 91.26%
=======================================
Files 35 35
Lines 20918 20918
=======================================
Hits 19090 19090
Misses 1828 1828
Continue to review full report at Codecov.
|
Yes, definitely much clearer! Especially with the example. I think a further improvement could be to rename the enum variants. When I was struggling to understand these states, the following questions came to mind:
By answering the first point, I think we can come up with some more intuitive names. |
Yes, I'd agree with those assessments -- Do you think this would be clearer, for the first 3?
I prefer the terms "offered" and "accepted", since they align with the spec better. If the first Q was not rhetorical, it seems to me like there are 3 different definitions of "announced" here. In RemoteAnnounced, Announced == offered. In AwaitingRemoteRevokeToAnnounce, Announce = accept. In AwaitingAnnouncedRemoteRevoke, Announced = "sent"(?). Though @TheBlueMatt would have to confirm these guesses... |
I like For the One idea: enum InboundHTLCState {
Offered(PendingHTLCStatus),
Pending(PendingHTLCStatus),
Accepted(PendingHTLCStatus),
Committed,
Removed(InboundHTLCRemovalReason),
} I'm not sure if there are better names for Thoughts? |
Agree My definition of "accepted" means the HTLC is definitely in our commitment tx and we've sent commitment sigs for it. I can explicitly define it the comments. But, the spec doesn't explicitly define it. edit: removed my suggestion for the Pending replacement, wasn't a fan actually |
FYI, my argument for using Don't have a strong opinion yet on |
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! Thanks.
lightning/src/ln/channel.rs
Outdated
/// Included in a received commitment_signed message (implying we've revoke_and_ack'd it), but | ||
/// the remote hasn't yet revoked their previous state (see the example below). We have not yet | ||
/// included this HTLC in a commitment_signed message because we are waiting on the remote's | ||
/// aforementioned state revocation. The reason we need this remote RAA (revoke_and_ack) is |
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 feel a bit awkward calling this the reason - is true, it is a reason, but the other reason is because RAA "commits" a state, but doesn't specify which state, leaving an implication of it ACK'ing the latest state (commitent_signed that we sent).
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.
Let me know if the new version is good. I added the second reason as the last sentence of the paragraph
a6d1b81
to
20e1b78
Compare
@jkczyz Upon further reflection, I'm in favor of all these names, except Pending, which I'm in favor of switching to |
IMO "Held" could be a tad misleading since these HTLCs are a subset of all HTLCs in the holding cell, afaict from the holding cell code? |
SGTM. Yes,
Good point -- I think you're right. |
20e1b78
to
96daffa
Compare
@jkczyz related to a previous discussion on Slack -- would appreciate your input on whether this is clarifying (though another reviewer will probably have to confirm that everything's correct here, first).