Skip to content

price oracle: add intent, optional peer_id and metadata to QueryAssetRates RPC #1677

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

Merged
merged 8 commits into from
Aug 21, 2025

Conversation

guggero
Copy link
Contributor

@guggero guggero commented Jul 25, 2025

Fixes #1159 (replaces #1161).

cc @lukegao209 and @bitcoin-coder-bob, does this look like what you had in mind?
The metadata field can be used to send any JSON or other custom data (e.g. user information or authentication data) to the price oracle for any payment or invoice creation request.

The two new diagrams now show how the price oracle is called and with what parameters:
https://github.com/lightninglabs/taproot-assets/blob/cacf2339ff448bd04b7fdde4dcb713d196a75d4a/docs/rfq-and-decimal-display.md#price-oracle-interaction

See this to get an explanation for the intent values:

@guggero guggero added this to the v0.7 milestone Jul 25, 2025
@guggero guggero requested a review from ffranr July 25, 2025 13:15
@guggero guggero self-assigned this Jul 25, 2025
@guggero guggero added gRPC RFQ Work relating to TAP channel Request For Quote (RFQ). labels Jul 25, 2025
@guggero guggero added the oracle label Jul 25, 2025
@coveralls
Copy link

coveralls commented Jul 25, 2025

Pull Request Test Coverage Report for Build 17107029065

Details

  • 270 of 427 (63.23%) changed or added relevant lines in 16 files are covered.
  • 388 unchanged lines in 31 files lost coverage.
  • Overall coverage decreased (-0.3%) to 56.314%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rfq/manager.go 9 12 75.0%
rfqmsg/request.go 51 55 92.73%
rfqmsg/buy_request.go 13 19 68.42%
rfqmsg/sell_request.go 17 23 73.91%
taprpc/tapchannelrpc/tapchannel.pb.go 0 15 0.0%
rfq/oracle.go 35 55 63.64%
taprpc/rfqrpc/rfq.pb.go 0 20 0.0%
rfq/negotiator.go 55 77 71.43%
taprpc/priceoraclerpc/price_oracle.pb.go 7 36 19.44%
rpcserver.go 15 47 31.91%
Files with Coverage Reduction New Missed Lines %
tapdb/assets_common.go 2 77.41%
tapdb/migrations.go 2 76.06%
tapdb/mssmt.go 2 88.64%
tapdb/sqlc/mssmt.sql.go 2 52.98%
tapdb/sqlc/transfers.sql.go 2 82.65%
tapdb/universe_federation.go 2 88.55%
universe/syncer.go 2 82.73%
itest/multisig.go 3 97.91%
proof/courier.go 3 79.53%
tapchannel/aux_leaf_signer.go 3 43.43%
Totals Coverage Status
Change from base Build 17057360543: -0.3%
Covered Lines: 60427
Relevant Lines: 107304

💛 - Coveralls

@guggero guggero force-pushed the price-oracle-metadata branch from cacf233 to babbbfa Compare July 28, 2025 05:58
@ffranr
Copy link
Contributor

ffranr commented Jul 28, 2025

I think change log changes for this PR have been merged already: #1679 (comment)

@levmi levmi moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board Jul 28, 2025
@bitcoin-coder-bob
Copy link

bitcoin-coder-bob commented Jul 30, 2025

@guggero the combination of the Intent, CounterpartyId and Metadata fields accomplishes exactly what I had in mind. Thank you for implementing! Apologies for the late review.

@guggero guggero force-pushed the price-oracle-metadata branch from babbbfa to da60f26 Compare July 30, 2025 13:47
@guggero
Copy link
Contributor Author

guggero commented Jul 30, 2025

Added an end-to-end test that verifies all calls, taking out of draft.

@guggero guggero marked this pull request as ready for review July 30, 2025 13:49
@guggero guggero requested a review from GeorgeTsagk July 30, 2025 13:49
@levmi levmi moved this from 🏗 In progress to 👀 In review in Taproot-Assets Project Board Jul 31, 2025
Copy link
Member

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🙌

@lightninglabs-deploy
Copy link

@ffranr: review reminder

Copy link
Member

@jtobin jtobin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through this in detail, LGTM. 👍

To align the interface method names more with the actual RPC calls, we
replace the terms ask and bid with sale, purchase respectively.
This commit adds three new fields to the price oracle's QueryAssetRates
RPC call: The intent behind the call, the peer at the opposite side of
the transaction and user-defined metadata.
To understand the role of those fields and how they can help the price
oracle to decide what price rate to return, we also add a sequence
diagram with the full price oracle interaction to the RFQ document.
This commit adds the price oracle metadata field to the buy and sell
request messages that are sent over the p2p network between
participants. We'll actually hook up things to populate the value in a
later commit.
This informs the price oracle about the intent and other context
behind a call to its QueryAssetRate RPC method.
To improve privacy when using a public or untrusted third-party price
oracle, we no longer send a price hint by default. We also make sharing
the peer's identity public key with the price oracle opt-in.
@guggero guggero force-pushed the price-oracle-metadata branch from da60f26 to 3294fc1 Compare August 20, 2025 18:28
@guggero
Copy link
Contributor Author

guggero commented Aug 20, 2025

Rebased.

@guggero guggero merged commit d04ab96 into main Aug 21, 2025
72 of 76 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gRPC oracle RFQ Work relating to TAP channel Request For Quote (RFQ).
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[feature]: Add a 'memo' or 'custom' property in QueryAssetRatesRequest v4.2
7 participants