From 5a4b6d80a7ef9e217db280a233448b700976ecc9 Mon Sep 17 00:00:00 2001 From: mpoke Date: Thu, 30 Nov 2023 12:52:32 +0100 Subject: [PATCH] nit: validate MsgAssignConsumerKey --- x/ccv/provider/types/errors.go | 2 +- x/ccv/provider/types/msg.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index 66d7a9a3b8..6c19a7b396 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -11,7 +11,7 @@ var ( ErrUnknownConsumerChainId = errorsmod.Register(ModuleName, 3, "no consumer chain with this chain id") ErrUnknownConsumerChannelId = errorsmod.Register(ModuleName, 4, "no consumer chain with this channel id") ErrInvalidConsumerConsensusPubKey = errorsmod.Register(ModuleName, 5, "empty consumer consensus public key") - ErrBlankConsumerChainID = errorsmod.Register(ModuleName, 6, "consumer chain id must not be blank") + ErrInvalidConsumerChainID = errorsmod.Register(ModuleName, 6, "invalid consumer chain id") ErrConsumerKeyNotFound = errorsmod.Register(ModuleName, 7, "consumer key not found") ErrNoValidatorConsumerAddress = errorsmod.Register(ModuleName, 8, "error getting validator consumer address") ErrNoValidatorProviderAddress = errorsmod.Register(ModuleName, 9, "error getting validator provider address") diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index f7ee11325c..73fb7f5b74 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -72,14 +72,13 @@ func (msg MsgAssignConsumerKey) GetSignBytes() []byte { // ValidateBasic implements the sdk.Msg interface. func (msg MsgAssignConsumerKey) ValidateBasic() error { if strings.TrimSpace(msg.ChainId) == "" { - return ErrBlankConsumerChainID + return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot be blank") } // It is possible to assign keys for consumer chains that are not yet approved. // This can only be done by a signing validator, but it is still sensible // to limit the chainID size to prevent abuse. - if 128 < len(msg.ChainId) { - return ErrBlankConsumerChainID + return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot exceed 128 length") } _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) if err != nil {