From e45db07a10873012f7c8b62efa10fdd22e13db6b Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Fri, 17 May 2024 05:02:02 +0800 Subject: [PATCH] contractcourt+itest: make sure ChannelArbitrator has the latest htlcs --- contractcourt/chain_arbitrator.go | 4 ++++ contractcourt/channel_arbitrator.go | 3 +++ itest/lnd_multi-hop_test.go | 6 ------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index fbddd81f0..0cc4b111a 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -1287,6 +1287,10 @@ func (c *ChainArbitrator) FindOutgoingHTLCDeadline(scid lnwire.ShortChannelID, continue } + // Make sure the channel arbitrator has the latest view of its + // active HTLCs. + channelArb.updateActiveHTLCs() + // Iterate all the known HTLCs to find the targeted incoming // HTLC. for _, htlcs := range channelArb.activeHTLCs { diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index f9df71c19..cda0d4e1f 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -3089,6 +3089,9 @@ func (c *ChannelArbitrator) channelAttendant(bestHeight int32) { // We've just received a request to forcibly close out the // channel. We'll case closeReq := <-c.forceCloseReqs: + log.Infof("ChannelArbitrator(%v): received force "+ + "close request", c.cfg.ChanPoint) + if c.state != StateDefault { select { case closeReq.closeTx <- nil: diff --git a/itest/lnd_multi-hop_test.go b/itest/lnd_multi-hop_test.go index 7ff9f48b4..09b2cdf46 100644 --- a/itest/lnd_multi-hop_test.go +++ b/itest/lnd_multi-hop_test.go @@ -713,12 +713,6 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest, // to be mined to trigger a force close later on. var blocksMined uint32 - // We need to mine a block otherwise `FindOutgoingHTLCDeadline` cannot - // find the incoming HTLC on Bob's ChainArbitrator. - // - // TODO(yy): Investigate and fix it! - ht.MineEmptyBlocks(1) - // Now that all parties have the HTLC locked in, we'll immediately // force close the Bob -> Carol channel. This should trigger contract // resolution mode for both of them.