-
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
Fix warning messages #6840
Fix warning messages #6840
Conversation
4be9167
to
5502fc2
Compare
5502fc2
to
d7e85fb
Compare
5570b13
to
a7fb4bd
Compare
lnwire/error.go
Outdated
@@ -47,6 +47,25 @@ func (e FundingError) Error() string { | |||
return e.String() | |||
} | |||
|
|||
// ErrorLike is an interface implemented by Error and Warning messages as | |||
// described in BOLT1. | |||
type ErrorLike interface { |
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 don't really see the benefit of this - I dislike changing the peer/brontide code more than it has to be changed. I think it is better if Warning
does not embed Error
and either:
handleError
is duplicated with ahandleWarning
functionhandleError
handles both aWarning
or anError
without an interface, and is renamed tohandleErrorOrWarning
or something similar
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 chose option A 👍
Cleared the milestone for the pr as the issue (#6801) is tagged now |
6e90ecf
to
09f0103
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.
i think the link test should be added back and that a fundingmanager test should be added
@@ -194,6 +208,18 @@ func WriteElement(w *bytes.Buffer, element interface{}) error { | |||
if _, err := w.Write(e[:]); err != nil { | |||
return err | |||
} | |||
|
|||
case WarningData: |
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.
is this called anywhere?
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 think we can actually also just fall through to the case below.
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.
No, and the method will be removed soon* (YY comment). However, I added in case someone is using lnwire.WriteElement
outside the lnd code base for completeness.
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.
IIRC, you had a test that you used to repro the behavior in the first place? If we modified SendCustomMessage
to allow sending messages below the custom message range w/ a build tag (for itests) then we can test this out in the wild to ensure that sending a warning doesn't lead to a force close. This should help catch any future regressions in the future.
@@ -194,6 +208,18 @@ func WriteElement(w *bytes.Buffer, element interface{}) error { | |||
if _, err := w.Write(e[:]); err != nil { | |||
return err | |||
} | |||
|
|||
case WarningData: |
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 think we can actually also just fall through to the case below.
@@ -1775,7 +1807,7 @@ func messageSummary(msg lnwire.Message) string { | |||
msg.ChanID, msg.ID, msg.FailureCode) | |||
|
|||
case *lnwire.Warning: | |||
return fmt.Sprintf("%v", msg.Error.Error()) | |||
return fmt.Sprintf("%v", msg.Warning()) |
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.
If we keep the existing Error
method, then we can pass it around as a normal error
. Not sure if we 100% want that behavior though...
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 leave it like this so we do not have any error in the future using the Error
interface for warnings.
359d6b8
to
7a1b788
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.
needs rebase
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 ❄️
7a1b788
to
5d71f95
Compare
@positiveblue the new linter rules seem to cause a few new complaints. |
06d769f
to
a48b0a0
Compare
Split the logic for processing `error` and `warning` messages from our peers.
a48b0a0
to
cba5095
Compare
Stop casting warnings to errors before passing it to the service handling the message. BOLT1 talks about error and warning messages so I created a new interface called
ErrorLike
.Warning messages for pending channels are now handled by the funding manager. Until now they were simply ignored.
Currently, the only action triggered by a warning messages sent by our peers is logging.
Fixes #6801