Skip to content

Conversation

@jtobin
Copy link
Member

@jtobin jtobin commented Aug 25, 2025

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.)

@jtobin jtobin requested review from GeorgeTsagk and ffranr August 25, 2025 11:28
@jtobin jtobin added error handling RFQ Work relating to TAP channel Request For Quote (RFQ). labels Aug 25, 2025
@jtobin jtobin force-pushed the oracle-error-codes branch from 0a5e9ab to 6bdb36a Compare August 25, 2025 11:35
@coveralls
Copy link

coveralls commented Aug 25, 2025

Pull Request Test Coverage Report for Build 19893520905

Details

  • 1 of 74 (1.35%) changed or added relevant lines in 4 files are covered.
  • 55 unchanged lines in 10 files lost coverage.
  • Overall coverage decreased (-0.05%) to 56.561%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rfqmsg/reject.go 0 6 0.0%
rfq/oracle.go 0 14 0.0%
rfq/negotiator.go 0 26 0.0%
taprpc/priceoraclerpc/price_oracle.pb.go 1 28 3.57%
Files with Coverage Reduction New Missed Lines %
rfq/negotiator.go 2 56.27%
tapdb/sqlc/transfers.sql.go 2 83.33%
itest/assertions.go 3 87.42%
address/mock.go 4 87.5%
tapdb/universe.go 4 81.04%
tapgarden/planter.go 6 80.16%
universe/archive.go 6 79.0%
tapdb/multiverse.go 8 79.89%
tapgarden/caretaker.go 8 76.63%
tapdb/assets_store.go 12 78.61%
Totals Coverage Status
Change from base Build 19823124678: -0.05%
Covered Lines: 64807
Relevant Lines: 114579

💛 - Coveralls

@jtobin jtobin requested a review from ffranr August 28, 2025 15:47
@levmi levmi moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board Sep 4, 2025
@levmi levmi moved this from 🏗 In progress to 👀 In review in Taproot-Assets Project Board Sep 11, 2025
Copy link
Contributor

@ffranr ffranr left a 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.

@levmi levmi added this to the v0.8 milestone Sep 25, 2025
@jtobin jtobin force-pushed the oracle-error-codes branch from 5eaf8a9 to a164c40 Compare October 16, 2025 01:44
@jtobin jtobin changed the base branch from main to 0-8-0-staging October 16, 2025 01:44
@jtobin jtobin requested review from GeorgeTsagk and ffranr October 21, 2025 18:49
@jtobin jtobin force-pushed the oracle-error-codes branch from a164c40 to e78d038 Compare October 21, 2025 19:02
@jtobin jtobin changed the base branch from 0-8-0-staging to main November 24, 2025 15:28
@jtobin jtobin force-pushed the oracle-error-codes branch from e78d038 to e8e57ec Compare November 24, 2025 15:30
@lightninglabs-deploy
Copy link

@GeorgeTsagk: review reminder
@ffranr: review reminder

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.
@jtobin jtobin force-pushed the oracle-error-codes branch from a36f4bc to a2daeee Compare December 3, 2025 11:49
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.
@jtobin jtobin force-pushed the oracle-error-codes branch from a2daeee to 966f761 Compare December 3, 2025 12:16
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.
Comment on lines +79 to +88
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
)
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Comment on lines +100 to +108
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
)
Copy link
Contributor

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

Comment on lines +241 to +243
// public is a flag indicating that the error can be forwarded to peers.
bool public = 2;

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

error handling RFQ Work relating to TAP channel Request For Quote (RFQ).

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

[feature]: structured error codes for price oracles [bug]: clearer error with price oracle that does not support the asset requested

6 participants