Skip to content

Conversation

@guggero
Copy link
Contributor

@guggero guggero commented Nov 27, 2024

Updates the force close HTLC sweep integration test to also do MPP payments, to make sure duplicate script keys due to identical MPP shard HTLCs don't cause an issue.

@guggero guggero requested review from Roasbeef and gijswijs November 27, 2024 15:19
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!

// active.
numHtlcs := 4
if mpp {
numHtlcs += 2
Copy link
Member

Choose a reason for hiding this comment

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

nit: could derive the numHtlcs from invoice amt + default max shard size

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, makes sense. That way we can also more easily increase the number of HTLCs later on.

@dstadulis dstadulis added this to the tapd v0.5 milestone Nov 27, 2024
@jharveyb jharveyb self-requested a review November 27, 2024 18:17
Copy link

@jharveyb jharveyb left a comment

Choose a reason for hiding this comment

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

LGTM - confirmed MPP behavior from peeking at the logs 💯

bobHodlInvoices []assetHodlInvoice
aliceHodlInvoices []assetHodlInvoice
assetInvoiceAmt = 100
assetInvoiceAmt = 5_000

Choose a reason for hiding this comment

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

nit: Bit confused on the math for this change causing MPP to get used.

AFAICT, setting mpp = true below limits the shard size to 80e6 msats / 80000 sats.

But the minted asset seems to be 1,000,000 itest-asset-cents. And it looks like assetInvoiceAmt is denominated in cents also. Not sure if decimal display is being set somewhere I can't find.

I also can't find the exchange rate being used here that would probably help clarify this math.

Choose a reason for hiding this comment

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

Update: I found the rate, from grepping after inspecting the logs, as the config value of mockoracleassetsperbtc. Would still be good to call out.

Also this log msg should be got quote for %d msats, not sats:

t.Logf("Got quote for %d sats at %v msat/unit from peer %x with SCID "+

So, the quoted sat amount is ~85901 sats, which is over the MPP shard threshold of 80000 sats / 4656 asset units.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, that's not super apparent. Added a comment to describe that, which then also makes the use of the mpp variable a bit more apparent.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't grok this either. Thanks for explaining it @jharveyb.

go.mod Outdated
github.com/lightninglabs/pool/auctioneerrpc v1.1.2
github.com/lightninglabs/pool/poolrpc v1.0.0
github.com/lightninglabs/taproot-assets v0.4.2-0.20241125202051-783fb1e5ab03
github.com/lightninglabs/taproot-assets v0.4.2-0.20241127150634-c96f36961231
Copy link
Contributor

Choose a reason for hiding this comment

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

Could bump it now to RC5, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, will do that once the tag is pushed in tapd.

@guggero guggero force-pushed the fix-htlc-mpp-duplicate-script-key branch from 894800d to 81f25b7 Compare November 27, 2024 20:07
@guggero guggero merged commit 8a4c588 into update-to-lnd-18-4 Nov 27, 2024
12 of 13 checks passed
@guggero guggero deleted the fix-htlc-mpp-duplicate-script-key branch November 27, 2024 20:07
aliceSweepTransfer := locateAssetTransfers(
t.t, aliceTap, sweepTx.TxHash(),
)
t.Logf("Alice's first-level sweep transfer: %v",
Copy link
Contributor

@gijswijs gijswijs Nov 27, 2024

Choose a reason for hiding this comment

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

nit:
This if-else statement could be extracted into its own function, with a string parameter for the Logf statement. This prevents the code duplication that is going on in this test.

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.

6 participants