Skip to content

Commit

Permalink
added result var for check_consensus_validator_status task
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Feb 12, 2024
1 parent 6950ed3 commit 84e44d8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ The `check_consensus_validator_status` task is focused on verifying the status o
- **`failOnCheckMiss`**:\
Determines the task's behavior if the validator's status does not match any of the statuses in `validatorStatus`. If `false`, the task will continue running and wait for the validator to match the expected status. If `true`, the task will fail immediately upon a status mismatch.

- **`validatorInfoResultVar`**:\
The name of the variable where the resulting information about the validator will be stored. This includes status, index, balance and any other relevant data fetched during the check.

### Defaults

These are the default settings for the `check_consensus_validator_status` task:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ type Config struct {
ValidatorIndex *uint64 `yaml:"validatorIndex" json:"validatorIndex"`
ValidatorStatus []string `yaml:"validatorStatus" json:"validatorStatus"`
FailOnCheckMiss bool `yaml:"failOnCheckMiss" json:"failOnCheckMiss"`

ValidatorInfoResultVar string `yaml:"validatorInfoResultVar" json:"validatorInfoResultVar"`
}

func DefaultConfig() Config {
Expand Down
19 changes: 19 additions & 0 deletions pkg/coordinator/tasks/check_consensus_validator_status/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package checkconsensusvalidatorstatus
import (
"bytes"
"context"
"encoding/json"
"fmt"
"regexp"
"time"
Expand Down Expand Up @@ -178,6 +179,24 @@ func (t *Task) runValidatorStatusCheck() bool {
}
}

// found a matching validator

if t.config.ValidatorInfoResultVar != "" {
validatorJSON, err := json.Marshal(validator)
if err == nil {
validatorMap := map[string]interface{}{}
err = json.Unmarshal(validatorJSON, &validatorMap)

if err == nil {
t.ctx.Vars.SetVar(t.config.ValidatorInfoResultVar, validatorMap)
} else {
t.logger.Errorf("could not unmarshal validator info for result var: %v", err)
}
} else {
t.logger.Errorf("could not marshal validator info for result var: %v", err)
}
}

if len(t.config.ValidatorStatus) > 0 {
found := false

Expand Down

0 comments on commit 84e44d8

Please sign in to comment.