Skip to content

Commit

Permalink
improve long running task logging
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Dec 19, 2023
1 parent bd0ec1b commit f52e36f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func (t *Task) Execute(ctx context.Context) error {
// start vote counting from next epoch as current epoch might be incomplete
lastCheckedEpoch := currentEpoch.Number()

t.logger.Infof("current epoch: %v, starting attestation aggregation at epoch %v", lastCheckedEpoch, lastCheckedEpoch+1)

t.attesterDutyMap = map[uint64]map[phase0.Root]*attesterDuties{}
defer func() {
t.attesterDutyMap = nil
Expand All @@ -139,7 +141,6 @@ func (t *Task) Execute(ctx context.Context) error {
break
}

t.logger.Infof("check epoch %v votes", checkEpoch)
t.runAttestationStatsCheck(ctx, checkEpoch)

lastCheckedEpoch = checkEpoch
Expand Down Expand Up @@ -253,6 +254,8 @@ func (t *Task) runAttestationStatsCheck(ctx context.Context, epoch uint64) {
}
}

t.logger.Infof("epoch %v attestation check result: %v. passed checks: %v, want: %v", epoch, result, t.passedEpochs, t.config.MinCheckedEpochs)

break
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/coordinator/tasks/check_consensus_finality/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@ func (t *Task) runFinalityCheck() bool {
unfinalizedEpochs := currentEpoch.Number() - uint64(finalizedEpoch)

if t.config.MinUnfinalizedEpochs > 0 && unfinalizedEpochs < t.config.MinUnfinalizedEpochs {
t.logger.Debugf("check failed: minUnfinalizedEpochs (have: %v, want >= %v)", unfinalizedEpochs, t.config.MinUnfinalizedEpochs)
t.logger.Infof("check failed: minUnfinalizedEpochs (have: %v, want >= %v)", unfinalizedEpochs, t.config.MinUnfinalizedEpochs)
return false
}

if t.config.MaxUnfinalizedEpochs > 0 && unfinalizedEpochs > t.config.MaxUnfinalizedEpochs {
t.logger.Debugf("check failed: maxUnfinalizedEpochs (have: %v, want <= %v)", unfinalizedEpochs, t.config.MaxUnfinalizedEpochs)
t.logger.Infof("check failed: maxUnfinalizedEpochs (have: %v, want <= %v)", unfinalizedEpochs, t.config.MaxUnfinalizedEpochs)
return false
}

if t.config.MinFinalizedEpochs > 0 && uint64(finalizedEpoch) < t.config.MinFinalizedEpochs {
t.logger.Debugf("check failed: minFinalizedEpochs (have: %v, want >= %v)", finalizedEpoch, t.config.MinFinalizedEpochs)
t.logger.Infof("check failed: minFinalizedEpochs (have: %v, want >= %v)", finalizedEpoch, t.config.MinFinalizedEpochs)
return false
}

Expand Down
9 changes: 7 additions & 2 deletions pkg/coordinator/tasks/check_consensus_reorgs/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ func (t *Task) Execute(ctx context.Context) error {

if t.config.MaxReorgDistance > 0 && t.maxReorgDistance > t.config.MaxReorgDistance {
t.ctx.SetResult(types.TaskResultFailure)
t.logger.Infof("task failed: max reorg distance (%v) exceeded, reorg distance around slot %v: %v", t.config.MaxReorgDistance, block.Slot, t.maxReorgDistance)

return fmt.Errorf("max reorg distance (%v) exceeded: %v -> %v (%v)", t.config.MaxReorgDistance, lastBlock.Root.String(), block.Root.String(), t.maxReorgDistance)
}

t.ctx.SetResult(t.runCheck())
}

t.ctx.SetResult(t.runCheck())

lastBlock = block
case <-ctx.Done():
return ctx.Err()
Expand All @@ -136,16 +138,19 @@ func (t *Task) runCheck() types.TaskResult {

_, currentEpoch, err := consensusPool.GetBlockCache().GetWallclock().Now()
if err != nil {
t.logger.Warnf("check missed: could not get current epoch from wall clock")
return types.TaskResultNone
}

epochCount := currentEpoch.Number() - t.startEpoch

if t.config.MinCheckEpochCount > 0 && epochCount < t.config.MinCheckEpochCount {
t.logger.Warnf("Check missed: checked %v epochs, but need >= %v", epochCount, t.config.MinCheckEpochCount)
return types.TaskResultNone
}

if t.config.MaxReorgsPerEpoch > 0 && epochCount > 0 && float64(t.totalReorgs)/float64(epochCount) > t.config.MaxReorgsPerEpoch {
t.logger.Warnf("check failed: max reorgs per epoch exceeded. (have: %v, want <= %v)", float64(t.totalReorgs)/float64(epochCount), t.config.MaxReorgsPerEpoch)
return types.TaskResultFailure
}

Expand Down

0 comments on commit f52e36f

Please sign in to comment.