Skip to content

Commit 2e3a2b2

Browse files
authored
Merge pull request #1698 from lightninglabs/wip/proof-syncer-resilience
universe: improve robustness of proof leaf sync
2 parents 652ce04 + bd32f90 commit 2e3a2b2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

universe/syncer.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func (s *SimpleSyncer) syncRoot(ctx context.Context, remoteRoot Root,
304304

305305
// Now that we know where the divergence is, we can fetch the issuance
306306
// proofs from the remote party.
307-
err = fn.ParSlice(
307+
fetchErrs, err := fn.ParSliceErrCollect(
308308
ctx, keysToFetch, func(ctx context.Context, key LeafKey) error {
309309
newProof, err := diffEngine.FetchProofLeaf(
310310
ctx, uniID, key,
@@ -320,8 +320,9 @@ func (s *SimpleSyncer) syncRoot(ctx context.Context, remoteRoot Root,
320320
// given.
321321
validRoot := leafProof.VerifyRoot(remoteRoot)
322322
if !validRoot {
323-
return fmt.Errorf("proof for key=%v is "+
324-
"invalid", spew.Sdump(key))
323+
return fmt.Errorf("proof leaf failed "+
324+
"universe root verification "+
325+
"(leaf_key=%v)", spew.Sdump(key))
325326
}
326327

327328
// If this is an issuance proof, then we can send
@@ -379,6 +380,13 @@ func (s *SimpleSyncer) syncRoot(ctx context.Context, remoteRoot Root,
379380
return err
380381
}
381382

383+
// Report any errors encountered while fetching the leaves.
384+
for idx, fetchErr := range fetchErrs {
385+
leafKey := keysToFetch[idx]
386+
log.Errorf("Error fetching leaf (leaf_key=%x): %v",
387+
leafKey.UniverseKey(), fetchErr)
388+
}
389+
382390
// We use an error group to simply the error handling of a goroutine.
383391
// This goroutine will handle reading in batches of new leaves to
384392
// insert into the DB. We'll fee the output of the goroutines below

0 commit comments

Comments
 (0)