Skip to content

Commit

Permalink
fix: clean upgrade plan after all plans are executed
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 committed Jan 3, 2023
1 parent db38442 commit 1457f2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 6 additions & 1 deletion x/upgrade/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func BeginBlocker(k keeper.Keeper, ctx sdk.Context, _ abci.RequestBeginBlock) {
logger := ctx.Logger()

// To make sure clear upgrade is executed at the same block
executed := false
for _, plan := range plans {
if plan.ShouldExecute(ctx) {
// If skip upgrade has been set for current height, we clear the upgrade plan
Expand All @@ -47,9 +48,13 @@ func BeginBlocker(k keeper.Keeper, ctx sdk.Context, _ abci.RequestBeginBlock) {
ctx.Logger().Info(fmt.Sprintf("applying upgrade \"%s\" at %s", plan.Name, plan.DueAt()))
ctx = ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())
k.ApplyUpgrade(ctx, *plan)
return
executed = true
}
}
if executed {
k.ClearIBCState(ctx, ctx.BlockHeight())
k.ClearUpgradePlan(ctx)
}
}

// BuildUpgradeNeededMsg prints the message that notifies that an upgrade is needed.
Expand Down
2 changes: 0 additions & 2 deletions x/upgrade/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,6 @@ func (k Keeper) ApplyUpgrade(ctx sdk.Context, plan types.Plan) {

// Must clear IBC state after upgrade is applied as it is stored separately from the upgrade plan.
// This will prevent resubmission of upgrade msg after upgrade is already completed.
k.ClearIBCState(ctx, plan.Height)
k.ClearUpgradePlan(ctx)
k.setDone(ctx, plan.Name)
}

Expand Down

0 comments on commit 1457f2c

Please sign in to comment.