Skip to content
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

[custom channels]: update to unmerged release branch of lnd 0.18.4-beta #1130

Merged
merged 9 commits into from
Oct 22, 2024

Conversation

guggero
Copy link
Member

@guggero guggero commented Sep 19, 2024

This PR prepares all compile time changes that will come with lnd v0.18.4-beta. We don't have a tag for v0.18.4-beta yet, but the release branch will remain stable (meaning only new PRs will be added).
So we'll still need a version bump PR later, but it should only be a go.mod/go.sum bump, which means the main review can be done in this PR.

Full serialized dependency list can be seen here: lightninglabs/lightning-terminal#848

@guggero guggero changed the title [custom channels¨ [custom channels]: update to tagged version of lnd Sep 19, 2024
@coveralls
Copy link

coveralls commented Sep 19, 2024

Pull Request Test Coverage Report for Build 11460101149

Details

  • 42 of 394 (10.66%) changed or added relevant lines in 17 files are covered.
  • 51 unchanged lines in 10 files lost coverage.
  • Overall coverage decreased (-0.03%) to 40.404%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rfqmsg/buy_request.go 0 1 0.0%
rfqmsg/sell_request.go 0 1 0.0%
tapchannel/aux_invoice_manager.go 0 1 0.0%
itest/utils.go 0 2 0.0%
tapchannelmsg/records.go 2 4 50.0%
rfqmsg/records.go 15 18 83.33%
rfq/order.go 0 4 0.0%
rfqmsg/messages.go 23 27 85.19%
rfq/manager.go 0 5 0.0%
tapchannel/aux_traffic_shaper.go 0 8 0.0%
Files with Coverage Reduction New Missed Lines %
server.go 2 0.0%
tappsbt/create.go 2 53.22%
tapchannel/aux_leaf_signer.go 3 36.33%
rfqmsg/buy_accept.go 3 0.0%
tapchannel/aux_funding_controller.go 4 0.0%
commitment/tap.go 4 83.91%
asset/asset.go 4 81.61%
tapchannel/aux_sweeper.go 7 0.0%
tapgarden/caretaker.go 8 68.5%
tapchannel/aux_leaf_creator.go 14 0.0%
Totals Coverage Status
Change from base Build 11456580163: -0.03%
Covered Lines: 24408
Relevant Lines: 60410

💛 - Coveralls

@dstadulis dstadulis added this to the v0.4.2 milestone Sep 19, 2024
@dstadulis dstadulis added the dependencies Pull requests that update a dependency file label Sep 19, 2024
@guggero guggero force-pushed the update-to-lnd-18-4 branch 2 times, most recently from 0a37fcf to 45d3a96 Compare October 15, 2024 11:33
@guggero guggero changed the title [custom channels]: update to tagged version of lnd [custom channels]: update to unmerged release branch of lnd 0.18.4-beta Oct 15, 2024
@guggero guggero force-pushed the update-to-lnd-18-4 branch 2 times, most recently from 95064dd to 32bff76 Compare October 15, 2024 12:06
@guggero
Copy link
Member Author

guggero commented Oct 15, 2024

Similar to lightninglabs/loop#828, I bumped to lndclient v0.18.4-0 which references lightningnetwork/lnd#9183 (commit lightningnetwork/lnd@ca3bde9) which should remain stable, so we can start the main review work here.

@guggero guggero marked this pull request as ready for review October 15, 2024 12:07
@guggero guggero requested review from GeorgeTsagk and ffranr October 15, 2024 12:07
Comment on lines 37 to 76
// We need to make sure the block height is within the range of valid
// SCID block heights.
scid := lnwire.NewShortChanIDFromInt(scidInteger)

minBlock := uint32(aliasmgr.AliasStartBlockHeight)
maxBlock := uint32(aliasmgr.AliasEndBlockHeight)

// If we're within the valid range, we can return the SCID as is.
if aliasmgr.IsAlias(scid) {
return SerialisedScid(scid.ToUint64())
}

// Normalize the value relative to min, then wrap within blockRange, and
// finally shift back by min. Generated by ChatGPT and I couldn't find a
// better way to do this.
blockRange := maxBlock - minBlock + 1
scid.BlockHeight = ((scid.BlockHeight-minBlock)%blockRange+blockRange)%
blockRange + minBlock

return SerialisedScid(scid.ToUint64())
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 shifting will need to be described in the BLIP:

Given a valid `rfq_id`, the RFQ specific SCID `tap_rfq_scid` is defined by
taking the last `8` bytes of the `rfq_id` and interpreting them as a 64-bit
integer.

It would probably be simpler at this point to just generate a SCID independent of RFQ ID and pass it to our peer in the RFQ request message.

There might be an advantage in separating the RFQ message ID from the SCID. We might be able to re-use the same SCID across multiple quotes for example. So every payment would correspond to a single RFQ quote but then multiple payments can share the same SCID.

There may be an advantage there when we come up with a formulation that avoids quote re-use.

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 don't think separating the two values is a good idea at this point. I went with the approach to generate random IDs until they fall within the correct range.

So the bLIP could just say: "The rfq_id must be drawn in a way that the derived tap_rfq_scid falls within the correct range for an SCID alias (16_000_000 <= block height < 16_250_000).

rfqmsg/messages_test.go Outdated Show resolved Hide resolved
rfqmsg/records.go Show resolved Hide resolved
tapchannel/aux_closer.go Outdated Show resolved Hide resolved
@guggero guggero force-pushed the update-to-lnd-18-4 branch from 32bff76 to 118d738 Compare October 17, 2024 14:47
@guggero guggero requested a review from ffranr October 17, 2024 14:48
@guggero guggero force-pushed the update-to-lnd-18-4 branch from 118d738 to fc1a430 Compare October 21, 2024 12:28
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 fc1a430

i think the htlc intercept itest might be flaky, kicked it

Is this PR going to get more commits as we move forward, or is this it's final-ish state?

@guggero guggero force-pushed the update-to-lnd-18-4 branch from fc1a430 to 1bbe907 Compare October 22, 2024 09:47
@guggero
Copy link
Member Author

guggero commented Oct 22, 2024

Is this PR going to get more commits as we move forward, or is this it's final-ish state?

There will be one more round of go.mod bumps across all projects once the final/tagged version of v0.18.4-beta is out. But this PR is now complete as is, as soon as the CI is fixed (which I will look into momentarily).

A recent change to the lnd SCID alias RPCs requires us to generate SCID
aliases in a certain range. Because we derive the alias from the
randomly generated RFQ ID, we need to make sure we derive a random ID
that can be successfully transformed into a valid SCID alias.
We now get custom_channel_data fields in the ListInvoices/LookupInvoice
as well as in the ListPayments RPC. We add those fields to our data
parser implementation.
This commit unifies the use of the lfn.Result return type as a
preparation for the final commit in this PR, where we change a bunch of
function/method signatures to use the Result type as well.

We use lnf.Err(fnt.Errorf()) instead of lnf.Errf because the
intellisense of some IDEs complain about the '%w' verb only being usable
with fmt.Errorf().
The lnd version we're going to use in the next commit requires a
slightly more up-to-date version of Golang.
With this commit we switch the testing branch to the currently unmerged
'update-to-lnd-18-4' branch which will soon be in master.
But because that branch depends on the commits in this PR, we first have
to point to it, get this PR merged, then merge update-to-lnd-18-4, then
change this to 'master'.
@guggero guggero force-pushed the update-to-lnd-18-4 branch from 1bbe907 to d74dd65 Compare October 22, 2024 10:44
Due to the new way we calculate asset rates, the rounding works slightly
differently. That's why we need to add a single milli-satoshi to the
total inbound margin.
@guggero
Copy link
Member Author

guggero commented Oct 22, 2024

I had to add 2 commits to address some of the RFQ changes (and to make the itests pass with the new way asset to BTC conversions now happen with more precision).
Re-requesting review from @ffranr with the ask to just take a look at the last two commits.

@guggero guggero requested a review from ffranr October 22, 2024 14:07
@guggero guggero merged commit 54f007d into main Oct 22, 2024
18 checks passed
@guggero guggero deleted the update-to-lnd-18-4 branch October 22, 2024 14:36
@guggero guggero restored the update-to-lnd-18-4 branch October 22, 2024 14:37
@guggero guggero deleted the update-to-lnd-18-4 branch October 22, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants