Skip to content

Commit

Permalink
add validation to the spec parameters (#304)
Browse files Browse the repository at this point in the history
Co-authored-by: Yarom Swisa <yarom@lavanet.xyz git config --global user.name Yarom>
  • Loading branch information
Yaroms and Yarom Swisa authored Feb 19, 2023
1 parent 13c24ee commit e14d322
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions x/spec/types/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package types
import (
fmt "fmt"
"strconv"

epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types"
)

const minCU = 1
Expand All @@ -18,6 +20,30 @@ func (spec Spec) ValidateSpec(maxCU uint64) (map[string]string, error) {
APIInterfaceGrpc: {},
}

if spec.ReliabilityThreshold == 0 {
return details, fmt.Errorf("ReliabilityThreshold can't be zero")
}

if spec.BlocksInFinalizationProof == 0 {
return details, fmt.Errorf("BlocksInFinalizationProof can't be zero")
}

if spec.AverageBlockTime <= 0 {
return details, fmt.Errorf("AverageBlockTime can't be zero")
}

if spec.AllowedBlockLagForQosSync <= 0 {
return details, fmt.Errorf("AllowedBlockLagForQosSync can't be zero")
}

if spec.MinStakeClient.Denom != epochstoragetypes.TokenDenom || spec.MinStakeClient.Amount.IsZero() {
return details, fmt.Errorf("MinStakeClient can't be zero andmust have denom of ulava")
}

if spec.MinStakeProvider.Denom != epochstoragetypes.TokenDenom || spec.MinStakeProvider.Amount.IsZero() {
return details, fmt.Errorf("MinStakeProvider can't be zero andmust have denom of ulava")
}

for _, api := range spec.Apis {
if api.ComputeUnits < minCU || api.ComputeUnits > maxCU {
details["api"] = api.Name
Expand Down

0 comments on commit e14d322

Please sign in to comment.