diff --git a/CHANGELOG.md b/CHANGELOG.md index c74cc5a2a19d..7f2e8885ab10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Features + +* (x/upgrade) [\#11551](https://github.com/cosmos/cosmos-sdk/pull/11551) Update `ScheduleUpgrade` for chains to schedule an automated upgrade on `BeginBlock` without having to go though governance. + ## [v0.45.2](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.2) - 2022-04-05 ### Features diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index 9420cf968273..f20b6ad5c355 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -196,13 +196,8 @@ func (k Keeper) ScheduleUpgrade(ctx context.Context, plan types.Plan) error { // NOTE: allow for the possibility of chains to schedule upgrades in begin block of the same block // as a strategy for emergency hard fork recoveries - if plan.Height < k.HeaderService.HeaderInfo(ctx).Height { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "upgrade cannot be scheduled in the past") - } - - doneHeight, err := k.GetDoneHeight(ctx, plan.Name) - if err != nil { - return err + if plan.Height < ctx.BlockHeight() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "upgrade cannot be scheduled in the past") } if doneHeight != 0 { @@ -512,7 +507,7 @@ func (k Keeper) DumpUpgradeInfoWithInfoToDisk(height int64, name string, info st return err } - return ioutil.WriteFile(upgradeInfoFilePath, bz, 0600) + return os.WriteFile(upgradeInfoFilePath, bz, 0o600) } // GetUpgradeInfoPath returns the upgrade info file path