From a89b95ac8f96c5a471e4ebbe4b515a97cbca1c7e Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Wed, 20 Dec 2023 21:44:06 +0100 Subject: [PATCH] imp(statemachine)!: if the allow all host messages wildcard is used, then the allow list should have only one element (#5461) Co-authored-by: DimitrisJim --- modules/apps/27-interchain-accounts/host/types/params.go | 5 +++++ .../apps/27-interchain-accounts/host/types/params_test.go | 1 + 2 files changed, 6 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/types/params.go b/modules/apps/27-interchain-accounts/host/types/params.go index 1da41757819..5c47fe65487 100644 --- a/modules/apps/27-interchain-accounts/host/types/params.go +++ b/modules/apps/27-interchain-accounts/host/types/params.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "slices" "strings" ) @@ -29,6 +30,10 @@ func (p Params) Validate() error { } func validateAllowlist(allowMsgs []string) error { + if slices.Contains(allowMsgs, AllowAllHostMsgs) && len(allowMsgs) > 1 { + return fmt.Errorf("allow list must have only one element because the allow all host messages wildcard (%s) is present", AllowAllHostMsgs) + } + for _, typeURL := range allowMsgs { if strings.TrimSpace(typeURL) == "" { return fmt.Errorf("parameter must not contain empty strings: %s", allowMsgs) diff --git a/modules/apps/27-interchain-accounts/host/types/params_test.go b/modules/apps/27-interchain-accounts/host/types/params_test.go index 33b0ff77c43..9cd7b46bc45 100644 --- a/modules/apps/27-interchain-accounts/host/types/params_test.go +++ b/modules/apps/27-interchain-accounts/host/types/params_test.go @@ -13,4 +13,5 @@ func TestValidateParams(t *testing.T) { require.NoError(t, types.NewParams(false, []string{}).Validate()) require.Error(t, types.NewParams(true, []string{""}).Validate()) require.Error(t, types.NewParams(true, []string{" "}).Validate()) + require.Error(t, types.NewParams(true, []string{"*", "/cosmos.bank.v1beta1.MsgSend"}).Validate()) }