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

[bug]: sweeper (bumpfee) creates invalid transaction (not paying higher fees when necessary) #7972

Closed
C-Otto opened this issue Sep 10, 2023 · 7 comments · Fixed by #8091
Closed
Labels
bug Unintended code behaviour P2 should be fixed if one has time utxo sweeping

Comments

@C-Otto
Copy link
Contributor

C-Otto commented Sep 10, 2023

Background

The sweeper creates a combined sweep transaction, using another pending sweep transaction's input as an input, without raising the fee rate. The resulting combined transaction cannot be broadcast because of that.

Your environment

  • version of lnd: 0.16.4
  • which operating system (uname -a on *Nix): Linux server 6.1.0-11-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-4 (2023-08-08) x86_64 GNU/Linux
  • version of btcd, bitcoind, or other backend: bitcoind v25

Steps to reproduce

Run bumpfee for input A and 15 sat/vByte, resulting in a sweep transaction paying 15 sat/vByte.
Wait for the sweep transaction to broadcast.
Run bumpfee for input B and 15 sat/vByte before the sweep for input A is confirmed.

Expected behaviour

Input A is not used as an input for the sweep transaction for input B.

Actual behaviour

It is used, resulting in an error:

2023-09-10 11:59:22.323 [INF] SWPR: Creating sweep transaction xxx for 2 inputs (xxx:0 (CommitmentAnchor), xxx:0 (CommitmentAnchor)) using 253 sat/kw, tx_weight=774, tx_fee=0.00000195 BTC, parents_count=0, parents_fee=0 BTC, parents_weight=0
2023-09-10 11:59:22.333 [ERR] BTCN: Broadcast attempt failed: -26: insufficient fee, rejecting replacement xxx; new feerate 0.00001010 BTC/kvB <= old feerate 0.00004508 BTC/kvB
2023-09-10 11:59:22.337 [INF] LNWL: Inserting unconfirmed transaction xxx
2023-09-10 11:59:22.345 [INF] LNWL: xxx: broadcast failed because of: unable to replace transaction: -26: insufficient fee, rejecting replacement xxx; new feerate 0.00001010 BTC/kvB <= old feerate 0.00004508 BTC/kvB
2023-09-10 11:59:22.353 [ERR] SWPR: Publish sweep tx xxx got error: transaction rejected: output already spent
@C-Otto C-Otto added bug Unintended code behaviour needs triage labels Sep 10, 2023
@C-Otto C-Otto changed the title [bug]: sweeper (bumpfee) creates invalid transaction [bug]: sweeper (bumpfee) creates invalid transaction (not paying higher fees when necessary) Sep 10, 2023
@yyforyongyu
Copy link
Member

Looks like it's the issue mentioned here.

Do you also see the sweeping transaction for input B only being created?

@C-Otto
Copy link
Contributor Author

C-Otto commented Sep 11, 2023

I don't understand the question. I posted the logs, what exactly are you looking for?

@yyforyongyu
Copy link
Member

Something like [INF] SWPR: Creating sweep transaction xxx for 1 inputs.... So I was wondering if there were two sweeping transactions being created - the first was the one shown above, and a second one which only contained input B.

@C-Otto
Copy link
Contributor Author

C-Otto commented Sep 11, 2023

Please have another look at my issue. The first transaction is unproblematic and ends up in the mempool. The second transaction is the one for which I showed the logs, including the resulting error. I still don't understand what kind of information is missing.

@C-Otto
Copy link
Contributor Author

C-Otto commented Sep 11, 2023

Ah. I think I understand what you're asking for, let me have a look.

@C-Otto
Copy link
Contributor Author

C-Otto commented Sep 11, 2023

For the problematic sweep transactions I also see various other sweep transactions making use of other inputs, yes. If "x and y" as inputs result in an error, "x and z" is attempted a bit later.

@saubyk saubyk added utxo sweeping P2 should be fixed if one has time and removed needs triage labels Sep 13, 2023
@yyforyongyu
Copy link
Member

So I think what's happening here is that we always create two input sets here. Each of the input sets is used to create a sweeping transaction. This means,

  1. when seeing input A, we'd create and publish a sweeping transaction using it.
  2. before the above tx is confirmed, input B is received by the sweeper.
  3. the sweeper will then create two transactions, tx1 has input B, tx2 has input A and input B.
  4. tx2 is most likely to fail because of the RBF constraints.

The solution is,

  1. stop creating transactions using the same input.
  2. start tracking individual input's state to precisely control whether to sweep it or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unintended code behaviour P2 should be fixed if one has time utxo sweeping
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants