Skip to content

Commit

Permalink
CNS-261: added check in spec proposal handler that spec name can only…
Browse files Browse the repository at this point in the history
… have lowercase chars or ' '
  • Loading branch information
oren-lava committed May 7, 2023
1 parent 8c0287a commit 8b563e7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions x/spec/types/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
fmt "fmt"
"strconv"
"unicode"

epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types"
)
Expand All @@ -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")
}
Expand All @@ -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 {
Expand Down

0 comments on commit 8b563e7

Please sign in to comment.