-
Notifications
You must be signed in to change notification settings - Fork 2.2k
routing+migration: fix mission control migration with nil failure msg #9770
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
routing+migration: fix mission control migration with nil failure msg #9770
Conversation
|
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
ziggie1984
left a comment
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.
First pass looks good, need to take a second look tho.
| msg: tlv.NewRecordT[tlv.TlvType1](failureMessage{failureMsg}), | ||
| } | ||
|
|
||
| if failureMsg != nil { |
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.
Add a comment why this might happen, decoding error of the error msg.
What about the case where we have a nil source index:
Lines 843 to 845 in b34afa3
| if sourceIdx == nil { | |
| return &paymentFailure{} | |
| } |
we should instead return nil here, so we do not create the failure information.
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 should instead return nil here, so we do not create the failure information.
Ah, I think we should do something about the pointer, I converted to use a fn.Option[paymentFailure] in other places and removed the pointer, because newPaymentFailure always constructs a paymentFailure, it still represents a payment failure if the info fields are absent.
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.
Add a comment why this might happen, decoding error of the error msg.
I added comments to the paymentFailure fields.
What about the case where we have a nil source index
The sourceIdx is a prerequisite to be able to decrypt the error via the hop's shared secret, so I think it makes sense to return an empty paymentFailure here, because if we don't know the index, we won't be able to get a message.
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 more or less had the same question when looking at the code. Perhaps this explanation is worth a comment in both versions of newPaymentFailure where we return an empty paymentFailure.
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.
It looks like one level of nesting can be removed, trying that out.
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.
It seems to work, I removed paymentFailure, whose role is now taken over by the old paymentFailureInfo. Instead of checking the optional record in paymentFailure, I think we can use the source index instead. I put all mission control migration changes together in the last commit, which was easier for me. Let me know if I should make changes in lockstep.
70f4cba to
68e6ad9
Compare
68e6ad9 to
dc7d1c9
Compare
guggero
left a comment
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 is later used to handle their nil values.
We can remove paymentFailureInfo since we can gate the result interpretation on the source index, meaning that if we don't have a source index, we deal with an unknown payment outcome because we couldn't pinpoint the failing hop.
This introduces an option instead to signal whether there was a failure for result interpretation.
ziggie1984
left a comment
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.
Looks very good, in my opinion we can also remove the sourceIdx pointer and check the nil case outside and return early or return an option. Because I don't think we want to persist an empty payment failure tlv in the case sourceIdx == nil espcially since the tlv is optional anyways ?
| if failure.info.IsNone() { | ||
| // Not having a source index means that we were unable to decrypt the | ||
| // error message. | ||
| if failure.sourceIdx.IsNone() { |
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.
should we error out if the sourceIdx is none but the failure.msg is not ?
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.
mentioned in other response
|
|
||
| // If we can't identify a failure source, we also won't have a decrypted | ||
| // failure message. In this case we return an empty payment failure. | ||
| if sourceIdx == nil { |
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 would prefer removing this pointer for sourceIdx, and catch the nil case outside of this function. or we return an option here for the paymentFailure, and set it to None in the sourceIdx=nil case wdyt ?
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 wonder if we should check the case sourceIdx == nil but failureMsg not and report an error ?
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 would prefer removing this pointer for sourceIdx, and catch the nil case outside of this function. or we return an option here for the paymentFailure, and set it to None in the sourceIdx=nil case wdyt ?
Because I don't think we want to persist an empty payment failure tlv in the case sourceIdx == nil espcially since the tlv is optional anyways ?
I think we always want to construct a paymentFailure here even if it's empty, because its presence in paymentResult indicates a payment failure (just one we don't know how to interpret precisely). So I think we can't save more in terms of serialization?
| // failure with unknown details. Otherwise, the index and failure message are | ||
| // used to populate the info field of the paymentFailure. | ||
| func newPaymentFailure(sourceIdx *int, | ||
| failureMsg lnwire.FailureMessage) *paymentFailure { |
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.
as mentioned before I think we can also get rid of the sourceIdx pointer ?
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'm currently not seeing a lot of advantages in removing the source index pointer and would like to keep further changes in this bug fix PR minimal (also with regards to changing the signature to return an error), since this is not touching the serialization. I can change it though if you feel strongly about it.
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.
ok cool let's keep it as is.
| store](https://github.com/lightningnetwork/lnd/pull/8911) to use a more | ||
| minimal encoding for payment attempt routes as well as use [pure TLV | ||
| encoding](https://github.com/lightningnetwork/lnd/pull/9167). | ||
| * [Migrate the mission control |
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.
Release notes in a separate commit please.
This commit is temporary and demonstrates a panic. To be squashed with the following commit.
ziggie1984
left a comment
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
dc7d1c9 to
5020e1f
Compare
|
Will also check for errors if somebody ran with the previous serialization. |
|
If anybody ran with the migration included in because of the change in serialization, just to be aware of that. This can be resolved by |
But the user has to revert back to a prior version to startup LND or ? |
|
They need to run |
Tries to fix #9769.
Demonstrates the migration error and attempts a fix by making the failure message an optional tlv record. I'm not sure if we want to do this because it's strange that the failure message is nil in the first place. Perhaps we want to instead migrate nil failure messages to
CodeNoneinstead or drop these entries.