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]: sweep: BumpFee can cause transaction conflicts #8737

Open
morehouse opened this issue May 7, 2024 · 1 comment
Open

[bug]: sweep: BumpFee can cause transaction conflicts #8737

morehouse opened this issue May 7, 2024 · 1 comment
Labels
bug Unintended code behaviour P2 should be fixed if one has time utxo sweeping

Comments

@morehouse
Copy link
Collaborator

morehouse commented May 7, 2024

UtxoSweeper.UpdateParams updates the parameters for a specified input and resets its state to Init, after which the sweeper can create a new transaction for the input. But UpdateParams does not cancel any existing fee bumps for the input.

Thus, we can end up with the fee bumper creating multiple conflicting transactions each block. The fee bumper will not notice the conflicting transactions until one of them confirms, at which point any unspent inputs are allowed to be batched again.

These rebatched inputs will not be swept for at least 1 block after the conflicting transaction confirms, potentially causing deadlines to be missed in some edge cases.

Example edge case

  1. Inputs A, B, C all have a deadline in 6 blocks and are batched into a single transaction Tx1.
  2. After 4 blocks, Tx1 still hasn't confirmed. The user increases the budget for input A using BumpFee. The sweeper creates a new transaction Tx2 containing only input A.
  3. In the 5th block, Tx2 confirms. Inputs B and C are rebatched into a new transaction Tx3.

Tx3 now cannot confirm before the deadline.

Solution

UpdateParams should probably cancel any existing fee bump for the specified input. This would allow immediate rebatching of inputs in the original transaction using the updated parameters.

@yyforyongyu
Copy link
Collaborator

There's a related issue #8736, that we think when bumping the fees of a given input, if it's already in a set, we would instead bump the whole set to avoid fee bumping races. In addition, there's a TODO in #8680 which aids this new behavior,

update PendingSweeps to return inputs in InputSet, which gives users more info about the sweeping tx, so better decisions can be made when calling BumpFee.

@saubyk saubyk added P2 should be fixed if one has time and removed needs triage labels May 27, 2024
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

No branches or pull requests

3 participants