diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index 4bc8590eeeb9..3c9689aad2b7 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -529,6 +529,10 @@ func (k Keeper) ReadUpgradeInfoFromDisk() (types.Plan, error) { return upgradeInfo, err } + if err := upgradeInfo.ValidateBasic(); err != nil { + return upgradeInfo, err + } + return upgradeInfo, nil } diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index 2979e75e7e01..ec7a882e0d5c 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -99,6 +99,12 @@ func (s *KeeperTestSuite) TestReadUpgradeInfoFromDisk() { s.Require().NoError(err) expected.Height = 101 s.Require().Equal(expected, ui) + + // create invalid upgrade plan (with empty name) + expected.Name = "" + s.Require().NoError(s.upgradeKeeper.DumpUpgradeInfoToDisk(101, expected)) + _, err = s.upgradeKeeper.ReadUpgradeInfoFromDisk() + s.Require().ErrorContains(err, "name cannot be empty: invalid request") } func (s *KeeperTestSuite) TestScheduleUpgrade() { diff --git a/x/upgrade/keeper/msg_server.go b/x/upgrade/keeper/msg_server.go index 9cb82563248d..bd447a8cce7e 100644 --- a/x/upgrade/keeper/msg_server.go +++ b/x/upgrade/keeper/msg_server.go @@ -32,10 +32,6 @@ func (k msgServer) SoftwareUpgrade(ctx context.Context, msg *types.MsgSoftwareUp return nil, errors.Wrapf(types.ErrInvalidSigner, "expected %s got %s", k.authority, msg.Authority) } - if err := msg.Plan.ValidateBasic(); err != nil { - return nil, errors.Wrap(err, "plan") - } - err := k.ScheduleUpgrade(ctx, msg.Plan) if err != nil { return nil, err