From 8b563e75dbbb3fdca4e6310a01fa0376619a17e0 Mon Sep 17 00:00:00 2001 From: oren-lava Date: Sun, 7 May 2023 17:30:24 +0300 Subject: [PATCH] CNS-261: added check in spec proposal handler that spec name can only have lowercase chars or ' ' --- x/spec/types/spec.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/x/spec/types/spec.go b/x/spec/types/spec.go index 396ee88c6f..f38ea9ea6e 100644 --- a/x/spec/types/spec.go +++ b/x/spec/types/spec.go @@ -3,6 +3,7 @@ package types import ( fmt "fmt" "strconv" + "unicode" epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" ) @@ -24,6 +25,12 @@ func (spec Spec) ValidateSpec(maxCU uint64) (map[string]string, error) { EncodingHex: {}, } + for _, char := range spec.Name { + if !unicode.IsLower(char) && char != ' ' { + return details, fmt.Errorf("spec name must contain lowercase characters only") + } + } + if spec.ReliabilityThreshold == 0 { return details, fmt.Errorf("ReliabilityThreshold can't be zero") } @@ -41,11 +48,11 @@ func (spec Spec) ValidateSpec(maxCU uint64) (map[string]string, error) { } if spec.MinStakeClient.Denom != epochstoragetypes.TokenDenom || spec.MinStakeClient.Amount.IsZero() { - return details, fmt.Errorf("MinStakeClient can't be zero andmust have denom of ulava") + return details, fmt.Errorf("MinStakeClient can't be zero and must 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") + return details, fmt.Errorf("MinStakeProvider can't be zero and must have denom of ulava") } for _, api := range spec.Apis {