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 17268575857

Details

  • 1 of 99 (1.01%) changed or added relevant lines in 4 files are covered.
  • 84 unchanged lines in 16 files lost coverage.
  • Overall coverage decreased (-0.06%) to 56.558%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rfqmsg/reject.go 0 6 0.0%
rfq/oracle.go 0 12 0.0%
taprpc/priceoraclerpc/price_oracle.pb.go 1 23 4.35%
rfq/negotiator.go 0 58 0.0%
Files with Coverage Reduction New Missed Lines %
address/mock.go 2 96.2%
asset/group_key.go 2 72.15%
mssmt/compacted_tree.go 2 79.49%
tapdb/assets_common.go 2 78.72%
tapdb/sqlc/transfers.sql.go 2 82.65%
tapdb/sqlc/universe.sql.go 2 75.78%
tapchannel/aux_leaf_signer.go 3 43.43%
rfqmsg/records.go 4 70.8%
rpcserver.go 4 61.03%
tapdb/universe.go 4 81.64%
Totals Coverage Status
Change from base Build 17140538774: -0.06%
Covered Lines: 60774
Relevant Lines: 107454

💛 - 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
ffranr added 14 commits October 8, 2025 11:13
Refactor the function by introducing an internal helper to improve
readability.
Refactor MacaroonWhitelist to handle public universe proof courier
permissions independently. This clarifies the logic and avoids coupling
courier access with other universe server permissions.
Remove the defaultMacaroonWhitelist map and inline its entries directly
into the conditional logic within MacaroonWhitelist. This ensures that
access to previously always-available endpoints is now governed by
explicit user configuration (read/write/courier), improving permission
control and aligning with expected access restrictions.
Separate the mint anchor transaction fee rate calculation from
fundGenesisPsbt into anchorTxFeeRate.

This refactor is part of a broader effort to simplify calling
fundGenesisPsbt from unit tests.
Extract the wallet funding call into a closure that is passed as an
argument. This prepares fundGenesisPsbt to become a standalone
function, making it easier to call in unit tests.
Pass the pending batch and chain params into fundGenesisPsbt and convert
it into a standalone function rather than a method on ChainPlanter. This
change makes it easier to call fundGenesisPsbt from unit tests.
The batch key was only used for logging. This commit moves the log
messages outside fundGenesisPsbt, simplifying the function for
better code health.
The mock helper FundGenesisTx now returns the index of the change
output. It also dynamically computes the index of the change output it
adds. These enhancements will be useful when handling packets with
supply pre-commitment outputs.
The funding routine now uses the refactored fundGenesisPsbt function,
introduced in a previous commit. Which adds test coverage for the batch
funding logic.

An optional argument is also added to allow skipping funding.
@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
darioAnongba and others added 12 commits October 20, 2025 18:09
Refactored GetBlockTimestamp to call GetBlockHeaderByHeight and return
an optional error type. Removed the timestamp-to-block-height cache, as
it did not handle re-orgs correctly. This prepares the codebase for a
more comprehensive caching mechanism to be added in a follow-up commit.
Introduce a reusable cache that stores full headers keyed by height and
hash. Tracks confirmation depth and treats shallow entries as unsettled
(return miss). Detects conflicts at a height and invalidates shallower
headers on reorg. Size and random purge fraction are configurable
(default 100k entries, 10 percent).

Not yet used by LndRpcChainBridge.
…-rpc-macaroonwhitelist

Improve `MacaroonWhitelist` Structure and Permission Granularity
Adds a block header cache to LndRpcChainBridge, which indirectly
improves performance of methods like GetBlockTimestamp by avoiding
repeated block header fetches.
…int-pre-commit

Refactor `fundGenesisPsbt` and enhance test helpers for coverage
…k-header-cache

lndservices: add reorg aware block header cache; use in ChainBridge
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.
Marshalls oracle error codes received over-the-wire into OracleErrorCode
values, which are returned in oracle error responses.
Adds a 'QueryError' type for capturing the error resulting from a price
oracle query. These errors are used to construct quote reject messages.
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.
@lightninglabs-deploy
Copy link

@GeorgeTsagk: review reminder
@ffranr: review reminder

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

7 participants