Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add validation to the spec parameters #304

Merged
merged 1 commit into from
Feb 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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