Skip to content

Commit be1742c

Browse files
authored
Merge pull request #1853 from lightninglabs/wip/improve-troubleshoot-logging
Improve troubleshooting logs for bug reports 1845 and 1850
2 parents 33dd9a5 + 5e57802 commit be1742c

File tree

5 files changed

+59
-29
lines changed

5 files changed

+59
-29
lines changed

address/book.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ func (b *Book) NewAddress(ctx context.Context, addrVersion Version,
535535
error) {
536536

537537
// Before we proceed and make new keys, make sure that we actually know
538-
// of this asset ID, or can import it.
538+
// of this asset, or can import it.
539539
if _, err := b.QueryAssetInfo(ctx, specifier); err != nil {
540540
return nil, fmt.Errorf("unable to make address for unknown "+
541541
"asset %s: %w", &specifier, err)

authmailbox/receive_subscription.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,9 @@ func (s *receiveSubscription) connectServerStream(ctx context.Context,
249249
if backoff > s.cfg.MaxBackoff {
250250
backoff = s.cfg.MaxBackoff
251251
}
252-
log.DebugS(ctx, "Connect failed with error, canceling and "+
253-
"backing off", "backoff", backoff, "err", err)
252+
log.WarnS(ctx, "Connect failed with error, canceling and "+
253+
"backing off", err, "backoff", backoff, "client_config",
254+
s.cfg)
254255

255256
if i < numRetries-1 {
256257
log.InfoS(ctx, "Connection to server failed, will try "+
@@ -278,7 +279,8 @@ func (s *receiveSubscription) connectServerStream(ctx context.Context,
278279

279280
// Read incoming messages and send them to the channel where the caller
280281
// is listening to.
281-
log.InfoS(ctx, "Successfully connected to mailbox server")
282+
log.InfoS(ctx, "Successfully connected to mailbox server",
283+
"server_addr", s.cfg.ServerAddress)
282284
s.wg.Add(1)
283285
go func() {
284286
defer s.wg.Done()

rfq/manager.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,6 @@ func (m *Manager) handleIncomingMessage(incomingMsg rfqmsg.IncomingMsg) error {
416416
}
417417

418418
case *rfqmsg.BuyAccept:
419-
// TODO(ffranr): The stream handler should ensure that the
420-
// accept message corresponds to a request.
421-
422419
finaliseCallback := func(msg rfqmsg.BuyAccept,
423420
invalidQuoteEvent fn.Option[InvalidQuoteRespEvent]) {
424421

@@ -472,9 +469,6 @@ func (m *Manager) handleIncomingMessage(incomingMsg rfqmsg.IncomingMsg) error {
472469
}
473470

474471
case *rfqmsg.SellAccept:
475-
// TODO(ffranr): The stream handler should ensure that the
476-
// accept message corresponds to a request.
477-
478472
finaliseCallback := func(msg rfqmsg.SellAccept,
479473
invalidQuoteEvent fn.Option[InvalidQuoteRespEvent]) {
480474

rpcserver.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,8 @@ func (r *rpcServer) QueryAddrs(ctx context.Context,
16261626
func (r *rpcServer) NewAddr(ctx context.Context,
16271627
req *taprpc.NewAddrRequest) (*taprpc.Addr, error) {
16281628

1629+
rpcsLog.TraceS(ctx, "[NewAddr]: Called", "req", spew.Sdump(req))
1630+
16291631
// Parse the proof courier address if one was provided, otherwise use
16301632
// the default specified in the config.
16311633
courierAddr := r.cfg.DefaultProofCourierAddr
@@ -1660,9 +1662,6 @@ func (r *rpcServer) NewAddr(ctx context.Context,
16601662
err)
16611663
}
16621664

1663-
rpcsLog.Infof("[NewAddr]: making new addr: specifier=%s, amt=%v",
1664-
&specifier, req.Amt)
1665-
16661665
err = r.checkBalanceOverflow(ctx, assetID, groupKey, req.Amt)
16671666
if err != nil {
16681667
return nil, err
@@ -1695,6 +1694,10 @@ func (r *rpcServer) NewAddr(ctx context.Context,
16951694
addrVersion = address.V2
16961695
}
16971696

1697+
rpcsLog.Infof("[NewAddr]: Making new addr: specifier=%s, amt=%v, "+
1698+
"courier=%v, addr_version=%v, asset_version=%v", &specifier,
1699+
req.Amt, courierAddr, addrVersion, assetVersion)
1700+
16981701
// Addresses with version 2 must use the new authmailbox proof courier
16991702
// type.
17001703
protocol := courierAddr.Scheme
@@ -1790,8 +1793,8 @@ func (r *rpcServer) NewAddr(ctx context.Context,
17901793
address.WithAssetVersion(assetVersion),
17911794
)
17921795
if err != nil {
1793-
return nil, fmt.Errorf("unable to make new addr: %w",
1794-
err)
1796+
return nil, fmt.Errorf("unable to make new addr with "+
1797+
"keys: %w", err)
17951798
}
17961799
}
17971800

tapgarden/planter_test.go

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,15 @@ func (t *mintingTestHarness) queueSeedlingsInBatch(isFunded bool,
331331

332332
// assertPendingBatchExists asserts that a pending batch is found and it has
333333
// numSeedlings assets registered.
334-
func (t *mintingTestHarness) assertPendingBatchExists(numSeedlings int) {
335-
t.Helper()
334+
func (t *mintingTestHarness) assertPendingBatchExists(
335+
expectedSeedlings []*tapgarden.Seedling) {
336336

337337
// The planter is a state machine, so we need to wait until it has
338338
// reached the expected state.
339+
var (
340+
numExpectedSeedlings = len(expectedSeedlings)
341+
lastActualSeedlings map[string]*tapgarden.Seedling
342+
)
339343
err := wait.NoError(func() error {
340344
batch, err := t.planter.PendingBatch()
341345
if err != nil {
@@ -348,14 +352,43 @@ func (t *mintingTestHarness) assertPendingBatchExists(numSeedlings int) {
348352
"non-nil")
349353
}
350354

351-
if len(batch.Seedlings) < numSeedlings {
355+
lastActualSeedlings = batch.Seedlings
356+
357+
if len(batch.Seedlings) < numExpectedSeedlings {
352358
return fmt.Errorf("expected %d seedlings, got %d",
353-
numSeedlings, len(batch.Seedlings))
359+
numExpectedSeedlings, len(batch.Seedlings))
354360
}
355361

356362
return nil
357363
}, defaultTimeout)
358-
require.NoError(t, err)
364+
if err != nil {
365+
// Report any missing seedlings.
366+
spewCfg := spew.ConfigState{
367+
// Disable .String() and other methods.
368+
DisableMethods: true,
369+
Indent: " ",
370+
}
371+
372+
for idx := range expectedSeedlings {
373+
expectedSeedling := expectedSeedlings[idx]
374+
if lastActualSeedlings == nil {
375+
t.Logf("Missing expected seedling: %s",
376+
spewCfg.Sdump(expectedSeedling))
377+
continue
378+
}
379+
380+
_, ok := lastActualSeedlings[expectedSeedling.AssetName]
381+
if !ok {
382+
t.Logf("Missing expected seedling: %s",
383+
spewCfg.Sdump(expectedSeedling))
384+
}
385+
}
386+
387+
t.Fatalf("Batch seedling mismatch: \nactual seedlings: %s\n"+
388+
"expected seedlings: %s\nerror: %v",
389+
spew.Sdump(lastActualSeedlings),
390+
spew.Sdump(expectedSeedlings), err)
391+
}
359392
}
360393

361394
// assertNoActiveBatch asserts that no pending batch exists.
@@ -1089,7 +1122,7 @@ func (t *mintingTestHarness) queueInitialBatch(
10891122

10901123
// At this point, there should be a single pending batch with 5
10911124
// seedlings. The batch stored in the log should also match up exactly.
1092-
t.assertPendingBatchExists(numSeedlings)
1125+
t.assertPendingBatchExists(seedlings)
10931126

10941127
// Before we tick the batch, we record all existing batches, so we can
10951128
// make sure a new one was created.
@@ -1303,10 +1336,9 @@ func testMintingCancelFinalize(t *mintingTestHarness) {
13031336
// harness.
13041337
t.refreshChainPlanter()
13051338

1306-
// Create an initial batch of 5 seedlings.
1307-
const numSeedlings = 5
1339+
// Create an initial set of seedlings.
1340+
const numSeedlings = 4
13081341
seedlings := t.queueInitialBatch(numSeedlings)
1309-
firstSeedling := seedlings[0]
13101342

13111343
// If we cancel the current batch, the pending batch should be cleared,
13121344
// but the seedlings should still exist on disk.
@@ -1320,21 +1352,20 @@ func testMintingCancelFinalize(t *mintingTestHarness) {
13201352
t.finalizeBatchAssertFrozen(true)
13211353
t.cancelMintingBatch(true)
13221354

1323-
// Next, make another 5 random seedlings and continue with minting.
1355+
// Next, make another set of random seedlings and continue with minting.
13241356
seedlings = t.newRandSeedlings(numSeedlings)
1325-
seedlings[0] = firstSeedling
13261357
seedlings[0].ScriptKey = asset.ScriptKey{}
13271358
if seedlings[0].EnableEmission {
13281359
seedlings[0].GroupInternalKey = nil
13291360
}
13301361
t.queueSeedlingsInBatch(false, seedlings...)
13311362

1332-
t.assertPendingBatchExists(numSeedlings)
1363+
t.assertPendingBatchExists(seedlings)
13331364
t.assertSeedlingsExist(seedlings, nil)
13341365

13351366
// If we attempt to queue a seedling with the same name as a pending
13361367
// seedling, the planter should reject it.
1337-
updates, err := t.planter.QueueNewSeedling(firstSeedling)
1368+
updates, err := t.planter.QueueNewSeedling(seedlings[0])
13381369
require.NoError(t, err)
13391370
planterErr := <-updates
13401371
require.NotNil(t, planterErr.Error)
@@ -1781,7 +1812,7 @@ func testFundSealBeforeFinalize(t *mintingTestHarness) {
17811812
// Add the seedlings modified earlier to the batch, and check that they
17821813
// were added correctly.
17831814
t.queueSeedlingsInBatch(true, seedlings...)
1784-
t.assertPendingBatchExists(numSeedlings)
1815+
t.assertPendingBatchExists(seedlings)
17851816
t.assertSeedlingsExist(seedlings, nil)
17861817

17871818
verboseBatches, err := t.planter.ListBatches(

0 commit comments

Comments
 (0)