-
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
Beat [4/4]: implement Consumer
in chainWatcher
#9277
base: yy-blockbeat-finalize
Are you sure you want to change the base?
Beat [4/4]: implement Consumer
in chainWatcher
#9277
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 (
|
d2b0ffa
to
d863938
Compare
ac8ce82
to
a16b2d4
Compare
0ddd693
to
07631c0
Compare
c5f77e3
to
3456f2e
Compare
07631c0
to
96474de
Compare
3456f2e
to
3d08b74
Compare
96474de
to
c7747a2
Compare
3d08b74
to
e69cd41
Compare
c7747a2
to
a4f226a
Compare
e69cd41
to
cdd805f
Compare
a4f226a
to
9f740cc
Compare
contractcourt/chain_watcher.go
Outdated
// we proceed with the rest of the close observer logic for taproot channels. | ||
func (c *chainWatcher) chanPointConfirmed() bool { | ||
op := c.cfg.chanState.FundingOutpoint | ||
confNtfn, err := c.cfg.notifier.RegisterConfirmationsNtfn( |
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 think we need to be careful about some of these assumptions of insta conf sends here. This won't always be the case for the neutrino backend.
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.
cool we now moved the subscription earlier so it's more likely we can get this "on beat".
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 is it not possible to open a zeroconf channel and then close it even though it is not confirmed ?
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.
good q - i think theoratically we could do a package of [zero-conf funding tx -> coop close]
, but usually we want it to be confirmed to be safe.
// closure type. | ||
func (c *chainWatcher) handleBlockbeat(beat chainio.Blockbeat) { | ||
// Notify the chain arbitrator has processed the block. | ||
defer c.NotifyBlockProcessed(beat, nil) |
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.
Do you mean "chain watcher" here in the 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.
yikes now fixed!
default: | ||
log.Infof("Taproot ChannelPoint(%v) not confirmed yet", op) | ||
|
||
return false |
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 think we should cancel the conf request here, otherwise we'll have a new one stack up each block the transaction isn't confirmed.
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 catch - we now register it early during the initialization, similar to how fundingSpendNtfn
works, we register it once and cancel it when the funding tx is confirmed. The fix is in the final commit.
contractcourt/chain_arbitrator.go
Outdated
@@ -891,7 +891,7 @@ func (c *ChainArbitrator) Stop() error { | |||
} | |||
for chanPoint, arbitrator := range activeChannels { | |||
log.Tracef("Attempting to stop ChannelArbitrator(%v)", | |||
chanPoint) | |||
arbitrator.id()) |
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.
IMO, the scid is much less useful than the chan point. For the chan point we can easily use it to look up the transaction/channel. This is frequently done in incoming user bug reports. If you only have the scid
, you need to translate it to get the outpoint, which is what's commonly used.
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.
Got it, changed to chan point instead.
contractcourt/channel_arbitrator.go
Outdated
return | ||
} | ||
|
||
// The remote has breached the channel! We now launch the |
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.
Comment can be reflowed to the left.
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.
my bad, fixed.
1e58126
to
abbee3b
Compare
9f740cc
to
6bdb145
Compare
abbee3b
to
aeafa63
Compare
0032fd7
to
5c9c6d0
Compare
29521a1
to
7b19d5c
Compare
5c9c6d0
to
54eaec8
Compare
23ee2e3
to
897e642
Compare
a9f29f6
to
9793973
Compare
897e642
to
d854e87
Compare
9793973
to
a8bb337
Compare
d854e87
to
0397aaf
Compare
a8bb337
to
d77fde1
Compare
0397aaf
to
1a6653f
Compare
d77fde1
to
9efd5bf
Compare
1a6653f
to
33064a3
Compare
9efd5bf
to
8bc31ea
Compare
ef85fb5
to
cebad6d
Compare
This commit moves the creation of the spending notification from `Start` to `newChainWatcher` so we subscribe the spending event before handling the block, which is needed to properly handle the blockbeat.
To prepare for the blockbeat handler.
We now start notifying the blockbeat from the ChainArbitrator to the chainWatcher.
This commit adds the closing height to the logging and fixes a wrong height used in handling the breach event.
This commit adds a new method to enable us resending the blockbeat in `ChainArbitrator`, which is needed for the channel restore as the chain watcher and channel arbitrator are added after the start of the chain arbitrator.
To prepare the next commit where we would handle the event upon receiving a blockbeat.
We need to check `dispatched` before sending conf details, otherwise the channel `ntfn.Event.Confirmed` will be blocking, which is the leftover from lightningnetwork#9275.
8bc31ea
to
a890230
Compare
@Roasbeef: review reminder |
This PR implements the
Consumer
interface inchainWatcher
with necessary refactors.TODOs
Depends on
blockbeat
#9276NOTE: itest is fixed in the final PR