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

LND PeerSwap fee estimation seems broken with Bitcoin Core v27.0rc1 #289

Closed
grubles opened this issue Mar 17, 2024 · 5 comments
Closed

LND PeerSwap fee estimation seems broken with Bitcoin Core v27.0rc1 #289

grubles opened this issue Mar 17, 2024 · 5 comments
Labels

Comments

@grubles
Copy link
Collaborator

grubles commented Mar 17, 2024

LND as swap-out receiver apparently seems to think the fee rate is >= 1BTC/kvB and cancels the swap. LND as swap-in receiver seems unable to claim onchain signet coins for the same reason.

Fedora 39 ARM64
LND 0.17.4-beta
PeerSwap @ fb7d5f7
Bitcoin Core v27.0rc1
Go 1.21.8

peerswapd logs:

2024/03/16 23:47:22 [DEBUG] [FSM] event:id: a71942d629ee5ce4898f709150b05a37d7acb791ae965487217990d48ca94cd6, Event_OnSwapOutRequestReceived on 
2024/03/16 23:47:22 [INFO] Estimated fee rate is below floor of 275 sat/kw, take floor instead
2024/03/16 23:47:22 [DEBUG] Using a fee rate of 1.10 sat/vb for a total fee of 385
2024/03/16 23:47:26 [DEBUG] [FSM] event:id: a71942d629ee5ce4898f709150b05a37d7acb791ae965487217990d48ca94cd6, Event_ActionSucceeded on State_SwapOutReceiver_CreateSwap
2024/03/16 23:47:26 [INFO] [Swap:a71942d629ee5ce4898f709150b05a37d7acb791ae965487217990d48ca94cd6] swap-out request received: peer: 036e680823a129ac9a2eeb8c43514a5b6cb09ae28e3e698a0e34aaa8865d6cc344 chanId: 182807x4x0 initiator: 036e680823a129ac9a2eeb8c43514a5b6cb09ae28e3e698a0e34aaa8865d6cc344 amount 200000000
2024/03/16 23:47:26 [DEBUG] [FSM] event:id: a71942d629ee5ce4898f709150b05a37d7acb791ae965487217990d48ca94cd6, Event_ActionSucceeded on State_SwapOutReceiver_SendFeeInvoice
2024/03/16 23:47:26 [DEBUG] [PaymentWatcher] Swap: a71942d629ee5ce4898f709150b05a37d7acb791ae965487217990d48ca94cd6: Add new payment watcher for payreq lntbs3850n1pjlvtuwpp5ds3nsvdakndztm56dlh22km79jxfvej273ag230agr79p7lx4tvqdy5wpjk2unnwashqgrzw33jqen9v5srzwpj8qcrw7p50qczqcfhxyungvnyxcerjet9x43k2dpc8yuxvdes8ycn2vrzxq6kzvehvsmkzcmzxuunzct98ymr2dpcxuerzdee8ycxgdpcvdsnjdrrvsmqcqzzsxqzjcsp5axg9rhmjznmkjqeu3xtr9x8tqsuk96qhscdvjkk7vc4ss40l7fss9qyyssqxagewxhzkyfyj2u48gxvs8qexv6ukyrfrecnsl24rz2wtdnkrgeyznhynaskuknw2azt6wr9cut3ds3wn7j7rs8g2ha6qkskcu6jkasp2pd3fv of type "fee"
2024/03/16 23:47:28 [DEBUG] [PaymentWatcher] Swap: a71942d629ee5ce4898f709150b05a37d7acb791ae965487217990d48ca94cd6: Calling paymentCallback
2024/03/16 23:47:28 [DEBUG] [FSM] event:id: a71942d629ee5ce4898f709150b05a37d7acb791ae965487217990d48ca94cd6, Event_OnFeeInvoicePaid on State_SwapOutReceiver_AwaitFeeInvoicePayment
2024/03/16 23:47:28 [DEBUG] [grpc_conn]: grpc_retry attempt: 0, got err: rpc error: code = Unknown desc = unmatched backend error: -8: Fee rates larger than or equal to 1BTC/kvB are not accepted
2024/03/16 23:47:28 [INFO] [FSM] Action failure rpc error: code = Unknown desc = unmatched backend error: -8: Fee rates larger than or equal to 1BTC/kvB are not accepted
2024/03/16 23:47:28 [DEBUG] [FSM] event:id: a71942d629ee5ce4898f709150b05a37d7acb791ae965487217990d48ca94cd6, Event_ActionFailed on State_SwapOutReceiver_BroadcastOpeningTx
2024/03/16 23:47:28 [DEBUG] [FSM] Canceling because of rpc error: code = Unknown desc = unmatched backend error: -8: Fee rates larger than or equal to 1BTC/kvB are not accepted
2024/03/16 23:47:28 [DEBUG] [FSM] event:id: a71942d629ee5ce4898f709150b05a37d7acb791ae965487217990d48ca94cd6, Event_ActionSucceeded on State_SendCancel
2024/03/16 23:47:28 [INFO] [Swap:a71942d629ee5ce4898f709150b05a37d7acb791ae965487217990d48ca94cd6] Swap canceled. Reason: rpc error: code = Unknown desc = unmatched backend error: -8: Fee rates larger than or equal to 1BTC/kvB are not accepted

