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

More custom channel bugfixes #939

Merged
merged 10 commits into from
Jun 9, 2024
Merged

More custom channel bugfixes #939

merged 10 commits into from
Jun 9, 2024

Conversation

guggero
Copy link
Member

@guggero guggero commented Jun 8, 2024

Fixes the following issues found during testing:

  • Allow a push amount to be set in the RPC and CLI to improve bi-directional sending UX in regtest
  • Make sure we set the minimum possible channel reserve when opening the channel
  • Make sure the FundChannel RPC cannot be called when tapd is running in standalone mode (not integrated into litd)
  • Fix bug that caused channel funding to fail if we spent the full amount in the channel funding (and the input being spent was the split root output of a previous send)
  • Add proof courier delivery address to the shutdown messages and allocations, so individual proofs are uploaded to correct universes
  • Make sure the party that isn't the initiator of the channel shutdown correctly fetches their co-op close output proof

GeorgeTsagk and others added 9 commits June 8, 2024 15:35
To avoid calling any channel functionality when tapd is running in
standalone mode (not integrated into litd), we add a new flag that can
be set by litd.
This commit mainly fixes a bug that when we copy an asset to create a
new output, we didn't empty out the split commitment when we spent an
output of a previous split in a full-value send output.
This lead to a validation error in the VM. We also add some more context
to the error that we were previously running into with this.
And just because we can, we fix a package shadowing issue.
In order for us to send the proofs to the correct proof courier address,
we need to be able to specify different delivery addresses for each
allocation.
We want to be able to tell the initiator of the shutdown what proof
delivery address we use, so we can fetch the proof of the co-op close
correctly (only the initiator of the shutdown will create an asset
transfer and hand it to the freighter, so if we're on the other side,
we'll need to fetch the proof instead).
If we're not the initiator of the shutdown process, we won't be called
back from lnd after the channel closing TX confirmed. So in order for us
to pick up on the transfer and download the proof from the courier, we
need to add our expected output as a TAP address, so the custodian will
detect the confirmed output on chain.

This is not optimal, as it will not work if there are multiple assets in
that close output. But since we'll need to add a whole new callback in
lnd that invokes a method in the aux closer after the channel confirmed,
we solve it this way instead for now. Because the whole funding logic
isn't ready to add multiple assets to a channel anyway.
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.

LGTM 🐜

const (
// CustomChannelRemoteReserve is the custom channel minimum remote
// reserve that we'll use for our channels.
CustomChannelRemoteReserve = 1062
Copy link
Member

Choose a reason for hiding this comment

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

Oddly precise number?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, not sure where exactly this is coming from. Took over the commit from #934, @GeorgeTsagk did some calculations to arrive at it.
Probably the 1% of our 100k default channel size plus some dust margin?

config.go Show resolved Hide resolved
@@ -447,6 +453,7 @@ func DistributeCoins(inputs []*proof.Proof, allocations []*Allocation,
AnchorOutputInternalKey: a.InternalKey,
AnchorOutputTapscriptSibling: sibling,
ScriptKey: a.ScriptKey,
ProofDeliveryAddress: deliveryAddr,
Copy link
Member

Choose a reason for hiding this comment

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

In order for us to send the proofs to the correct proof courier address,
we need to be able to specify different delivery addresses for each
allocation.

In the future, or today?

Copy link
Member Author

Choose a reason for hiding this comment

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

Today. Otherwise if the initiator of the shutdown process uses the non-default proof courier address, the respondent wouldn't ever learn that and wouldn't know where to download the proof from.

AssetVersion: asset.V0,
BtcAmount: tapsend.DummyAmtSats,
SortTaprootKeyBytes: sortKeyBytes,
ProofDeliveryAddress: proofDeliveryUrl,
Copy link
Member

Choose a reason for hiding this comment

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

Ah existing tests assumed that they were all using the same courier.

Copy link
Member Author

Choose a reason for hiding this comment

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

Before this commit the respondent to the shutdown process didn't actually know what proof courier the final proof would be uploaded to. Now the desired delivery address is sent along with the internal and script key, so the non-shutdown-initiator will know where to look for the proof.

The allocation code incorrectly assumed that if there was no asset
balance on one side, there also wouldn't be a BTC balance. With that
incorrect assumptions, no commitment or anchor allocations were added if
there for example was a BTC push amount added in the channel opening
transaction.
@guggero
Copy link
Member Author

guggero commented Jun 9, 2024

Added one more bugfix, kudos to @jamaljsr for the amazing testing.

Commit message reads:

tapchannel: account for BTC only balances

The allocation code incorrectly assumed that if there was no asset
balance on one side, there also wouldn't be a BTC balance. With that
incorrect assumptions, no commitment or anchor allocations were added if
there for example was a BTC push amount added in the channel opening
transaction.

@guggero guggero merged commit 2b3c60a into main Jun 9, 2024
14 checks passed
@guggero guggero deleted the even-more-bugfixes branch June 9, 2024 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[enhancement]: Channel-state machine initiation stalls due to channel-reserve requirement
4 participants