Skip to content

Commit

Permalink
feat(validator): add nil machine claim error
Browse files Browse the repository at this point in the history
All epochs have at least one input. If an input has no outputs, then Input.OutputsHash equals the last input OutputsHash. If it is the first input and it has no outputs, its OutputsHash is the application's template hash. Therefore, if this value is nil the node is in an inconsistent state.
  • Loading branch information
torives committed Sep 4, 2024
1 parent 47b5b21 commit b1e9aa5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,15 @@ func (v *Validator) validateApplication(ctx context.Context, app Application) er
)
}

if machineClaim == nil {
return fmt.Errorf(
"inconsistent state: machine claim for epoch %v of application %v was not found",
epoch.Index, epoch.AppAddress,
)
}

// ...and compare it to the hash calculated by the Validator
if machineClaim != nil && *machineClaim != *claim {
if *machineClaim != *claim {
return fmt.Errorf(
"validator claim does not match machine claim for epoch %v of application %v",
epoch.Index, epoch.AppAddress,
Expand Down

0 comments on commit b1e9aa5

Please sign in to comment.