From fecd5ac735d3169e11e888d5472ac44fc3ea3f67 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Wed, 18 Dec 2024 19:33:41 +0800 Subject: [PATCH] contractcourt: make sure `launchResolvers` is called on new blockbeat This is an oversight from addressing this commment: https://github.com/lightningnetwork/lnd/pull/9277#discussion_r1882410396 where we should focus on skipping the close events but not the resolvers. --- contractcourt/channel_arbitrator.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index f193ee68d..3b1c82ce5 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -2994,12 +2994,18 @@ func (c *ChannelArbitrator) handleBlockbeat(beat chainio.Blockbeat) error { // If the state is StateContractClosed, StateWaitingFullResolution, or // StateFullyResolved, there's no need to read the close event channel - // and launch the resolvers since the arbitrator can only get to this - // state after processing a previous close event and launched all its - // resolvers. + // since the arbitrator can only get to this state after processing a + // previous close event and launched all its resolvers. if c.state.IsContractClosed() { - log.Infof("ChannelArbitrator(%v): skipping launching "+ - "resolvers in state=%v", c.cfg.ChanPoint, c.state) + log.Infof("ChannelArbitrator(%v): skipping reading close "+ + "events in state=%v", c.cfg.ChanPoint, c.state) + + // Launch all active resolvers when a new blockbeat is + // received, even when the contract is closed, we still need + // this as the resolvers may transform into new ones. For + // already launched resolvers this will be NOOP as they track + // their own `launched` states. + c.launchResolvers() return nil }