lnd+contractcourt: add more debug logs

This commit adds more debug logs for witness beacon and channel
arbitrator.
This commit is contained in:
yyforyongyu
2023-04-07 13:47:38 +08:00
parent e9c10bf0a1
commit dccf9c77ca
3 changed files with 25 additions and 3 deletions

View File

@@ -1589,11 +1589,15 @@ func (c *ChannelArbitrator) checkCommitChainActions(height uint32,
)
if toChain {
// Convert to int64 in case of overflow.
remainingBlocks := int64(htlc.RefundTimeout) -
int64(height)
log.Infof("ChannelArbitrator(%v): go to chain for "+
"outgoing htlc %x: timeout=%v, "+
"blocks_until_expiry=%v, broadcast_delta=%v",
c.cfg.ChanPoint, htlc.RHash[:],
htlc.RefundTimeout, htlc.RefundTimeout-height,
htlc.RefundTimeout, remainingBlocks,
c.cfg.OutgoingBroadcastDelta,
)
}
@@ -1620,11 +1624,15 @@ func (c *ChannelArbitrator) checkCommitChainActions(height uint32,
)
if toChain {
// Convert to int64 in case of overflow.
remainingBlocks := int64(htlc.RefundTimeout) -
int64(height)
log.Infof("ChannelArbitrator(%v): go to chain for "+
"incoming htlc %x: timeout=%v, "+
"blocks_until_expiry=%v, broadcast_delta=%v",
c.cfg.ChanPoint, htlc.RHash[:],
htlc.RefundTimeout, htlc.RefundTimeout-height,
htlc.RefundTimeout, remainingBlocks,
c.cfg.IncomingBroadcastDelta,
)
}

View File

@@ -140,6 +140,9 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
return nil, errResolverShuttingDown
}
log.Debugf("%T(%v): Resolving incoming HTLC(expiry=%v, height=%v)", h,
h.htlcResolution.ClaimOutpoint, h.htlcExpiry, currentHeight)
// We'll first check if this HTLC has been timed out, if so, we can
// return now and mark ourselves as resolved. If we're past the point of
// expiry of the HTLC, then at this point the sender can sweep it, so

View File

@@ -1,6 +1,7 @@
package lnd
import (
"errors"
"sync"
"github.com/lightningnetwork/lnd/channeldb"
@@ -127,6 +128,11 @@ func (p *preimageBeacon) LookupPreimage(
// Otherwise, we'll perform a final check using the witness cache.
preimage, err := p.wCache.LookupSha256Witness(payHash)
if errors.Is(err, channeldb.ErrNoWitnesses) {
ltndLog.Debugf("No witness for payment %v", payHash)
return lntypes.Preimage{}, false
}
if err != nil {
ltndLog.Errorf("Unable to lookup witness: %v", err)
return lntypes.Preimage{}, false
@@ -147,7 +153,9 @@ func (p *preimageBeacon) AddPreimages(preimages ...lntypes.Preimage) error {
// the caller when delivering notifications.
preimageCopies := make([]lntypes.Preimage, 0, len(preimages))
for _, preimage := range preimages {
srvrLog.Infof("Adding preimage=%v to witness cache", preimage)
srvrLog.Infof("Adding preimage=%v to witness cache for %v",
preimage, preimage.Hash())
preimageCopies = append(preimageCopies, preimage)
}
@@ -174,6 +182,9 @@ func (p *preimageBeacon) AddPreimages(preimages ...lntypes.Preimage) error {
}(client)
}
srvrLog.Debugf("Added %d preimage(s) to witness cache",
len(preimageCopies))
return nil
}