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]: Fix bandwidth manager and other bugs #1236

Merged
merged 5 commits into from
Dec 9, 2024

Conversation

guggero
Copy link
Member

@guggero guggero commented Dec 4, 2024

Depends on lightningnetwork/lnd#9333.

Fixes the issue that would lead to a force close if the channel bandwidth of a target channel during a forward event isn't sufficient.

Also fixes #1234 (drive-by fix) and another edge case found during integration tests.

@coveralls
Copy link

coveralls commented Dec 4, 2024

Pull Request Test Coverage Report for Build 12233514979

Details

  • 0 of 52 (0.0%) changed or added relevant lines in 3 files are covered.
  • 36 unchanged lines in 8 files lost coverage.
  • Overall coverage decreased (-0.03%) to 40.684%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rpcserver.go 0 9 0.0%
tapchannel/aux_traffic_shaper.go 0 16 0.0%
tapchannel/commitment.go 0 27 0.0%
Files with Coverage Reduction New Missed Lines %
rpcserver.go 1 0.0%
tapgarden/planter.go 2 74.12%
tapchannel/aux_leaf_signer.go 3 43.43%
asset/mock.go 3 91.71%
tapdb/universe.go 4 80.91%
tapgarden/caretaker.go 4 68.5%
asset/asset.go 4 81.09%
universe/interface.go 15 50.65%
Totals Coverage Status
Change from base Build 12231190207: -0.03%
Covered Lines: 25804
Relevant Lines: 63425

💛 - Coveralls

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! 🐐

feePerKw = view.FeePerKw
// When determining whether we need an anchor output, we need to
// count the non-asset HTLCs as well.
numHTLCs = uint64(len(nonAssetView.OurUpdates) +
Copy link
Member

Choose a reason for hiding this comment

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

would this lead to stuck force-closes? (covered in the LitD itest?)

trying to understand if we ever had coverage for 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.

No, the channel will not force close (at least from my observations), but the HTLC will be rejected. This is covered in the new litd itest, where we pay sats over an asset channel.

Copy link
Member

Choose a reason for hiding this comment

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

Won't this result in us over counting? The non asset view will still have an manifest HTLC for a given asset HTLC. I think it's enough to just have this combined sum here, and drop the numHTLCs increment in the inner loop.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the non-asset view and the asset view are fully distinct. And even if we were over counting, we only use numHTLCs > 0 as a condition for determining whether we need a commitment anchor output.

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 thought about this again and my initial approach wasn't 100% correct. It is correct that the assetView and
nonAssetView are non-overlapping. But we need to replicate this behavior:
https://github.com/lightningnetwork/lnd/blob/ab7aae07085ec244f7888e990e8d8cc6ae6dfa83/lnwallet/commitment.go#L706

So we also need to check for dust, which I now added.

@GeorgeTsagk
Copy link
Member

GeorgeTsagk commented Dec 5, 2024

when we do "breaking version bumps" I wonder how can we get the Lit Tests to run correctly and show 🟢 instead of compilation errors

Could maybe pin the LitD commit that we want to use to run the itests, then CI would use that

@guggero
Copy link
Member Author

guggero commented Dec 5, 2024

when we do "breaking version bumps" I wonder how can we get the Lit Tests to run correctly and show 🟢 instead of compilation errors

Could maybe pin the LitD commit that we want to use to run the itests, then CI would use that

Yeah, it's not optimal. We could point the litd itest to an unmerged commit, but IMO that's also not great, since we need to merge tapd first, then update litd which leads to a new commit...

So I think the best strategy is just to always follow up a tapd change that doesn't pass the LiT itests with a PR that shows it will eventually pass.

feePerKw = view.FeePerKw
// When determining whether we need an anchor output, we need to
// count the non-asset HTLCs as well.
numHTLCs = uint64(len(nonAssetView.OurUpdates) +
Copy link
Member

Choose a reason for hiding this comment

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

Won't this result in us over counting? The non asset view will still have an manifest HTLC for a given asset HTLC. I think it's enough to just have this combined sum here, and drop the numHTLCs increment in the inner loop.

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 pt.2 🌟

tapchannel/commitment.go Show resolved Hide resolved
This commit fixes an issue where we wouldn't count non-asset HTLCs when
deciding whether the commitment transaction would require a commitment
anchor output for the remote party, so the number of allocations would
be out of sync with the number of outputs on the commitment transaction.
Because the traffic shaper is now also used for checking the bandwidth
when forwarding HTLCs to the final recipient, we also need to check our
local buy quotes for a quote with the given RFQ ID.
Fixes #1234.

Simplifies and unifies the marshaling of sell quotes and adds the asset
amount by converting the request's max amount using the quote.
@guggero guggero force-pushed the bandwidth-manager-switch branch from 3c019a4 to 2ed2772 Compare December 9, 2024 10:17
@ffranr ffranr enabled auto-merge December 9, 2024 17:22
@guggero guggero disabled auto-merge December 9, 2024 17:55
@guggero guggero merged commit fde6732 into main Dec 9, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[bug]: asset_amount not showing up in SendPayment response
6 participants