-
Notifications
You must be signed in to change notification settings - Fork 122
sweepbatcher: make sure feerate does not decrease #833
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
sweepbatcher: make sure feerate does not decrease #833
Conversation
hieblmi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice test.
sweepbatcher/sweep_batch.go
Outdated
| } | ||
|
|
||
| // Update batch's fee rate to be greater than or equal to | ||
| // minFeeRate of the sweep. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add the reason for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done:
// Update batch's fee rate to be greater than or equal to
// minFeeRate of the sweep. Make sure batch's fee rate does not
// decrease (otherwise it won't pass RBF rules and won't be
// broadcasted) and that it is not lower that minFeeRate of
// other sweeps (so it is applied).|
|
||
| batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, | ||
| testMuSig2SignSweep, testVerifySchnorrSig, lnd.ChainParams, | ||
| batcherStore, sweepStore, WithCustomFeeRate(customFeeRate)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: nl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
sweepbatcher/sweep_batcher_test.go
Outdated
| require.Len(t, batch.sweeps, 1) | ||
| require.Equal(t, feeRateMedium, batch.rbfCache.FeeRate) | ||
|
|
||
| // Now decreate the fee of sweep1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: decrease
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| setFeeRate(swapHash1, feeRateLow) | ||
| require.NoError(t, batcher.AddSweep(&sweepReq1)) | ||
|
|
||
| // Tick tock next block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| <-lnd.TxPublishChannel | ||
|
|
||
| // Make sure the fee rate is still feeRateMedium. | ||
| require.Equal(t, feeRateMedium, batch.rbfCache.FeeRate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
sweepbatcher/sweep_batcher_test.go
Outdated
| require.Len(t, batch.sweeps, 2) | ||
| require.Equal(t, feeRateMedium, batch.rbfCache.FeeRate) | ||
|
|
||
| // Now update fee rate of second sweep (which is not promary) to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: primary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Previous behaviour was to overwrite batch's feerate with minFeeRate of its primary sweep, which could be lower that previus batch's feerate or lower that feerate of some other sweep. Instead, batch's feerate only grows and never declines and is at least as high as the highest feerate of its sweeps. Added a test to verify this.
dabc74a to
864d7f2
Compare
bhandras
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
Previous behaviour was to overwrite batch's feerate with minFeeRate of its primary sweep, which could be lower that previus batch's feerate or lower that feerate of some other sweep.
Instead, batch's feerate only grows and never declines and is at least as high as the highest feerate of its sweeps.
Added a test to verify this.
Pull Request Checklist
release_notes.mdif your PR contains major features, breaking changes or bugfixes