Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bor: don't hide ctx.Err() #8792

Merged
merged 3 commits into from
Nov 22, 2023
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
2 changes: 1 addition & 1 deletion consensus/bor/finality/bor_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func borVerify(ctx context.Context, config *config, start uint64, end uint64, ha
// check if we have the given blocks
currentBlock := rawdb.ReadCurrentBlockNumber(roTx)
if currentBlock == nil {
log.Debug("[bor] Failed to fetch current block from blockchain while verifying incoming", "str", str)
log.Debug("[bor] Failed to fetch current block while verifying", "incoming", str)
return hash, errMissingBlocks
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/bor/heimdall/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ retryLoop:

select {
case <-ctx.Done():
logger.Debug("Shutdown detected, terminating request by context.Done")
logger.Debug("Shutdown detected, terminating request", "err", ctx.Err())

return nil, ctx.Err()
case <-closeCh:
Expand Down
15 changes: 8 additions & 7 deletions eth/stagedsync/stage_bor_heimdall.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func BorHeimdallForward(
fetchTime += callTime
}

if err = PersistValidatorSets(u, ctx, tx, cfg.blockReader, cfg.chainConfig.Bor, chain, blockNum, header.Hash(), recents, signatures, cfg.snapDb, logger); err != nil {
if err = PersistValidatorSets(u, ctx, tx, cfg.blockReader, cfg.chainConfig.Bor, chain, blockNum, header.Hash(), recents, signatures, cfg.snapDb, logger, s.LogPrefix()); err != nil {
return fmt.Errorf("persistValidatorSets: %w", err)
}
if !mine && header != nil {
Expand Down Expand Up @@ -497,7 +497,8 @@ func PersistValidatorSets(
recents *lru.ARCCache[libcommon.Hash, *bor.Snapshot],
signatures *lru.ARCCache[libcommon.Hash, libcommon.Address],
snapDb kv.RwDB,
logger log.Logger) error {
logger log.Logger,
logPrefix string) error {

logEvery := time.NewTicker(logInterval)
defer logEvery.Stop()
Expand Down Expand Up @@ -559,7 +560,7 @@ func PersistValidatorSets(

select {
case <-logEvery.C:
logger.Info("Gathering headers for validator proposer prorities (backwards)", "blockNum", blockNum)
logger.Info(fmt.Sprintf("[%s] Gathering headers for validator proposer prorities (backwards)", logPrefix), "blockNum", blockNum)
default:
}
}
Expand All @@ -585,7 +586,7 @@ func PersistValidatorSets(
if err := snap.Store(snapDb); err != nil {
return fmt.Errorf("snap.Store (0): %w", err)
}
logger.Info("Stored proposer snapshot to disk", "number", 0, "hash", hash)
logger.Info(fmt.Sprintf("[%s] Stored proposer snapshot to disk", logPrefix), "number", 0, "hash", hash)
g := errgroup.Group{}
g.SetLimit(estimate.AlmostAllCPUs())
defer g.Wait()
Expand All @@ -608,7 +609,7 @@ func PersistValidatorSets(
})
}
if header == nil {
log.Debug("[bor] PersistValidatorSets nil header", "blockNum", i)
log.Debug(fmt.Sprintf("[%s] PersistValidatorSets nil header", logPrefix), "blockNum", i)
}
initialHeaders = append(initialHeaders, header)
if len(initialHeaders) == cap(initialHeaders) {
Expand All @@ -620,7 +621,7 @@ func PersistValidatorSets(
}
select {
case <-logEvery.C:
logger.Info("Computing validator proposer prorities (forward)", "blockNum", i)
logger.Info(fmt.Sprintf("[%s] Computing validator proposer prorities (forward)", logPrefix), "blockNum", i)
default:
}
}
Expand Down Expand Up @@ -666,7 +667,7 @@ func PersistValidatorSets(
return fmt.Errorf("snap.Store: %w", err)
}

logger.Info("Stored proposer snapshot to disk", "number", snap.Number, "hash", snap.Hash)
logger.Info(fmt.Sprintf("[%s] Stored proposer snapshot to disk", logPrefix), "number", snap.Number, "hash", snap.Hash)
}

return nil
Expand Down
Loading