diff --git a/x/ccv/provider/client/proposal_handler.go b/x/ccv/provider/client/proposal_handler.go index 32c62df460..1bfb21ea40 100644 --- a/x/ccv/provider/client/proposal_handler.go +++ b/x/ccv/provider/client/proposal_handler.go @@ -1,6 +1,7 @@ package client import ( + "context" "encoding/json" "fmt" "net/http" @@ -15,6 +16,7 @@ import ( govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" "github.com/cosmos/interchain-security/x/ccv/provider/types" "github.com/spf13/cobra" @@ -74,6 +76,9 @@ Where proposal.json contains: return err } + // do not fail for errors regarding the unbonding period, but just log a warning + CheckPropUnbondingPeriod(clientCtx, proposal.UnbondingPeriod) + content := types.NewConsumerAdditionProposal( proposal.Title, proposal.Description, proposal.ChainId, proposal.InitialHeight, proposal.GenesisHash, proposal.BinaryHash, proposal.SpawnTime, @@ -441,3 +446,25 @@ func postEquivocationProposalHandlerFn(clientCtx client.Context) http.HandlerFun tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg) } } + +func CheckPropUnbondingPeriod(clientCtx client.Context, propUnbondingPeriod time.Duration) { + queryClient := stakingtypes.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &stakingtypes.QueryParamsRequest{}) + if err != nil { + fmt.Println(err.Error()) + return + } + + providerUnbondingTime := res.Params.UnbondingTime + + if providerUnbondingTime < propUnbondingPeriod { + fmt.Printf( + `consumer unbonding period is advised to be smaller than provider unbonding period, but is longer. +This is not a security risk, but will effectively lengthen the unbonding period on the provider. +consumer unbonding: %s +provider unbonding: %s`, + propUnbondingPeriod, + providerUnbondingTime) + } +}