-
Notifications
You must be signed in to change notification settings - Fork 137
rfq+rfqmsg: add structured price oracle error codes #1766
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
base: main
Are you sure you want to change the base?
Conversation
0a5e9ab to
6bdb36a
Compare
Pull Request Test Coverage Report for Build 19893520905Details
💛 - Coveralls |
ffranr
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.
I've taken another look through this.
IMO needs commit squash and then we can review the set of commits which will be merged.
5eaf8a9 to
a164c40
Compare
965998d to
83a4116
Compare
a164c40 to
e78d038
Compare
2b3ac4f to
035a840
Compare
e78d038 to
e8e57ec
Compare
|
@GeorgeTsagk: review reminder |
e8e57ec to
a36f4bc
Compare
Adds the 'UnspecifiedRejectCode' and 'UnavailableRejectCode' consts to represent the two protocol-defined rejection error codes of 0 and 1, respectively. The 'NewRejectErr' utility produces a RejectErr with the UnspecifiedRejectCode code, but pairs it with a custom error message.
Defines an OracleErrorCode type representing error codes returned by a price oracle, and updates proto definitions accordingly.
a36f4bc to
a2daeee
Compare
Marshalls oracle error codes received over-the-wire into OracleErrorCode values, which are returned in oracle error responses.
Adds a 'customRejectErr' function that handles errors resulting from a price oracle query, producing a quote reject message. The changes in the next commit will augment this function to disambiguate between public/private errors.
a2daeee to
966f761
Compare
Adds a flag (defaulting to false) that indicates that the error returned by a price oracle should be considered public, and can be safely forwarded to peers. Updates proto definitions accordingly.
| const ( | ||
| // UnspecifiedRejectCode indicates that a request-for-quote was | ||
| // rejected, without necessarily providing any further detail as to | ||
| // why. | ||
| UnspecifiedRejectCode uint8 = iota | ||
|
|
||
| // UnavailableRejectCode indicates that a request-for-quote was | ||
| // rejected as a price oracle was unavailable. | ||
| UnavailableRejectCode | ||
| ) |
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’s better, in my view, not to use iota. Reordering the const fields becomes a silent breaking change, and it’s easy to miss in review, especially as more error types are added.
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 turn this set of const values into a RejectCode enum type? We could then use it in RejectErr instead of a plain uint8. But I can see that just adding the const values is a win for now. So I wont block approve on this.
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.
Maybe we should make the name more specific than UnavailableRejectCode. Something like PriceOracleUnavailableRejectCode might be clearer. It’s long, but many things could be unavailable, so the extra clarity feels worthwhile.
| const ( | ||
| // UnspecifiedOracleErrorCode represents the case where the oracle has | ||
| // declined to give a more specific reason for the error. | ||
| UnspecifiedOracleErrorCode OracleErrorCode = iota | ||
|
|
||
| // UnsupportedAssetOracleErrorCode represents the case in which an | ||
| // oracle does not provide quotes for the requested asset. | ||
| UnsupportedAssetOracleErrorCode | ||
| ) |
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.
same comment here re iota
| // public is a flag indicating that the error can be forwarded to peers. | ||
| bool public = 2; | ||
|
|
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 think the price oracle should decide whether a tapd node forwards an error to its peer. That decision belongs entirely to tapd in my view. So IMO the price oracle shouldn’t signal whether an error is “public” or not.
We want to be able to query price oracle services operated by third parties.
Adds some structure to price oracle error codes, along with some custom handling for them. In particular, a code of '1' now corresponds to an 'unsupported asset' error, which, considered a 'public' error, is forwarded in the customizable message field of the reject messages sent to peers. An error with any other code continues, at present, to be treated as an unspecified error.
Resolves #1749, #1326.
(This is a refinement over the closed #1751, which forwarded errors indiscriminately.)