From 72b82b1aa7afa6b57434aeca85bdc606b4a80401 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Thu, 9 Jun 2022 18:31:07 -0500 Subject: [PATCH] Cherry-pick of https://github.com/cosmos/cosmos-sdk/pull/11551 Allow ScheduleUpgrade to come from same block --- x/upgrade/keeper/keeper.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index a9d6e59081af..20abc1ef10ed 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -145,14 +145,16 @@ func (k Keeper) getModuleVersion(ctx sdk.Context, name string) (uint64, bool) { // ScheduleUpgrade schedules an upgrade based on the specified plan. // If there is another Plan already scheduled, it will overwrite it // (implicitly cancelling the current plan) -// ScheduleUpgrade will also write the upgraded client to the upgraded client path -// if an upgraded client is specified in the plan +// ScheduleUpgrade will also write the upgraded IBC ClientState to the upgraded client +// path if it is specified in the plan. func (k Keeper) ScheduleUpgrade(ctx sdk.Context, plan types.Plan) error { if err := plan.ValidateBasic(); err != nil { return err } - if plan.Height <= ctx.BlockHeight() { + // 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 < ctx.BlockHeight() { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "upgrade cannot be scheduled in the past") }