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

coop close does not work with agreed fees (may be due to Taproot) #6953

Closed
BhaagBoseDK opened this issue Sep 28, 2022 · 11 comments · Fixed by #6957
Closed

coop close does not work with agreed fees (may be due to Taproot) #6953

BhaagBoseDK opened this issue Sep 28, 2022 · 11 comments · Fixed by #6957
Assignees
Labels
bug Unintended code behaviour channel closing Related to the closing of channels cooperatively and uncooperatively P1 MUST be fixed or reviewed
Milestone

Comments

@BhaagBoseDK
Copy link
Contributor

Background

A peer tried to coop close with my node. The negotiation ended with 183 fees but than broadcast transaction failed. The channel got stuck in closing with no txn in mempool. It had to be force closed later.

closing negotiation

2022-09-28 07:47:12.286 [INF] HSWC: ChannelLink(37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0): exited
2022-09-28 07:47:12.286 [INF] HSWC: ChannelLink(37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0): stopping
2022-09-28 07:47:12.287 [INF] HSWC: Removing channel link with ChannelID(c0376aea6113eb4070f0c94bf8162cfd367a552d8f78ec939926f3192269f237)
2022-09-28 07:47:12.300 [INF] PEER: Peer(032e65c456441da55db4c9b3ea863e60a154afc4bac2bdc96dbb25336779257b38): Delivery addr for channel close: bc1pxxxxxxxx -> taproot address
2022-09-28 07:47:12.313 [INF] CHCL: Ideal fee for closure of ChannelPoint(37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0) is: 183 sat
2022-09-28 07:47:12.313 [INF] NANN: Announcing channel(37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0) disabled [requested]
2022-09-28 07:47:12.336 [INF] CHCL: ChannelPoint(37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0): sending shutdown message
2022-09-28 07:47:12.336 [INF] CHCL: ChannelPoint(37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0): responding to shutdown
2022-09-28 07:47:12.720 [INF] CHCL: ChannelPoint(37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0): computing fee compromise, ideal=183, last_sent=0, remote_offer=183
2022-09-28 07:47:12.723 [INF] CHCL: ChannelPoint(37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0): proposing fee of 183 sat to close chan
2022-09-28 07:47:12.723 [INF] CHCL: ChannelPoint(37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0) fee of 0.00000183 BTC accepted, ending negotiation
2022-09-28 07:47:12.731 [INF] CHCL: Broadcasting cooperative close tx: (*wire.MsgTx)(0x4020869180)({
 Version: (int32) 2,
 TxIn: ([]*wire.TxIn) (len=1 cap=15) {
  (*wire.TxIn)(0x407d6954a0)({
   PreviousOutPoint: (wire.OutPoint) 37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0,
   SignatureScript: ([]uint8) <nil>,
   Witness: (wire.TxWitness) (len=4 cap=4) {
    ([]uint8) <nil>,
    ([]uint8) (len=71 cap=144) {
     00000000  30 44 02 20 1f 02 46 27  89 62 99 6b 68 df 36 c2  |0D. ..F'.b.kh.6.|

however failure to broadcast as expected fees was 193 (may be due to taproot)

2022-09-28 07:47:12.740 [ERR] LNWL: Notifying unmined tx notification (ad702fc910e166ca03f60c7f04cb69319eb5f22af144bed8b52a5b1c2401940a) while creating notification for blocks
2022-09-28 07:47:12.804 [INF] LNWL: Removed invalid transaction: (*wire.MsgTx)(0x4020869180)({
 Version: (int32) 2,
 TxIn: ([]*wire.TxIn) (len=1 cap=15) {
  (*wire.TxIn)(0x407d6954a0)({
   PreviousOutPoint: (wire.OutPoint) 37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0,
   SignatureScript: ([]uint8) <nil>,
   Witness: (wire.TxWitness) (len=4 cap=4) {
    ([]uint8) <nil>,
    ([]uint8) (len=71 cap=144) {
     00000000  30 44 02 20 1f 02 46 27  89 62 99 6b 68 df 36 c2  |0D. ..F'.b.kh.6.|
--
  })
 },
 LockTime: (uint32) 0
})

2022-09-28 07:47:12.806 [ERR] PEER: Peer(032e65c456441da55db4c9b3ea863e60a154afc4bac2bdc96dbb25336779257b38): unable to process close msg: unmatched backend error: -26: min relay fee not met, 184 < 193

Your environment

  • version of lnd
lncli getinfo
{
    "version": "0.15.1-beta commit=v0.15.1-beta",
    "commit_hash": "fd1a95bf322cdd1c743a1554f8e470fbf9a5e564",
    "identity_pubkey": "03c5528c628681aa17ab9e117aa3ee6f06c750dfb17df758ecabcd68f1567ad8c1",
    "alias": "⚡G-Spot-21_69_420⚡",


  • which operating system (uname -a on *Nix)
    Linux umbrel 5.10.17-v8+ #1421 SMP PREEMPT Thu May 27 14:01:37 BST 2021 aarch64 GNU/Linux
  • version of btcd, bitcoind, or other backend
umbrel@umbrel:~/umbrel/bin $ ./bitcoin-cli -getinfo
Chain: main
Blocks: 756058
Headers: 756058
Verification progress: 99.9999%
Difficulty: 31360548173144.85

Network: in 1, out 10, total 11
Version: 230000
Time offset (s): -1
Proxies: 10.21.21.11:9050 (ipv4, ipv6, onion, cjdns)
Min tx relay fee rate (BTC/kvB): 0.00001000
  • any other relevant environment details

Steps to reproduce

May be try coop closing channel with ECONOMICAL fees.

Expected behaviour

If minimum relay fees is 193 then 193 should have been proposed.

Actual behaviour

Channel did not close and had to be force closed later.

@Crypt-iQ
Copy link
Collaborator

Was this channel a static-remote-key channel without anchors? Do you happen to know the script your counterparty was using here - it doesn't say in the logs? I'm guessing CalcFee was used to set the idealFee based on the channel, which has a P2WPKH output. Then the P2WPKH script was replaced with a P2WSH or P2TR script during the coop flow, giving a higher weight at the same fee

@Crypt-iQ Crypt-iQ added bug Unintended code behaviour channel closing Related to the closing of channels cooperatively and uncooperatively labels Sep 28, 2022
@BhaagBoseDK
Copy link
Contributor Author

Was this channel a static-remote-key channel without anchors?

YES

Do you happen to know the script your counterparty was using here - it doesn't say in the logs? I'm guessing CalcFee was used to set the idealFee based on the channel, which has a P2WPKH output. Then the P2WPKH script was replaced with a P2WSH or P2TR script during the coop flow, giving a higher weight at the same fee

I have no idea about that but I have provided this gitub case to my peer and they can comment.

However, shouldn't my node propose a fee considering P2TR script during coop flow to nudge the negotiation higher? Why was my node also proposing 183?

@apogiffa
Copy link

Was this channel a static-remote-key channel without anchors? Do you happen to know the script your counterparty was using here - it doesn't say in the logs? I'm guessing CalcFee was used to set the idealFee based on the channel, which has a P2WPKH output. Then the P2WPKH script was replaced with a P2WSH or P2TR script during the coop flow, giving a higher weight at the same fee

I'm the peer who encountered these problems. In total I had 12/35 coop-closed channels with no closing_txid which I then had to force close.
If you tell me what command to paste into terminal I'll gladly provide the infos you want to know.

@Crypt-iQ
Copy link
Collaborator

@BhaagBoseDK you can look at the outputs in the invalid transaction that was removed to determine the type of the outputs (p2wsh, p2wkh, p2tr, etc)

@BhaagBoseDK
Copy link
Contributor Author

@BhaagBoseDK you can look at the outputs in the invalid transaction that was removed to determine the type of the outputs (p2wsh, p2wkh, p2tr, etc)

As I already mentioned, the "invalid" transaction had output as P2TR

This implies that fees are calculated on P2WSH while not realising that 0.15.0 onwards P2TR is also supported (and might require higher fees).

[INF] PEER: Peer(032e65c456441da55db4c9b3ea863e60a154afc4bac2bdc96dbb25336779257b38): Delivery addr for channel close: bc1pxxxxxxxx -> taproot address

@apogiffa
Copy link

Other plebs in the noderunners-TG-group also encountered "closing_txid": "" and mentioned that a simple restart of LND resulted in a successful renegotiation.
So that might help to avoid having to FC the channels.

@Crypt-iQ
Copy link
Collaborator

As I already mentioned, the "invalid" transaction had output as P2TR

Yes I understand, what about the other output?

@BhaagBoseDK
Copy link
Contributor Author

As I already mentioned, the "invalid" transaction had output as P2TR

Yes I understand, what about the other output?

how do I find it, the txn is not in mempool nor can I find the details from log. But most likely that was also P2TR because the peer is also on lnd 0.15.x

@Crypt-iQ
Copy link
Collaborator

It would be the un-truncated log here:

2022-09-28 07:47:12.804 [INF] LNWL: Removed invalid transaction: (*wire.MsgTx)(0x4020869180)({
 Version: (int32) 2,
 TxIn: ([]*wire.TxIn) (len=1 cap=15) {
  (*wire.TxIn)(0x407d6954a0)({
   PreviousOutPoint: (wire.OutPoint) 37f2692219f3269993ec788f2d557a36fd2c16f84bc9f07040eb1361ea6a37c0:0,
   SignatureScript: ([]uint8) <nil>,
   Witness: (wire.TxWitness) (len=4 cap=4) {
    ([]uint8) <nil>,
    ([]uint8) (len=71 cap=144) {
     00000000  30 44 02 20 1f 02 46 27  89 62 99 6b 68 df 36 c2  |0D. ..F'.b.kh.6.|
--
  })
 },
 LockTime: (uint32) 0
})

@saubyk saubyk added this to the v0.15.2 milestone Sep 30, 2022
@saubyk saubyk added the P1 MUST be fixed or reviewed label Oct 2, 2022
Roasbeef added a commit to Roasbeef/lnd that referenced this issue Oct 10, 2022
In this commit, we modify the way we compute the starting ideal fee for
the co-op close transaction. Before thsi commit, channel.CalcFee was
used, which'll compute the fee based on the commitment transaction
itself, rathern than the co-op close transaction. As the co-op close
transaction is potentailly bigger (two P2TR outputs) than the commitment
transaction, this can cause us to under estimate the fee, which can
result in the fee rate being too low to propagate.

To remedy this, we now compute a fee estimate from scratch, based on the
delivery fees of the two parties.

We also add a bug fix in the chancloser unit tests that wasn't caught
due to loop variable shadowing.

The wallet import itest has been updated as well, since we'll now pay
600 extra saothis to close the channel, since we're accounting for the
added weight of the P2TR outputs.

Fixes lightningnetwork#6953
Roasbeef added a commit to Roasbeef/lnd that referenced this issue Oct 11, 2022
In this commit, we modify the way we compute the starting ideal fee for
the co-op close transaction. Before thsi commit, channel.CalcFee was
used, which'll compute the fee based on the commitment transaction
itself, rathern than the co-op close transaction. As the co-op close
transaction is potentailly bigger (two P2TR outputs) than the commitment
transaction, this can cause us to under estimate the fee, which can
result in the fee rate being too low to propagate.

To remedy this, we now compute a fee estimate from scratch, based on the
delivery fees of the two parties.

We also add a bug fix in the chancloser unit tests that wasn't caught
due to loop variable shadowing.

The wallet import itest has been updated as well, since we'll now pay
600 extra saothis to close the channel, since we're accounting for the
added weight of the P2TR outputs.

Fixes lightningnetwork#6953
gkrizek pushed a commit to voltagecloud/lnd that referenced this issue Oct 14, 2022
In this commit, we modify the way we compute the starting ideal fee for
the co-op close transaction. Before thsi commit, channel.CalcFee was
used, which'll compute the fee based on the commitment transaction
itself, rathern than the co-op close transaction. As the co-op close
transaction is potentailly bigger (two P2TR outputs) than the commitment
transaction, this can cause us to under estimate the fee, which can
result in the fee rate being too low to propagate.

To remedy this, we now compute a fee estimate from scratch, based on the
delivery fees of the two parties.

We also add a bug fix in the chancloser unit tests that wasn't caught
due to loop variable shadowing.

The wallet import itest has been updated as well, since we'll now pay
600 extra saothis to close the channel, since we're accounting for the
added weight of the P2TR outputs.

Fixes lightningnetwork#6953
@bota87
Copy link
Contributor

bota87 commented Oct 18, 2022

I had this issue with 0.15.2, just updated to 0.15.3 to see if get fixed but I still see the same error, I have to force close or there is another way?

@Crypt-iQ
Copy link
Collaborator

the tx is persisted to the db and you won't be able to coop close that channel anymore, so you need to force close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unintended code behaviour channel closing Related to the closing of channels cooperatively and uncooperatively P1 MUST be fixed or reviewed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants