Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for v16.0.4 #2460

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,9 +893,8 @@
// BeginBlocker will schedule the upgrade plan and perform the state migration (if any).
func (app *Evmos) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
// Perform any scheduled forks before executing the modules logic
//
// NOTE: there are no scheduled forks currently, uncomment when needed
// app.ScheduleForkUpgrade(ctx)

app.ScheduleForkUpgrade(ctx)

Check warning on line 897 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L896-L897

Added lines #L896 - L897 were not covered by tests

return app.mm.BeginBlock(ctx, req)
}
Expand Down
59 changes: 33 additions & 26 deletions app/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
package app

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
v17 "github.com/evmos/evmos/v16/app/upgrades/v17"
"github.com/evmos/evmos/v16/utils"
)

// ScheduleForkUpgrade executes any necessary fork logic for based upon the current
Expand All @@ -15,31 +20,33 @@
//
// 1. Release a non-breaking patch version so that the chain can set the scheduled upgrade plan at upgrade-height.
// 2. Release the software defined in the upgrade-info
func (app *Evmos) ScheduleForkUpgrade(_ sdk.Context) {
// NOTE: there are no scheduled forks at the moment
func (app *Evmos) ScheduleForkUpgrade(ctx sdk.Context) {
// Only fork on Mainnet
if !utils.IsMainnet(ctx.ChainID()) {
return
}
upgradePlan := upgradetypes.Plan{
Height: ctx.BlockHeight(),
}

// handle mainnet forks with their corresponding upgrade name and info
switch ctx.BlockHeight() {
case v17.MainnetUpgradeHeight:
upgradePlan.Name = v17.UpgradeName
upgradePlan.Info = v17.UpgradeInfo
default:
// No-op
return

Check warning on line 39 in app/forks.go

View check run for this annotation

Codecov / codecov/patch

app/forks.go#L23-L39

Added lines #L23 - L39 were not covered by tests
}

// upgradePlan := upgradetypes.Plan{
// Height: ctx.BlockHeight(),
// }
//
// // handle mainnet forks with their corresponding upgrade name and info
// switch ctx.BlockHeight() {
// case v16.TestnetUpgradeHeight:
// upgradePlan.Name = v16.UpgradeNameTestnetRC4
// upgradePlan.Info = v16.UpgradeInfo
// default:
// // No-op
// return
// }
//
// // schedule the upgrade plan to the current block hight, effectively performing
// // a hard fork that uses the upgrade handler to manage the migration.
// if err := app.UpgradeKeeper.ScheduleUpgrade(ctx, upgradePlan); err != nil {
// panic(
// fmt.Errorf(
// "failed to schedule upgrade %s during BeginBlock at height %d: %w",
// upgradePlan.Name, ctx.BlockHeight(), err,
// ),
// )
// }
// schedule the upgrade plan to the current block height, effectively performing
// a hard fork that uses the upgrade handler to manage the migration.
if err := app.UpgradeKeeper.ScheduleUpgrade(ctx, upgradePlan); err != nil {
panic(
fmt.Errorf(
"failed to schedule upgrade %s during BeginBlock at height %d: %w",
upgradePlan.Name, ctx.BlockHeight(), err,
),
)

Check warning on line 50 in app/forks.go

View check run for this annotation

Codecov / codecov/patch

app/forks.go#L44-L50

Added lines #L44 - L50 were not covered by tests
}
}
13 changes: 13 additions & 0 deletions app/upgrades/v17/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)

package v17

const (
// UpgradeName is the shared upgrade plan name for mainnet
UpgradeName = "v17.0.0"
// MainnetUpgradeHeight defines the Evmos mainnet block height on which the upgrade will take place
MainnetUpgradeHeight = 20_101_000
// UpgradeInfo defines the binaries that will be used for the upgrade
UpgradeInfo = `'{"binaries":{"darwin/amd64":"https://github.com/evmos/evmos/releases/download/v17.0.0/evmos_17.0.0_Darwin_arm64.tar.gz","darwin/x86_64":"https://github.com/evmos/evmos/releases/download/v17.0.0/evmos_17.0.0_Darwin_x86_64.tar.gz","linux/arm64":"https://github.com/evmos/evmos/releases/download/v17.0.0/evmos_17.0.0_Linux_arm64.tar.gz","linux/amd64":"https://github.com/evmos/evmos/releases/download/v17.0.0/evmos_17.0.0_Linux_amd64.tar.gz","windows/x86_64":"https://github.com/evmos/evmos/releases/download/v17.0.0/evmos_17.0.0_Windows_x86_64.zip"}}'`
)
21 changes: 21 additions & 0 deletions app/upgrades/v17/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)

package v17

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v17
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
// Leave modules as-is to avoid running InitGenesis.
return mm.RunMigrations(ctx, configurator, vm)
}
}