-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[3/5]sweep: make pending inputs stateful #8423
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
Merged
yyforyongyu
merged 15 commits into
lightningnetwork:elle-new-sweeper
from
yyforyongyu:sweeper-rbf-2
Mar 27, 2024
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ce8c8c9
sweep: make pending input stateful
yyforyongyu d67c7f4
multi: query mempool spend when a new input is received
yyforyongyu 41d9a81
sweep: delete pending inputs based on their states
yyforyongyu be3dfa4
sweep: add fee info for published inputs
yyforyongyu f886f88
sweep: don't give up an input based on number of attempts
yyforyongyu 207e006
sweep: add method `markInputFailed`
yyforyongyu 4d3441d
sweep: patch unit tests for `markInputsSwept` and `markInputsPendingP…
yyforyongyu b12497b
sweep: remove unused param `testSpendChan`
yyforyongyu 800f5ba
sweep: fix logging
yyforyongyu b078ad1
lnd+sweep: remove unused `NextAttemptDeltaFunc`
yyforyongyu 6471835
btcdnotify: use `chain.NewRPCClientWithConfig` to init RPC client
yyforyongyu 6ecac77
chainntnfs+sweep: add `LookupInputMempoolSpend` and use it in the
yyforyongyu 97a6f0a
docs: update release notes
yyforyongyu 041aecf
lntest+itest: fix `testOpenChannelLockedBalance`
yyforyongyu fa2c3cf
sweep: refactor `attachAvailableRBFInfo` to `decideStateAndRBFInfo`
yyforyongyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package chainntnfs | ||
|
||
import ( | ||
"github.com/btcsuite/btcd/wire" | ||
"github.com/lightningnetwork/lnd/fn" | ||
"github.com/stretchr/testify/mock" | ||
) | ||
|
||
// MockMempoolWatcher is a mock implementation of the MempoolWatcher interface. | ||
// This is used by other subsystems to mock the behavior of the mempool | ||
// watcher. | ||
type MockMempoolWatcher struct { | ||
mock.Mock | ||
} | ||
|
||
// NewMockMempoolWatcher returns a new instance of a mock mempool watcher. | ||
func NewMockMempoolWatcher() *MockMempoolWatcher { | ||
return &MockMempoolWatcher{} | ||
} | ||
|
||
// Compile-time check to ensure MockMempoolWatcher implements MempoolWatcher. | ||
var _ MempoolWatcher = (*MockMempoolWatcher)(nil) | ||
|
||
// SubscribeMempoolSpent implements the MempoolWatcher interface. | ||
func (m *MockMempoolWatcher) SubscribeMempoolSpent( | ||
op wire.OutPoint) (*MempoolSpendEvent, error) { | ||
|
||
args := m.Called(op) | ||
|
||
if args.Get(0) == nil { | ||
return nil, args.Error(1) | ||
} | ||
|
||
return args.Get(0).(*MempoolSpendEvent), args.Error(1) | ||
} | ||
|
||
// CancelMempoolSpendEvent implements the MempoolWatcher interface. | ||
func (m *MockMempoolWatcher) CancelMempoolSpendEvent( | ||
sub *MempoolSpendEvent) { | ||
|
||
m.Called(sub) | ||
} | ||
|
||
// LookupInputMempoolSpend looks up the mempool to find a spending tx which | ||
// spends the given outpoint. | ||
func (m *MockMempoolWatcher) LookupInputMempoolSpend( | ||
op wire.OutPoint) fn.Option[wire.MsgTx] { | ||
|
||
args := m.Called(op) | ||
|
||
return args.Get(0).(fn.Option[wire.MsgTx]) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,17 +145,6 @@ func (c *anchorResolver) Resolve() (ContractResolver, error) { | |
c.log.Warnf("our anchor spent by someone else") | ||
outcome = channeldb.ResolverOutcomeUnclaimed | ||
|
||
// The sweeper gave up on sweeping the anchor. This happens | ||
// after the maximum number of sweep attempts has been reached. | ||
// See sweep.DefaultMaxSweepAttempts. Sweep attempts are | ||
// interspaced with random delays picked from a range that | ||
// increases exponentially. | ||
// | ||
// We consider the anchor as being lost. | ||
case sweep.ErrTooManyAttempts: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
c.log.Warnf("anchor sweep abandoned") | ||
outcome = channeldb.ResolverOutcomeUnclaimed | ||
|
||
// An unexpected error occurred. | ||
default: | ||
c.log.Errorf("unable to sweep anchor: %v", sweepRes.Err) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.