@grubles
Copy link
Collaborator Author

grubles commented Mar 17, 2024

peerswapd logs with LND as swap-in receiver:

2024/03/17 13:07:38 [INFO] [TxWatcher] Wait for confirmation on swap b131d7c5a788822268ad07c5148a13e637282bc788d41b4455e165e09ab32012: Got 3 confirmations call callback                                                                                                                
2024/03/17 13:07:38 [DEBUG] [FSM] event:id: b131d7c5a788822268ad07c5148a13e637282bc788d41b4455e165e09ab32012, Event_OnTxConfirmed on State_SwapInReceiver_AwaitTxConfirmation                                                                                                           
2024/03/17 13:07:45 [DEBUG] [Messenger] From: 036e680823a129ac9a2eeb8c43514a5b6cb09ae28e3e698a0e34aaa8865d6cc344 got same message for swap: b131d7c5a788822268ad07c5148a13e637282bc788d41b4455e165e09ab32012                                                                            
2024/03/17 13:07:48 [DEBUG] PayInvoiceViaChannel: payment still in flight                                                                   
2024/03/17 13:07:49 [DEBUG] PayInvoiceViaChannel: payment still in flight                                                                   
2024/03/17 13:07:50 [DEBUG] [FSM] event:id: b131d7c5a788822268ad07c5148a13e637282bc788d41b4455e165e09ab32012, Event_ActionSucceeded on State_SwapInReceiver_ValidateTxAndPayClaimInvoice                                                                                                
2024/03/17 13:07:50 [INFO] Estimated fee rate is below floor of 275 sat/kw, take floor instead                                              2024/03/17 13:07:50 [DEBUG] Using a fee rate of 1.10 sat/vb for a total fee of 171                                                          
2024/03/17 13:07:50 [DEBUG] [grpc_conn]: grpc_retry attempt: 0, got err: rpc error: code = Unknown desc = unmatched backend error: -8: Fee rates larger than or equal to 1BTC/kvB are not accepted                                                                                      
2024/03/17 13:07:50 [INFO] Error claiming tx with preimage rpc error: code = Unknown desc = unmatched backend error: -8: Fee rates larger th
an or equal to 1BTC/kvB are not accepted                                                                                                    
2024/03/17 13:07:50 [DEBUG] [FSM] event:id: b131d7c5a788822268ad07c5148a13e637282bc788d41b4455e165e09ab32012, Event_OnRetry on State_SwapInReceiver_ClaimSwap                                                                                                                           
2024/03/17 13:07:50 [INFO] Estimated fee rate is below floor of 275 sat/kw, take floor instead                                              2024/03/17 13:07:50 [DEBUG] Using a fee rate of 1.10 sat/vb for a total fee of 171                                                          
2024/03/17 13:07:50 [DEBUG] [grpc_conn]: grpc_retry attempt: 0, got err: rpc error: code = Unknown desc = unmatched backend error: -8: Fee r
ates larger than or equal to 1BTC/kvB are not accepted                                                                                      
2024/03/17 13:07:50 [INFO] Error claiming tx with preimage rpc error: code = Unknown desc = unmatched backend error: -8: Fee rates larger th
an or equal to 1BTC/kvB are not accepted
2024/03/17 13:07:50 [DEBUG] [FSM] event:id: b131d7c5a788822268ad07c5148a13e637282bc788d41b4455e165e09ab32012, Event_OnRetry on State_SwapInR
eceiver_ClaimSwap
2024/03/17 13:07:50 [INFO] Estimated fee rate is below floor of 275 sat/kw, take floor instead
2024/03/17 13:07:50 [DEBUG] Using a fee rate of 1.10 sat/vb for a total fee of 171
2024/03/17 13:07:50 [DEBUG] [grpc_conn]: grpc_retry attempt: 0, got err: rpc error: code = Unknown desc = unmatched backend error: -8: Fee r
ates larger than or equal to 1BTC/kvB are not accepted
2024/03/17 13:07:50 [INFO] Error claiming tx with preimage rpc error: code = Unknown desc = unmatched backend error: -8: Fee rates larger th
an or equal to 1BTC/kvB are not accepted
2024/03/17 13:07:50 [DEBUG] [FSM] event:id: b131d7c5a788822268ad07c5148a13e637282bc788d41b4455e165e09ab32012, Event_OnRetry on State_SwapInR
eceiver_ClaimSwap

@grubles
Copy link
Collaborator Author

grubles commented Mar 19, 2024

Something strange is happening with LND + Core v27. The swap is canceled due to the abnormally high fee rate, but somehow the transaction was broadcasted and ended up being confirmed in a block? And checking the tx on an explorer, the feerate appears normal.

2024-03-19 15:20:31.321 [INF] LNWL: a536eb55ccf685466baf6d2bc9bbc10ec260d69e3d5245133157fa578d2f0745: broadcast failed because of: unmatched
 backend error: -8: Fee rates larger than or equal to 1BTC/kvB are not accepted                                                             
2024-03-19 15:20:31.325 [INF] LNWL: Removed invalid transaction: a536eb55ccf685466baf6d2bc9bbc10ec260d69e3d5245133157fa578d2f0745 
2024-03-19 15:21:16.909 [INF] LNWL: Marking unconfirmed transaction a536eb55ccf685466baf6d2bc9bbc10ec260d69e3d5245133157fa578d2f0745 mined in block 187469
   {
      "id":  "e6dd6ef1346f08c31cd29f4cd4ce6ba82a7a61dc22d905ddcf20ed8545482b7f",
      "created_at":  "1710875843",
      "asset":  "btc",
      "type":  "swap-out",
      "role":  "receiver",
      "state":  "State_SwapCanceled",
      "initiator_node_id":  "036e680823a129ac9a2eeb8c43514a5b6cb09ae28e3e698a0e34aaa8865d6cc344",
      "peer_node_id":  "036e680823a129ac9a2eeb8c43514a5b6cb09ae28e3e698a0e34aaa8865d6cc344",
      "amount":  "100000000",
      "channel_id":  "182807x4x0",
      "opening_tx_id":  "",
      "claim_tx_id":  "",
      "cancel_message":  "rpc error: code = Unknown desc = unmatched backend error: -8: Fee rates larger than or equal to 1BTC/kvB are not accepted",
      "lnd_chan_id":  "200998422139109376"
    }

@YusukeShimizu
Copy link
Contributor

YusukeShimizu commented Mar 20, 2024

It may be an existing bug in LND found due to changes in bitcoin core.
I will investigate more and try to confirm.

Possible cause

In lnd, maxfeerate is set to 1e8 / 10(sat/kb) as a parameter when calling SendRawTransaction.
But BTC/kvB is the expected value, so the units would be wrong.

Reason for error in v27.0

bitcoin/bitcoin#29434 adds a sanity check for maxfeerate and does not accept values above 1BTC/kvB.
The error message in that case is

Fee rates larger than or equal to 1BTC/kvB are not accepted

@maflcko
Copy link

maflcko commented Apr 19, 2024

I presume this was fixed in btcsuite/btcd#2142 upstream?

@YusukeShimizu
Copy link
Contributor

It appears so.

@grubles grubles closed this as completed Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants