Skip to content

Commit

Permalink
Cherry-pick of cosmos#11551
Browse files Browse the repository at this point in the history
Allow ScheduleUpgrade to come from same block
  • Loading branch information
ValarDragon committed Jun 10, 2022
1 parent 51108b6 commit 72b82b1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions x/upgrade/keeper/keeper.go
Expand Up @@ -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")
}

Expand Down

0 comments on commit 72b82b1

Please sign in to comment.