Skip to content

custom channels: use tapd as the aux component implementation for lnd in integrated mode #761

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
Jun 9, 2024

Conversation

guggero
Copy link
Member

@guggero guggero commented May 23, 2024

No description provided.

@guggero guggero force-pushed the custom-channels-integration branch 6 times, most recently from 407c675 to b9bbaca Compare May 31, 2024 13:22
@guggero guggero force-pushed the custom-channels-integration branch from b9bbaca to 776813b Compare June 3, 2024 11:40
@guggero guggero linked an issue Jun 4, 2024 that may be closed by this pull request
@guggero guggero force-pushed the custom-channels-integration branch from 776813b to 31d4fee Compare June 5, 2024 20:26
Copy link
Member

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

Had a quick look to gain familiarity - looks good and mostly plumbing 👍 main question is around why the cli commands belong here

config.go Outdated
@@ -379,6 +380,7 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
cfg.Remote.LitDebugLevel, cfg.Lnd.LogWriter,
)
} else {
SetupLoggers(cfg.Lnd.LogWriter, interceptor)
Copy link
Member

Choose a reason for hiding this comment

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

is this not covered by SetupLoggers(preCfg.Lnd.LogWriter, interceptor) 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.

Yes, you're right. I was debugging something logging related and forgot to remove this again. Confirmed it's not needed.

terminal.go Outdated
tapdWrapper, available := g.subServerMgr.GetServer(subservers.TAP)
if !available {
return nil, fmt.Errorf("tapd is not available, must be " +
"started in integrated mode for Taproot Assets " +
Copy link
Member

Choose a reason for hiding this comment

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

started in integrated mode -> do you mean that tapd must be integrated? cause 'integrated mode' to me means that lnd is integrated

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, both. I'll update the error message.


var lnCommands = []cli.Command{
{
Name: "ln",
Copy link
Member

Choose a reason for hiding this comment

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

would tap be better? ln to me is general lightning network

Copy link
Member Author

@guggero guggero Jun 7, 2024

Choose a reason for hiding this comment

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

Yeah, I agree. Though I think this is temporary and we'll remove them in a future release anyway (see comment below). But for now I think Polar already uses the commands in some demos, so I don't want to rename them just for renaming sake.

Choose a reason for hiding this comment

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

I suppose since it's inducing ln functionality but pairing with tapd it's a bit of both

"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/record"
"github.com/urfave/cli"
)
Copy link
Member

Choose a reason for hiding this comment

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

just skimmed this commit really quickly but it isnt yet immediately obvious to me why this is here and not in the taproot assets cmd directory? ie what makes this different from loopcli or equivalent?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do eventually want the logic that's done in this file be RPCs in tapd, then it will make sense to move them to tapcli. But for now we need access to both lnd's and tapd's RPCs from within a single command, which is done most conveniently in tapcli (see the way we bake a macaroon just to connect to tapd).

@guggero guggero force-pushed the custom-channels-integration branch from 31d4fee to 2fa4b07 Compare June 7, 2024 08:42
Copy link
Contributor

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

Really exciting to see how everything fits together 🎉🚀. Left some comments in this first (quick) pass.

terminal.go Outdated
Comment on lines 1263 to 1265
return nil, fmt.Errorf("tapd is not available, must be " +
"started in integrated mode for Taproot Assets " +
"Channels to be available")
Copy link
Contributor

Choose a reason for hiding this comment

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

The error messages could be more distinguished between running remotely and being available.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the error message according to @ellemouton's review. Hope it makes more sense now.

msatPerUnit := acceptedQuote.BidPrice
numUnits := uint64(decodeResp.NumMsat) / msatPerUnit

fmt.Printf("Got quote for %v asset units at %v msat/unit from peer "+
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to have user consent here, because sending is blocked by SendPaymentRequest where a user has time to read this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, this message isn't really about consent, more of an information (and I guess initially mainly added for debugging purposes 😅 ).
The actual validation of the exchange rate is done by the RFQ and price oracle logic of tapd. The end user will be able to plug in their exchange API of choice to validate prices against, and then define a maximum percentage (PPM actually) of deviation due to spread.

cmd/litcli/ln.go Outdated
ValueMsat: int64(numMSats),
DescriptionHash: descHash,
FallbackAddr: ctx.String("fallback_addr"),
Expiry: ctx.Int64("expiry"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this may need to use the default expiry 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.

Ah yes, good point. Fixed!

fabiaAssetBalance += fabiaInvoiceAssetAmount1

// ------------
// Test case 4: Create an asset invoice on Fabian and pay it with just
Copy link
Contributor

Choose a reason for hiding this comment

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

Why those are multipart payments isn't quite obvious to me, probably also need the assertions to check for the individual htlc attempts (early stage I guess 🙂).

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit hidden, we hard code the max shard size to 80k in the payInvoiceWithXXX() helper. So choosing a large enough asset amount will guarantee at least two shards. Updated the comment to make it a bit more obvious.
And yes, we don't currently track the number of attempts. There are a lot of assertions still missing here, mainly due to the fact that the itest library isn't fully compatible with the refactored version in lnd, so we can't just re-use a lot of those assertions.

@guggero guggero force-pushed the custom-channels-integration branch 2 times, most recently from 067d09c to ee468ba Compare June 7, 2024 16:45
@guggero
Copy link
Member Author

guggero commented Jun 7, 2024

Thanks for the reviews! I addressed all comments and fixed the failing CI steps (hopefully).
Taking the PR out of draft, even if we still want to add the force-close code. But that will likely only affect the integration test (and the go.mod file).

@guggero guggero marked this pull request as ready for review June 7, 2024 16:47
@guggero guggero requested review from ellemouton and bitromortac June 7, 2024 16:47
@guggero guggero force-pushed the custom-channels-integration branch from ee468ba to 57bf3a0 Compare June 8, 2024 13:45
@guggero guggero changed the base branch from master to 0-19-staging June 9, 2024 14:27
guggero added 8 commits June 9, 2024 17:51
This commit represents the main integration between lnd running in
integrated mode and tapd providing auxiliary components for custom
channels.
This change will speed up integration tests by not waiting a full 5
seconds before re-trying the connection to lnd if it fails the first
time.
@guggero guggero force-pushed the custom-channels-integration branch from 57bf3a0 to 0b2b3eb Compare June 9, 2024 15:51
@guggero guggero merged commit 980ee93 into 0-19-staging Jun 9, 2024
12 checks passed
@guggero guggero deleted the custom-channels-integration branch June 9, 2024 16:13
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.

itest: Incorporate custom channel itests into main
4 participants