Skip to content

Conversation

@starius
Copy link
Collaborator

@starius starius commented Oct 15, 2024

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

  • Update release_notes.md if your PR contains major features, breaking changes or bugfixes

@starius starius marked this pull request as ready for review October 15, 2024 13:54
Copy link
Collaborator

@hieblmi hieblmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice test.

}

// Update batch's fee rate to be greater than or equal to
// minFeeRate of the sweep.
Copy link
Collaborator

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?

Copy link
Collaborator Author

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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: nl

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

require.Len(t, batch.sweeps, 1)
require.Equal(t, feeRateMedium, batch.rbfCache.FeeRate)

// Now decreate the fee of sweep1.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: decrease

Copy link
Collaborator Author

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.
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: primary

Copy link
Collaborator Author

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.
@starius starius force-pushed the sweepbatcher-feerate-grows branch from dabc74a to 864d7f2 Compare October 15, 2024 14:29
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@starius starius merged commit 2c32575 into lightninglabs:master Oct 15, 2024
4 checks passed
@starius starius deleted the sweepbatcher-feerate-grows branch October 15, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants