-
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
sweeper: rename Failed
to Fatal
and minor refactor
#9446
base: master
Are you sure you want to change the base?
sweeper: rename Failed
to Fatal
and minor refactor
#9446
Conversation
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This commit renames `Failed` to `Fatal` as it sounds too close to `PublishFailed`. We also wanna emphasize that inputs in this state won't be retried.
This commit shortens the function signature of `storeRecord`, also makes sure we don't call `t.records.Store` directly but always using `storeRecord` instead so it's easier to trace the record creation.
This way we can greatly simplify the method signatures, also paving the upcoming changes where we wanna make it clear when updating the monitorRecord, we only touch a portion of it.
To make it clear we are only updating fields, which will be handy for the following commit where we start tracking for spending notifications.
e8cb0c7
to
a738e7f
Compare
sweep/fee_bumper.go
Outdated
|
||
// spendNotifiers is a map of spend notifiers registered for all the | ||
// inputs. | ||
spendNotifiers map[wire.OutPoint]*chainntnfs.SpendEvent |
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.
This doesn't belong in this commit.
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.
hmm cannot find the commit - seems to be referring to an old one
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.
This is in commit 0ae9f1a.
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.
i see this too @yyforyongyu - it's currently in the sweep: add requestID to monitorRecord
commit which I assume was only meant to do that refactor
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.
it's unused in this commit and then removed in the next
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.
refactor LGTM! (small rebase artefact nit)
// - when a pending input has too many failed publish attempts; | ||
// - the input has been spent by another party; | ||
// - unknown broadcast error is returned. | ||
Fatal |
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.
another option could be "Terminal" since then it is very clear it wont be tried again
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.
but fatal is good too
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.
sweep/fee_bumper.go
Outdated
req *BumpRequest, f FeeFunction) { | ||
|
||
// Register the record. | ||
t.records.Store(requestID, &monitorRecord{ |
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.
should we comment somewhere that this should be the only call-site of t.records.Store
?
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.
So there's one other location right now:
Lines 427 to 441 in 0ac5bfa
// storeInitialRecord initializes a monitor record and saves it in the map. | |
func (t *TxPublisher) storeInitialRecord(req *BumpRequest) ( | |
uint64, *monitorRecord) { | |
// Increase the request counter. | |
// | |
// NOTE: this is the only place where we increase the counter. | |
requestID := t.requestCounter.Add(1) | |
// Register the record. | |
record := &monitorRecord{req: req} | |
t.records.Store(requestID, record) | |
return requestID, record | |
} |
As is, it's used for initial storage (no fee function set, etc). It's also where the requestID
is allocated for the first time.
sweep/fee_bumper.go
Outdated
|
||
// spendNotifiers is a map of spend notifiers registered for all the | ||
// inputs. | ||
spendNotifiers map[wire.OutPoint]*chainntnfs.SpendEvent |
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.
i see this too @yyforyongyu - it's currently in the sweep: add requestID to monitorRecord
commit which I assume was only meant to do that refactor
sweep/fee_bumper.go
Outdated
|
||
// spendNotifiers is a map of spend notifiers registered for all the | ||
// inputs. | ||
spendNotifiers map[wire.OutPoint]*chainntnfs.SpendEvent |
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.
it's unused in this commit and then removed in the next
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 🐯
// - when a pending input has too many failed publish attempts; | ||
// - the input has been spent by another party; | ||
// - unknown broadcast error is returned. | ||
Fatal |
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.
@@ -508,10 +522,7 @@ func (t *TxPublisher) createRBFCompliantTx(requestID uint64, req *BumpRequest, | |||
switch { | |||
case err == nil: | |||
// The tx is valid, store it. | |||
t.storeRecord( | |||
requestID, sweepCtx.tx, req, f, sweepCtx.fee, | |||
sweepCtx.outpointToTxIndex, |
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.
Nice simplification (roll in fields already part of sweepCtx
).
sweep/fee_bumper.go
Outdated
req *BumpRequest, f FeeFunction) { | ||
|
||
// Register the record. | ||
t.records.Store(requestID, &monitorRecord{ |
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.
So there's one other location right now:
Lines 427 to 441 in 0ac5bfa
// storeInitialRecord initializes a monitor record and saves it in the map. | |
func (t *TxPublisher) storeInitialRecord(req *BumpRequest) ( | |
uint64, *monitorRecord) { | |
// Increase the request counter. | |
// | |
// NOTE: this is the only place where we increase the counter. | |
requestID := t.requestCounter.Add(1) | |
// Register the record. | |
record := &monitorRecord{req: req} | |
t.records.Store(requestID, record) | |
return requestID, record | |
} |
As is, it's used for initial storage (no fee function set, etc). It's also where the requestID
is allocated for the first time.
sweep/fee_bumper.go
Outdated
|
||
// spendNotifiers is a map of spend notifiers registered for all the | ||
// inputs. | ||
spendNotifiers map[wire.OutPoint]*chainntnfs.SpendEvent |
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.
Added in an earlier commit, and removed here.
req *BumpRequest, f FeeFunction) { | ||
// updateRecord updates the given record's tx and fee, and saves it in the | ||
// records map. | ||
func (t *TxPublisher) updateRecord(r *monitorRecord, |
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.
solid change 👍
Check-picked some commits from the final sweeper fix.
This is a pure refactoring PR to make a following fix easier to implement, the changes are,
Failed
toFatal
for clarity.storeRecord
toupdateRecord
for clarity.