-
Notifications
You must be signed in to change notification settings - Fork 2.2k
input+lnrpc: realign witness types #7473
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
input+lnrpc: realign witness types #7473
Conversation
I think we need to test the mapping where it is needed in the codebase, because this will not prevent any errors when we are not actually changing the function where the mapping is done. mapping My recommendation: Try to use |
@ziggie1984 thanks for the feedback, I have
Would you mind taking another look? |
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 really good, left some comments :)
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.
Almost good from my side, had some final nits.
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 ⚡️
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.
Thanks for the PR!
Unfortunately we're between a rock and a hard place. We can't change the RPC values to not break older clients. And we can't change the native enum, because that's used for database values.
So we have to rely on the mapping.
@guggero: review reminder |
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 good, thanks for the update!
Can you rebase so the fixup commits are applied please? Then I'll do the final pass.
lnrpc/walletrpc/walletkit_server.go
Outdated
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.
nit: logging and error function calls get an exception in the formatting to help distinguish them from actual ("business logic") function calls: https://github.com/lightningnetwork/lnd/blob/master/docs/code_formatting_rules.md#exception-for-log-and-error-message-formatting.
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 see, makes sense. I've changed it from
return nil, fmt.Errorf(
"an error",
)
to
return nil, fmt.Errorf(
"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.
Actually, it should even be:
return nil, fmt.Errorf( "an error")
So in this case:
return nil, fmt.Errorf("unhandled witness type %v for "+
"input %v", pendingInput.WitnessType,
pendingInput.OutPoint)
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.
Right. Fixed it.
@guggero I've rebased the fixup commits. The PR is ready for a final pass. |
Refactor `PendingSweeps` to use `allWitnessTypes` map, and return an error from `PendingSweeps` if an unknown witness type is used, instead of logging a 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.
LGTM 🎉
Fixes #7460
This PR brings the
StandardWitnessType
enum back in line with theWitnessType
enum.To avoid breaking compatibility with the existing protobuf definition, I added the missing enum values there, and renumbered the enum values in the
input
package to match.I wasn't quite sure how to go about testing this. Really you'd want to iterate over all the values of a defined enum. Not sure if this is even possible in Go.
So instead I created a map from enum values to strings, and compared the values in that map with the generated protobuf enum values. Admittedly it's not foolproof.Whilst I was there, I also thought it made sense to refactor the.String
method to use this new mapEDIT: I reworked this a little, and the test now uses the.String
method directly without creating a global mapEDIT EDIT: went with the explicit map.