Skip to content

Commit

Permalink
multi: improve loggings
Browse files Browse the repository at this point in the history
  • Loading branch information
yyforyongyu committed Oct 15, 2024
1 parent 54d8b17 commit d76a26e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 20 deletions.
12 changes: 7 additions & 5 deletions contractcourt/channel_arbitrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1609,8 +1609,8 @@ func (c *ChannelArbitrator) advanceState(
for {
priorState = c.state
log.Debugf("ChannelArbitrator(%v): attempting state step with "+
"trigger=%v from state=%v", c.cfg.ChanPoint, trigger,
priorState)
"trigger=%v from state=%v at height=%v",
c.cfg.ChanPoint, trigger, priorState, triggerHeight)

nextState, closeTx, err := c.stateStep(
triggerHeight, trigger, confCommitSet,
Expand Down Expand Up @@ -2849,16 +2849,18 @@ func (c *ChannelArbitrator) channelAttendant(bestHeight int32) {
// We have broadcasted our commitment, and it is now confirmed
// on-chain.
case closeInfo := <-c.cfg.ChainEvents.LocalUnilateralClosure:
log.Infof("ChannelArbitrator(%v): local on-chain "+
"channel close", c.cfg.ChanPoint)

if c.state != StateCommitmentBroadcasted {
log.Errorf("ChannelArbitrator(%v): unexpected "+
"local on-chain channel close",
c.cfg.ChanPoint)
}

closeTx := closeInfo.CloseTx

log.Infof("ChannelArbitrator(%v): local force close "+
"tx=%v confirmed", c.cfg.ChanPoint,
closeTx.TxHash())

contractRes := &ContractResolutions{
CommitHash: closeTx.TxHash(),
CommitResolution: closeInfo.CommitResolution,
Expand Down
9 changes: 3 additions & 6 deletions contractcourt/htlc_lease_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,17 @@ func (h *htlcLeaseResolver) makeSweepInput(op *wire.OutPoint,
signDesc *input.SignDescriptor,
csvDelay, broadcastHeight uint32, payHash [32]byte) *input.BaseInput {

if h.hasCLTV() {
log.Infof("%T(%x): CSV and CLTV locks expired, offering "+
"second-layer output to sweeper: %v", h, payHash, op)
log.Infof("%T(%x): offering second-layer output to sweeper: %v", h,
payHash, op)

if h.hasCLTV() {
return input.NewCsvInputWithCltv(
op, cltvWtype, signDesc,
broadcastHeight, csvDelay,
h.leaseExpiry,
)
}

log.Infof("%T(%x): CSV lock expired, offering second-layer output to "+
"sweeper: %v", h, payHash, op)

return input.NewCsvInput(op, wType, signDesc, broadcastHeight, csvDelay)
}

Expand Down
2 changes: 1 addition & 1 deletion contractcourt/utxonursery.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ func (u *UtxoNursery) graduateClass(classHeight uint32) error {
return err
}

utxnLog.Infof("Attempting to graduate height=%v: num_kids=%v, "+
utxnLog.Debugf("Attempting to graduate height=%v: num_kids=%v, "+
"num_babies=%v", classHeight, len(kgtnOutputs), len(cribOutputs))

// Offer the outputs to the sweeper and set up notifications that will
Expand Down
2 changes: 1 addition & 1 deletion htlcswitch/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ out:
}
}

log.Infof("Received outside contract resolution, "+
log.Debugf("Received outside contract resolution, "+
"mapping to: %v", spew.Sdump(pkt))

// We don't check the error, as the only failure we can
Expand Down
2 changes: 1 addition & 1 deletion lnwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ func (l *LightningWallet) RegisterFundingIntent(expectedID [32]byte,
}

if _, ok := l.fundingIntents[expectedID]; ok {
return fmt.Errorf("%w: already has intent registered: %v",
return fmt.Errorf("%w: already has intent registered: %x",
ErrDuplicatePendingChanID, expectedID[:])
}

Expand Down
16 changes: 10 additions & 6 deletions sweep/sweeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ func (p *SweeperInput) isMature(currentHeight uint32) (bool, uint32) {
// this input and wait for the expiry.
locktime = p.BlocksToMaturity() + p.HeightHint()
if currentHeight+1 < locktime {
log.Debugf("Input %v has CSV expiry=%v, current height is %v",
p.OutPoint(), locktime, currentHeight)
log.Debugf("Input %v has CSV expiry=%v, current height is %v, "+
"skipped sweeping", p.OutPoint(), locktime,
currentHeight)

return false, locktime
}
Expand Down Expand Up @@ -1203,8 +1204,8 @@ func (s *UtxoSweeper) calculateDefaultDeadline(pi *SweeperInput) int32 {
if !matured {
defaultDeadline = int32(locktime + s.cfg.NoDeadlineConfTarget)
log.Debugf("Input %v is immature, using locktime=%v instead "+
"of current height=%d", pi.OutPoint(), locktime,
s.currentHeight)
"of current height=%d as starting height",
pi.OutPoint(), locktime, s.currentHeight)
}

return defaultDeadline
Expand All @@ -1216,7 +1217,8 @@ func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) error {
outpoint := input.input.OutPoint()
pi, pending := s.inputs[outpoint]
if pending {
log.Debugf("Already has pending input %v received", outpoint)
log.Infof("Already has pending input %v received, old params: "+
"%v, new params %v", outpoint, pi.params, input.params)

s.handleExistingInput(input, pi)

Expand Down Expand Up @@ -1498,6 +1500,8 @@ func (s *UtxoSweeper) updateSweeperInputs() InputsMap {
// turn this inputs map into a SyncMap in case we wanna add concurrent
// access to the map in the future.
for op, input := range s.inputs {
log.Tracef("Checking input: %s, state=%v", input, input.state)

// If the input has reached a final state, that it's either
// been swept, or failed, or excluded, we will remove it from
// our sweeper.
Expand Down Expand Up @@ -1527,7 +1531,7 @@ func (s *UtxoSweeper) updateSweeperInputs() InputsMap {
// skip this input and wait for the locktime to be reached.
mature, locktime := input.isMature(uint32(s.currentHeight))
if !mature {
log.Infof("Skipping input %v due to locktime=%v not "+
log.Debugf("Skipping input %v due to locktime=%v not "+
"reached, current height is %v", op, locktime,
s.currentHeight)

Expand Down

0 comments on commit d76a26e

Please sign in to comment.