Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Feb 14, 2024
1 parent cc762f3 commit 354342b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
32 changes: 20 additions & 12 deletions pkg/coordinator/tasks/check_consensus_validator_status/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,13 @@ func (t *Task) Execute(ctx context.Context) error {

// load current epoch duties
t.loadValidatorSet(ctx)
t.runCheck()

for {
select {
case <-wallclockEpochSubscription.Channel():
t.loadValidatorSet(ctx)

checkResult := t.runValidatorStatusCheck()

switch {
case checkResult:
t.ctx.SetResult(types.TaskResultSuccess)
case t.config.FailOnCheckMiss:
t.ctx.SetResult(types.TaskResultFailure)
default:
t.ctx.SetResult(types.TaskResultNone)
}
t.runCheck()
case <-ctx.Done():
return ctx.Err()
}
Expand All @@ -136,6 +127,22 @@ func (t *Task) loadValidatorSet(ctx context.Context) {
}
}

func (t *Task) runCheck() {
checkResult := t.runValidatorStatusCheck()

_, epoch, _ := t.ctx.Scheduler.GetServices().ClientPool().GetConsensusPool().GetBlockCache().GetWallclock().Now()
t.logger.Infof("epoch %v check result: %v", epoch.Number(), checkResult)

switch {
case checkResult:
t.ctx.SetResult(types.TaskResultSuccess)
case t.config.FailOnCheckMiss:
t.ctx.SetResult(types.TaskResultFailure)
default:
t.ctx.SetResult(types.TaskResultNone)
}
}

func (t *Task) runValidatorStatusCheck() bool {
if t.currentValidatorSet == nil {
t.logger.Errorf("check failed: no validator set")
Expand All @@ -147,7 +154,6 @@ func (t *Task) runValidatorStatusCheck() bool {
for {
validator := t.currentValidatorSet[currentIndex]
if validator == nil {
t.logger.Errorf("check failed: no matching validator found")
return false
}

Expand Down Expand Up @@ -175,11 +181,13 @@ func (t *Task) runValidatorStatusCheck() bool {
pubkey := common.FromHex(t.config.ValidatorPubKey)

if !bytes.Equal(pubkey, validator.Validator.PublicKey[:]) {
t.logger.Infof("check failed: no matching validator found")
continue
}
}

// found a matching validator
t.logger.Infof("validator found: index %v, status: %v", validator.Index, validator.Status.String())

if t.config.ValidatorInfoResultVar != "" {
validatorJSON, err := json.Marshal(validator)
Expand Down
8 changes: 6 additions & 2 deletions pkg/coordinator/tasks/generate_exits/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (t *Task) Execute(ctx context.Context) error {

err := t.generateVoluntaryExit(ctx, accountIdx, fork, validators)
if err != nil {
t.logger.Errorf("error generating voluntary exit: %v", err.Error())
t.logger.Errorf("error generating voluntary exit for index %v: %v", accountIdx, err.Error())
} else {
t.ctx.SetResult(types.TaskResultSuccess)

Expand Down Expand Up @@ -161,6 +161,10 @@ func (t *Task) Execute(ctx context.Context) error {
}
}

if totalCount == 0 {
t.ctx.SetResult(types.TaskResultFailure)
}

return nil
}

Expand Down Expand Up @@ -201,7 +205,7 @@ func (t *Task) generateVoluntaryExit(ctx context.Context, accountIdx uint64, for

// check validator status
if validator == nil {
return fmt.Errorf("validator not found")
return fmt.Errorf("validator not found: 0x%x", validatorPubkey)
}

if validator.Validator.ExitEpoch != 18446744073709551615 {
Expand Down

0 comments on commit 354342b

Please sign in to comment.