diff --git a/pkg/coordinator/tasks/check_consensus_validator_status/README.md b/pkg/coordinator/tasks/check_consensus_validator_status/README.md index 9cfc0f3..9b616a7 100644 --- a/pkg/coordinator/tasks/check_consensus_validator_status/README.md +++ b/pkg/coordinator/tasks/check_consensus_validator_status/README.md @@ -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: diff --git a/pkg/coordinator/tasks/check_consensus_validator_status/config.go b/pkg/coordinator/tasks/check_consensus_validator_status/config.go index 040840e..b8e4d0d 100644 --- a/pkg/coordinator/tasks/check_consensus_validator_status/config.go +++ b/pkg/coordinator/tasks/check_consensus_validator_status/config.go @@ -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 { diff --git a/pkg/coordinator/tasks/check_consensus_validator_status/task.go b/pkg/coordinator/tasks/check_consensus_validator_status/task.go index 621219f..d009e19 100644 --- a/pkg/coordinator/tasks/check_consensus_validator_status/task.go +++ b/pkg/coordinator/tasks/check_consensus_validator_status/task.go @@ -3,6 +3,7 @@ package checkconsensusvalidatorstatus import ( "bytes" "context" + "encoding/json" "fmt" "regexp" "time" @@ -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