Skip to content

Commit

Permalink
feat: ScheduleUpgradeNoHeightValidation for automated upgrades w/o …
Browse files Browse the repository at this point in the history
…gov proposal (backport cosmos#11551) (cosmos#11574)

* feat: `ScheduleUpgradeNoHeightValidation` for automated upgrades w/o gov proposal (cosmos#11551)

## Description

Implements a `ScheduleUpgradeNoHeightValidation` function for chains to schedule an automated upgrade (using the `x/upgrade` module) without having to go through a governance proposal.

This is beneficial to coordinate upgrades without having to manually download the new version, do the migration and restart the chain.

This is the procedure Evmos used for its automated upgrade.

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

(cherry picked from commit 5b02bf4)

# Conflicts:
#	CHANGELOG.md
#	x/upgrade/abci_test.go
#	x/upgrade/keeper/keeper.go

* fix conflicts

* changelog

* fix test

Co-authored-by: Federico Kunze Küllmer <[email protected]>
Co-authored-by: Federico Kunze Küllmer <[email protected]>
  • Loading branch information
3 people authored and JeancarloBarrios committed Sep 28, 2024
1 parent 5014c41 commit 6a28cf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions x/upgrade/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6a28cf4

Please sign in to comment.