From baf30ae6bc38f4f8eab0222dcc53bde14bb63b18 Mon Sep 17 00:00:00 2001 From: Yarom Swisa Date: Thu, 16 Feb 2023 16:03:09 +0000 Subject: [PATCH] add validation to the spec parameters --- x/spec/types/spec.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/x/spec/types/spec.go b/x/spec/types/spec.go index 297072f56c..87ea9d8a52 100644 --- a/x/spec/types/spec.go +++ b/x/spec/types/spec.go @@ -3,6 +3,8 @@ package types import ( fmt "fmt" "strconv" + + epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" ) const minCU = 1 @@ -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