Skip to content

Conversation

GeorgeTsagk
Copy link
Member

@GeorgeTsagk GeorgeTsagk commented Jul 22, 2025

Description

First commit exposes our current tolerance, leading to new rounding errors.

There was also an inaccuracy in the way we sharded the amount across the number of HTLCs. We had to also carry the remainder of invoiceAmt / numHTLCs, which is currently added to the last shard.

Then we modify the tolerance model to instead be (1unit + 1msat)*numHTLCs

Let's use this topology to put things in order

Alice --[units]--> Bob --[msat]--> Carol --[units]--> Dave 

Dave creates an asset invoice, Alice pays to it (with N HTLCs)

  • When an HTLC is forwarded to Carol: Carol converts msats to units, this justifies N units of tolerance
  • When an HTLC is received by Dave: Dave converts the units of the HTLC back to msats, as the invoice is measured in msats, this justifies N msats of tolerance

The current rapid test tolerance model follows the above model and seems to be happy (for rapid.checks up to 10M)

@GeorgeTsagk GeorgeTsagk self-assigned this Jul 22, 2025
@ZZiigguurraatt
Copy link

how does this differ from #1639 ?

@coveralls
Copy link

coveralls commented Jul 22, 2025

Pull Request Test Coverage Report for Build 17449019071

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 14 (0.0%) changed or added relevant lines in 1 file are covered.
  • 8719 unchanged lines in 122 files lost coverage.
  • Overall coverage decreased (-7.8%) to 49.029%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapchannel/aux_invoice_manager.go 0 14 0.0%
Files with Coverage Reduction New Missed Lines %
authmailbox/client.go 2 69.84%
commitment/proof.go 2 87.29%
fn/retry.go 2 92.5%
tapdb/interfaces.go 2 78.33%
tapsend/proof.go 2 85.99%
universe/interface.go 3 72.7%
commitment/encoding.go 4 68.75%
rpcutils/price_oracle_marshal.go 4 85.07%
fn/recv.go 5 60.47%
rfqmsg/messages.go 5 85.52%
Totals Coverage Status
Change from base Build 17435593956: -7.8%
Covered Lines: 52797
Relevant Lines: 107685

💛 - Coveralls

@GeorgeTsagk
Copy link
Member Author

how does this differ from #1639 ?

above adds a single 1 unit per invoice on the tolerance

This approach adds N msats, where N is the number of HTLCs paying to this invoice

@levmi levmi moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board Jul 24, 2025
@GeorgeTsagk GeorgeTsagk force-pushed the invoice-tolerance-tweaks branch from b8ece69 to 343b196 Compare July 28, 2025 13:18
@GeorgeTsagk GeorgeTsagk marked this pull request as ready for review July 28, 2025 13:18
@levmi levmi requested review from guggero and ffranr August 5, 2025 14:37
Copy link
Contributor

@guggero guggero left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

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.

Have gone over this in detail, LGTM. 👍 👍

@lightninglabs-deploy
Copy link

@ffranr: review reminder

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM ❄️

// allows for a total error that scales with the number of
// shards. We go up to numHTLCS-1 because we want to add any
// leftovers to the last shard.
for range numHTLCs - 1 {
Copy link
Member

Choose a reason for hiding this comment

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

Heh, I always forget that we have this new range syntax to just do a simple loop N times.

@github-project-automation github-project-automation bot moved this from 🏗 In progress to 👀 In review in Taproot-Assets Project Board Sep 3, 2025
GeorgeTsagk and others added 5 commits September 3, 2025 16:49
We slightly bump the rapid test range for the asset rate, in order to
allow for 1 asset unit to evaluate to much less than 1msat. This exposes
some of the rounding errors causing errors in the rapid test (it fails
if you run it on this commit).
We update the tolerance model in the rapid test to account for 1 unit
plus 1 msat, both per HTLC.
@Roasbeef Roasbeef force-pushed the invoice-tolerance-tweaks branch from 469f2e1 to 4df245b Compare September 3, 2025 23:50
@Roasbeef
Copy link
Member

Roasbeef commented Sep 3, 2025

tacked on a commit with release notes

@Roasbeef Roasbeef merged commit 290c828 into main Sep 3, 2025
16 of 18 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

7 participants