Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions breacharbiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func (b *breachArbiter) start() error {
}, func() {
breachRetInfos = make(map[wire.OutPoint]retributionInfo)
}); err != nil {
brarLog.Errorf("Unable to create retribution info: %v", err)
return err
}

Expand All @@ -190,6 +191,9 @@ func (b *breachArbiter) start() error {
return err
}

brarLog.Debugf("Found %v closing channels, %v retribution records",
len(closedChans), len(breachRetInfos))

// Using the set of non-pending, closed channels, reconcile any
// discrepancies between the channeldb and the retribution store by
// removing any retribution information for which we have already
Expand All @@ -199,6 +203,9 @@ func (b *breachArbiter) start() error {
// TODO(halseth): no need continue on IsPending once closed channels
// actually means close transaction is confirmed.
for _, chanSummary := range closedChans {
brarLog.Debugf("Working on close channel: %v, is_pending: %v",
chanSummary.ChanPoint, chanSummary.IsPending)

if chanSummary.IsPending {
continue
}
Expand All @@ -212,6 +219,9 @@ func (b *breachArbiter) start() error {
return err
}
delete(breachRetInfos, *chanPoint)

brarLog.Debugf("Skipped closed channel: %v",
chanSummary.ChanPoint)
}
}

Expand All @@ -220,6 +230,9 @@ func (b *breachArbiter) start() error {
for chanPoint := range breachRetInfos {
retInfo := breachRetInfos[chanPoint]

brarLog.Debugf("Handling breach handoff on startup "+
"for ChannelPoint(%v)", chanPoint)

// Register for a notification when the breach transaction is
// confirmed on chain.
breachTXID := retInfo.commitHash
Expand Down
10 changes: 5 additions & 5 deletions contractcourt/channel_arbitrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ func (c *ChannelArbitrator) Start(state *chanArbStartState) error {
}
}

log.Debugf("Starting ChannelArbitrator(%v), htlc_set=%v",
log.Debugf("Starting ChannelArbitrator(%v), htlc_set=%v, state=%v",
c.cfg.ChanPoint, newLogClosure(func() string {
return spew.Sdump(c.activeHTLCs)
}),
}), state.currentState,
)

// Set our state from our starting state.
Expand Down Expand Up @@ -795,7 +795,7 @@ func (c *ChannelArbitrator) stateStep(
// default state. If this isn't a self initiated event (we're
// checking due to a chain update), then we'll exit now.
if len(chainActions) == 0 && trigger == chainTrigger {
log.Tracef("ChannelArbitrator(%v): no actions for "+
log.Debugf("ChannelArbitrator(%v): no actions for "+
"chain trigger, terminating", c.cfg.ChanPoint)

return StateDefault, closeTx, nil
Expand Down Expand Up @@ -1303,7 +1303,7 @@ func (c *ChannelArbitrator) advanceState(
// transition to is that same state that we started at.
for {
priorState = c.state
log.Tracef("ChannelArbitrator(%v): attempting state step with "+
log.Debugf("ChannelArbitrator(%v): attempting state step with "+
"trigger=%v from state=%v", c.cfg.ChanPoint, trigger,
priorState)

Expand All @@ -1324,7 +1324,7 @@ func (c *ChannelArbitrator) advanceState(
// our prior state back as the next state, then we'll
// terminate.
if nextState == priorState {
log.Tracef("ChannelArbitrator(%v): terminating at "+
log.Debugf("ChannelArbitrator(%v): terminating at "+
"state=%v", c.cfg.ChanPoint, nextState)
return nextState, forceCloseTx, nil
}
Expand Down
4 changes: 4 additions & 0 deletions docs/release-notes/release-notes-0.14.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ you.

* [Upgraded miekg/dns to improve the security posture](https://github.com/lightningnetwork/lnd/pull/5738)

* [Fixed flakes caused by graph topology subcription](https://github.com/lightningnetwork/lnd/pull/5611).

* [Order of the start/stop on subsystems are changed to promote better safety](https://github.com/lightningnetwork/lnd/pull/1783).

## Database

* [Ensure single writer for legacy
Expand Down
60 changes: 28 additions & 32 deletions lntest/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -1263,56 +1263,52 @@ func (n *NetworkHarness) CloseChannel(lnNode *HarnessNode,
}
}

closeReq := &lnrpc.CloseChannelRequest{
ChannelPoint: cp,
Force: force,
}
closeRespStream, err := lnNode.CloseChannel(ctx, closeReq)
if err != nil {
return nil, nil, fmt.Errorf("unable to close channel: %v", err)
}
var (
closeRespStream lnrpc.Lightning_CloseChannelClient
closeTxid *chainhash.Hash
)

errChan := make(chan error)
fin := make(chan *chainhash.Hash)
go func() {
// Consume the "channel close" update in order to wait for the closing
// transaction to be broadcast, then wait for the closing tx to be seen
// within the network.
err = wait.NoError(func() error {
closeReq := &lnrpc.CloseChannelRequest{
ChannelPoint: cp, Force: force,
}
closeRespStream, err = lnNode.CloseChannel(ctx, closeReq)
if err != nil {
return fmt.Errorf("unable to close channel: %v", err)
}

// Consume the "channel close" update in order to wait for the
// closing transaction to be broadcast, then wait for the
// closing tx to be seen within the network.
closeResp, err := closeRespStream.Recv()
if err != nil {
errChan <- fmt.Errorf("unable to recv() from close "+
return fmt.Errorf("unable to recv() from close "+
"stream: %v", err)
return
}
pendingClose, ok := closeResp.Update.(*lnrpc.CloseStatusUpdate_ClosePending)
if !ok {
errChan <- fmt.Errorf("expected channel close update, "+
return fmt.Errorf("expected channel close update, "+
"instead got %v", pendingClose)
return
}

closeTxid, err := chainhash.NewHash(pendingClose.ClosePending.Txid)
closeTxid, err = chainhash.NewHash(
pendingClose.ClosePending.Txid,
)
if err != nil {
errChan <- fmt.Errorf("unable to decode closeTxid: "+
return fmt.Errorf("unable to decode closeTxid: "+
"%v", err)
return
}
if err := n.waitForTxInMempool(ctx, *closeTxid); err != nil {
errChan <- fmt.Errorf("error while waiting for "+
return fmt.Errorf("error while waiting for "+
"broadcast tx: %v", err)
return
}
fin <- closeTxid
}()

// Wait until either the deadline for the context expires, an error
// occurs, or the channel close update is received.
select {
case err := <-errChan:
return nil
}, ChannelCloseTimeout)
if err != nil {
return nil, nil, err
case closeTxid := <-fin:
return closeRespStream, closeTxid, nil
}

return closeRespStream, closeTxid, nil
}

// WaitForChannelClose waits for a notification from the passed channel close
Expand Down
Loading