contractcourt: use close height instead of best height

This commit adds the closing height to the logging and fixes a wrong
height used in handling the breach event.
This commit is contained in:
yyforyongyu
2024-12-04 05:29:55 +08:00
parent 3822c23833
commit 4d765668cc

View File

@@ -2861,7 +2861,8 @@ func (c *ChannelArbitrator) channelAttendant(bestHeight int32,
// needed. We'll mark the channel as resolved and exit. // needed. We'll mark the channel as resolved and exit.
case closeInfo := <-c.cfg.ChainEvents.CooperativeClosure: case closeInfo := <-c.cfg.ChainEvents.CooperativeClosure:
log.Infof("ChannelArbitrator(%v) marking channel "+ log.Infof("ChannelArbitrator(%v) marking channel "+
"cooperatively closed", c.cfg.ChanPoint) "cooperatively closed at height %v",
c.cfg.ChanPoint, closeInfo.CloseHeight)
err := c.cfg.MarkChannelClosed( err := c.cfg.MarkChannelClosed(
closeInfo.ChannelCloseSummary, closeInfo.ChannelCloseSummary,
@@ -2986,7 +2987,8 @@ func (c *ChannelArbitrator) channelAttendant(bestHeight int32,
// all. // all.
case uniClosure := <-c.cfg.ChainEvents.RemoteUnilateralClosure: case uniClosure := <-c.cfg.ChainEvents.RemoteUnilateralClosure:
log.Infof("ChannelArbitrator(%v): remote party has "+ log.Infof("ChannelArbitrator(%v): remote party has "+
"closed channel out on-chain", c.cfg.ChanPoint) "force closed channel at height %v",
c.cfg.ChanPoint, uniClosure.SpendingHeight)
// If we don't have a self output, and there are no // If we don't have a self output, and there are no
// active HTLC's, then we can immediately mark the // active HTLC's, then we can immediately mark the
@@ -3055,8 +3057,11 @@ func (c *ChannelArbitrator) channelAttendant(bestHeight int32,
// anything in particular, so just advance our state and // anything in particular, so just advance our state and
// gracefully exit. // gracefully exit.
case breachInfo := <-c.cfg.ChainEvents.ContractBreach: case breachInfo := <-c.cfg.ChainEvents.ContractBreach:
closeSummary := &breachInfo.CloseSummary
log.Infof("ChannelArbitrator(%v): remote party has "+ log.Infof("ChannelArbitrator(%v): remote party has "+
"breached channel!", c.cfg.ChanPoint) "breached channel at height %v!",
c.cfg.ChanPoint, closeSummary.CloseHeight)
// In the breach case, we'll only have anchor and // In the breach case, we'll only have anchor and
// breach resolutions. // breach resolutions.
@@ -3088,7 +3093,6 @@ func (c *ChannelArbitrator) channelAttendant(bestHeight int32,
// The channel is finally marked pending closed here as // The channel is finally marked pending closed here as
// the BreachArbitrator and channel arbitrator have // the BreachArbitrator and channel arbitrator have
// persisted the relevant states. // persisted the relevant states.
closeSummary := &breachInfo.CloseSummary
err = c.cfg.MarkChannelClosed( err = c.cfg.MarkChannelClosed(
closeSummary, closeSummary,
channeldb.ChanStatusRemoteCloseInitiator, channeldb.ChanStatusRemoteCloseInitiator,
@@ -3105,8 +3109,8 @@ func (c *ChannelArbitrator) channelAttendant(bestHeight int32,
// We'll advance our state machine until it reaches a // We'll advance our state machine until it reaches a
// terminal state. // terminal state.
_, _, err = c.advanceState( _, _, err = c.advanceState(
uint32(bestHeight), breachCloseTrigger, closeSummary.CloseHeight,
&breachInfo.CommitSet, breachCloseTrigger, &breachInfo.CommitSet,
) )
if err != nil { if err != nil {
log.Errorf("Unable to advance state: %v", err) log.Errorf("Unable to advance state: %v", err)