-
Notifications
You must be signed in to change notification settings - Fork 417
Implement invalid-parameters-error for lightning-liquidity #4039
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
Implement invalid-parameters-error for lightning-liquidity #4039
Conversation
This is for consistency with LSPS1 and LSPS2
We will need it for possibly returning an invalid-parameters-error
…e fields that were unknown when deserializing
…'deserialize_with_unknowns()' If an unknown field is caught, error code -32602 will be returned, as the spec says. Also, add tests that check this for every LSPS request and response
🎉 This PR is now ready for review! |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4039 +/- ##
==========================================
+ Coverage 88.74% 88.79% +0.04%
==========================================
Files 176 176
Lines 129012 129703 +691
Branches 129012 129703 +691
==========================================
+ Hits 114491 115166 +675
- Misses 11926 11945 +19
+ Partials 2595 2592 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
converted to draft because there are some edge cases that are not covered. |
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.
Hmm, this is great work, but I do wonder whether we really should take on the around +1400/-250 LoC just to implement this error type.
For context, there was some discussion in the spec group around the potential complexity increase when the invalid-params error was first introduced, and we concluded that we'd attempt to implement it but revisit if it would be too painful to implement/support.
FWIW, I think we're pretty much at the 'too painful' level here, so I'd actually lean in favor of changing the spec here to not require the error to exactly return which fields it wasn't able to parse.
@martinsaposnic It seems that you agree with that conclusion, even though you already went and did the work now?
👋 The first review has been submitted! Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer. |
I do agree with that conclusion. I mostly wanted to give it a try in case I found a simpler approach, but at least now we have a concrete reference showing why it's complex, and it also gives us some justification to push back on the spec. I'm happy to open an issue or PR to BLIP-50 with proposed changes if you think that's the right next step @tnull |
Cool, yes, please feel free to open a PR to bLIP-50 to simplify the error (I think we should be able to drop the dedicated section entirely?) |
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.
Btw, when you then update this PR for the simplified version, mind adding a test to make sure we simply ignore the additional data
attachment in the error message, just to make sure we stay compatible with the original spec (although I doubt there is any chance anybody ever implemented this, tbh)?
just to clarify, the proposed BLIP change would be either: a) we ignore any unknown params and still succeed as long as deserialization works, OR both options are super easy to implement, just want to make sure we are on the same page |
I think we should do b) as a) might lead to unexpected outcomes. My point above was that, if somebody ever sends us the 'old style' invalid-parameters-error with reporting the unknown fields, we should still treat it just like any other invalid-parameters-error (this is likely already the case and trivial, might still be good to double check). |
closing this. will reopen once I rework this and implement the simpler logic described above |
Closes #3476
As per spec, https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS0/README.md#-32602-invalid-parameters-error, if an unknown param is received, error code -32602 must be returned, and the unrecognized parameter must be informed to the caller.
I tried a few things (see Notes) and I agree, it's not trivial, mainly because serde does not provide this out of the box.
I also think that this is probably too much complexity for the thing that is accomplished, but I would like others to chip in.
Notes:
things I tried:
unknown_fields
field with #[serde(flatten)] on all structs. the unknown fields would be deserialized on this new field. kind of hard to maintain and adds a lot of noise. I think it added some complexity with nested structs.