Skip to content

Custom channels itest: Use group keys on some payments & invoices #995

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GeorgeTsagk
Copy link
Member

@GeorgeTsagk GeorgeTsagk commented Mar 5, 2025

Description

We sprinkle around some group keys across the grouped asset custom channels test. Some of the invoices and payments in that test now use a group key instead of a specific asset ID.

Related tapd PR: https://github.com/lightninglabs/taproot-assets/pull/1423/commits

For the liquidity edge cases itest, we now support running it in assetID & groupKey mode, meaning we can go through the full suite of edge cases by using either a single assetID or a groupKey.

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.

I think this is a good start as a sanity check for some of the new logic. I think we'll want to more or less run each test w/ both asset ID and group key, but that might eventually be a bit unwieldy when it comes to execution time.

Ultimately, we do expect most of the primary use cases to use group keys, so pehrhaps it's fine to lean towards coverage there?


case len(groupID) > 0:
groupHash := sha256.Sum256(groupID)
targetID = hex.EncodeToString(groupHash[:])
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, do we need to modify what we return as JsonHtlc to start to include a distinct group key field? IIRC, it's all TLV within the db/lnd, so shouldn't be a big lift there, and should be backwards compat.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, good idea. We can definitely add that to make certain things easier. Even if it's just informative to the user and useful in itests (but not explicitly expected in the RFQ logic).

@guggero guggero self-requested a review March 6, 2025 11:08
@levmi levmi moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board Mar 6, 2025
@GeorgeTsagk
Copy link
Member Author

I think this is a good start as a sanity check for some of the new logic. I think we'll want to more or less run each test w/ both asset ID and group key, but that might eventually be a bit unwieldy when it comes to execution time.

Ultimately, we do expect most of the primary use cases to use group keys, so pehrhaps it's fine to lean towards coverage there?

I agree with you here, ideally we'd want to even focus more on group key usage compared to single asset IDs. I'll think of an approach that lets us run everything in assetID / groupkey mode, and see if it's worth the trouble.

Otherwise, we could just add groupkey explicit itests, and support the hybrid mode on the more extensive edge-case itests

Copy link
Member

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

Concept ACK


case len(groupID) > 0:
groupHash := sha256.Sum256(groupID)
targetID = hex.EncodeToString(groupHash[:])
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, good idea. We can definitely add that to make certain things easier. Even if it's just informative to the user and useful in itests (but not explicitly expected in the RFQ logic).

@GeorgeTsagk
Copy link
Member Author

Added an extra commit which lets us run the liquidity edge cases in assetID & groupKey mode

This way the edge case coverage is repeated for group keys without re-writing the whole test

We could take a similar approach for all other tests, so please take a look and LMK if you agree with that approach. It would ofcs lead to running everything twice, so double total itest time.

@GeorgeTsagk
Copy link
Member Author

Changed base to #998 in order to be able to test with the related tapd PR

@GeorgeTsagk
Copy link
Member Author

rebased on master

Copy link
Member

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

Looks pretty good! Have some ideas to reduce the size of the diff though.

targetID = hex.EncodeToString(assetID)

case len(groupID) > 0:
groupHash := sha256.Sum256(groupID)
Copy link
Member

Choose a reason for hiding this comment

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

Same here, re x-coordinate. I wonder why this didn't cause things to fail? Or did this still point to the old commit in tapd?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think you started the review a bit before I rebased & used latest ref to tapd, which also changed these lines in the LiT side

Copy link
Member Author

Choose a reason for hiding this comment

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

ok so it was the wrong commit (other comment)

@@ -1896,10 +1918,13 @@ func testCustomChannelsLiquidityEdgeCases(ctx context.Context,

logBalance(t.t, nodes, assetID, "10k sats")

opts = []payOpt{}
Copy link
Member

Choose a reason for hiding this comment

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

nit: var opts []payOpt to match empty initialization style above?

Copy link
Member Author

Choose a reason for hiding this comment

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

can't redeclare it, i'm just setting it again


// Run liquidity edge cases and only use group keys for invoices and
// payments.
testCustomChannelsLiquidtyEdgeCasesCore(ctx, net, t, true)
Copy link
Member

Choose a reason for hiding this comment

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

Can't we run this directly in testCustomChannelsLiquidityEdgeCases? Meaning to call the same sub test function there once with true once with false.
Each new test has quite a bit of overhead, so the more we can combine, the better.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes thought of that. We can't really do that as it will crash due to re-creating all the nodes again in the same network.

Ideally, we would want to have a helper function that resets the state to a "clean slate" as far as liquidity goes, so that we can re-run the same suite and have the same liquidity footprint across multiple runs.

Maybe can make an issue/todo for this and introduce it in a later PR.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I've actually come full circle now and started taking apart the HTLC force close test in #1017 and making two out of them. That helps with starting with a clean slate.
And the performance optimizations I have in #987 should make it so that there is no additional overhead for running things in the same test vs. in separate ones.
So this is okay the way it is now.

@GeorgeTsagk
Copy link
Member Author

unified the helpers / itests commit to make things simpler

@GeorgeTsagk GeorgeTsagk requested a review from guggero April 1, 2025 14:34
Copy link
Member

@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 pending nits and update to the actual merged commit of tapd.


// Run liquidity edge cases and only use group keys for invoices and
// payments.
testCustomChannelsLiquidtyEdgeCasesCore(ctx, net, t, true)
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I've actually come full circle now and started taking apart the HTLC force close test in #1017 and making two out of them. That helps with starting with a clean slate.
And the performance optimizations I have in #987 should make it so that there is no additional overhead for running things in the same test vs. in separate ones.
So this is okay the way it is now.

@github-project-automation github-project-automation bot moved this from 🏗 In progress to 👀 In review in Taproot-Assets Project Board Apr 3, 2025
We add support for group keys on payments and invoices across the
itests. This includes all the required helpers and optional arguments to
make adding invoices and sending payments group-key enabled.

In order to run the liquidity edge cases twice, once using only asset
IDs and once using only group keys, we need to extract the main logic
into a re-usable function that has the group key option on the top
level. If the group key flag is set, then we append the respective group
key opt to the payment & invoice related calls.
@lightninglabs-deploy
Copy link

@Roasbeef: review reminder

@levmi levmi requested review from ffranr and removed request for Roasbeef April 15, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

4 participants