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

sweep: allow force sweeping of negatively yielding inputs #3809

Merged
merged 4 commits into from Jan 23, 2020

Conversation

@joostjager
Copy link
Collaborator

joostjager commented Dec 9, 2019

This PR adds force sweep functionality to the sweeper. Force sweep signals that an input needs to be swept even if its yield is negative. This is useful in CPFP scenarios where the parent tx output is only small. This will be common in the upcoming new anchor outputs commitment format.

The force flag is exposed on the BumpFee rpc call and through lncli. In many cases it will be required to have a wallet utxo available to bring the tx output above the dust limit. PR #3814 extended the sweeper with the capability to attach wallet utxos if needed.

@joostjager joostjager changed the title sweep: prepare for anchor sweeping sweep: prepare for anchor sweeping [don't review] Dec 9, 2019
@joostjager joostjager force-pushed the joostjager:anchor-sweeper branch 3 times, most recently from b82c3f7 to 3964624 Dec 9, 2019
@joostjager joostjager requested review from cfromknecht and Roasbeef as code owners Dec 9, 2019
@halseth halseth added the anchors label Dec 9, 2019
@joostjager joostjager force-pushed the joostjager:anchor-sweeper branch 2 times, most recently from 3136500 to 1319eff Dec 9, 2019
@joostjager joostjager removed request for Roasbeef and cfromknecht Dec 9, 2019
@joostjager joostjager force-pushed the joostjager:anchor-sweeper branch 7 times, most recently from 2bfce68 to d7a2265 Dec 12, 2019
@roeierez

This comment has been minimized.

Copy link
Contributor

roeierez commented Dec 24, 2019

@joostjager Will this PR solve the use case where channel was closed with small local balance?
Right now I have ~2000 sat that can't be swept due to fee rate.
in #3814 there is an attempt to use additional input but I don't have any in my wallet.

@joostjager joostjager force-pushed the joostjager:anchor-sweeper branch 2 times, most recently from 339d292 to 0178cea Jan 7, 2020
@joostjager

This comment has been minimized.

Copy link
Collaborator Author

joostjager commented Jan 9, 2020

With an input of that size, the idea is to modify the sweep fee rate to a lower value using the bumpfee rpc, so that it becomes economical to sweep. Without a wallet utxo, it still needs to produce a tx that has an output above the dust limit.

Note that the sweeper uses fee rate buckets to batch inputs together. The first bucket is 1-10 sat/byte. The actual sweep fee rate is the average of all inputs in a bucket. If your input is the only input in the 1-10 bucket and you've lowered the input fee rate preference to 1 sat/b, it should be swept at that rate.

This PR is not adding anything to that. It mainly allows negatively yielding inputs to be swept using the force flag, but for that you also need a wallet utxo.

@joostjager joostjager force-pushed the joostjager:anchor-sweeper branch 3 times, most recently from ffed1e5 to 0a31880 Jan 9, 2020
…eeps

Previously only the fee rate used for the last sweep (the sweep bucket
average) was reported. This commit adds the request fee preference to
the report, which is used to select a bucket and the sweep tx fee rate.
@joostjager joostjager force-pushed the joostjager:anchor-sweeper branch 2 times, most recently from 7cb17d1 to b114491 Jan 9, 2020
@joostjager joostjager changed the title sweep: prepare for anchor sweeping [don't review] sweep: allow force sweeping of negatively yielding inputs Jan 9, 2020
@joostjager joostjager requested review from wpaulino and halseth Jan 9, 2020
@joostjager joostjager removed the incomplete label Jan 9, 2020
@joostjager joostjager force-pushed the joostjager:anchor-sweeper branch from b114491 to f4af657 Jan 9, 2020
@joostjager

This comment has been minimized.

Copy link
Collaborator Author

joostjager commented Jan 9, 2020

Note to self: @cfromknecht suggested to require regular inputs to not just be positively yielding, but yield at least 2/3 (for example) of their value

@joostjager joostjager force-pushed the joostjager:anchor-sweeper branch from f4af657 to 99be3a2 Jan 10, 2020
@joostjager

This comment has been minimized.

Copy link
Collaborator Author

joostjager commented Jan 10, 2020

Checked what is needed for that minimum yield requirement. The sweeper change is small, but there are quite a few changes in the test (setup) required. Leaving that change for a separate pr.

Copy link
Collaborator

wpaulino left a comment

Nice small change! Will give it another pass, but LGTM so far.

lnrpc/walletrpc/walletkit.proto Show resolved Hide resolved
cmd/lncli/walletrpc_active.go Outdated Show resolved Hide resolved
sweep/sweeper.go Outdated Show resolved Hide resolved
sweep/sweeper.go Show resolved Hide resolved
@joostjager joostjager force-pushed the joostjager:anchor-sweeper branch from 99be3a2 to 79ebcb8 Jan 13, 2020
@joostjager

This comment has been minimized.

Copy link
Collaborator Author

joostjager commented Jan 13, 2020

Comments processed, ready for another pass

@joostjager joostjager requested a review from wpaulino Jan 13, 2020
@Roasbeef Roasbeef added this to the 0.10.0 milestone Jan 14, 2020
@Roasbeef Roasbeef added the v0.10 label Jan 14, 2020
sweep/sweeper.go Outdated Show resolved Hide resolved
@Roasbeef Roasbeef modified the milestones: 0.10.0, 0.9.0 Jan 14, 2020
Copy link
Collaborator

halseth left a comment

Nice PR :)

sweep/sweeper.go Outdated Show resolved Hide resolved
}
// Initialize new wallet total with the current wallet total. This is
// updated below if this input is a wallet input.
newWalletTotal := t.walletInputTotal

This comment has been minimized.

Copy link
@halseth

halseth Jan 15, 2020

Collaborator

seems like the handling of this field can stay inside the switch case

This comment has been minimized.

Copy link
@joostjager

joostjager Jan 15, 2020

Author Collaborator

I moved it outside, because otherwise you have to be very careful not to update t.walletInputTotal before you do any additional checks. In that case, the total would be updated without the add happening.

@@ -142,24 +151,14 @@ func bumpFee(ctx *cli.Context) error {
return err
}

var confTarget, satPerByte uint32

This comment has been minimized.

Copy link
@halseth

halseth Jan 15, 2020

Collaborator

why remove this validation?

This comment has been minimized.

Copy link
@joostjager

joostjager Jan 15, 2020

Author Collaborator

The server already validates this, so this is just unnecessary maintenance. Change was suggested by @wpaulino and I liked it.

sweep/tx_input_set.go Show resolved Hide resolved
joostjager added 3 commits Jan 9, 2020
This is a preparation for adding additional parameters besides the fee
preference.
This refactor prepares for the addition of specific constraints for
force sweep inputs.
@joostjager joostjager force-pushed the joostjager:anchor-sweeper branch from 79ebcb8 to b0aae13 Jan 15, 2020
@joostjager

This comment has been minimized.

Copy link
Collaborator Author

joostjager commented Jan 15, 2020

Holding off merge until 0.9 final is cut.

@Roasbeef Roasbeef added this to In progress in v0.10.0-beta via automation Jan 17, 2020
@Roasbeef Roasbeef moved this from In Progress to Merge Queue in v0.10.0-beta Jan 17, 2020
@joostjager joostjager merged commit ae9c6fa into lightningnetwork:master Jan 23, 2020
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.06%) to 62.993%
Details
v0.10.0-beta automation moved this from Merge Queue to Done Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
v0.10.0-beta
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.