Skip to content

Commit

Permalink
basic upgrade handler for v23
Browse files Browse the repository at this point in the history
  • Loading branch information
dimiandre committed Jul 5, 2024
1 parent 386f90b commit c17202b
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 3 deletions.
7 changes: 6 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ import (
testnetV19alpha3 "github.com/CosmosContracts/juno/v23/app/upgrades/testnet/v19.0.0-alpha.3"
testnetV21alpha1 "github.com/CosmosContracts/juno/v23/app/upgrades/testnet/v21.0.0-alpha.1"
testnetV22alpha1 "github.com/CosmosContracts/juno/v23/app/upgrades/testnet/v22.0.0-alpha.1"
testnetV23alpha1 "github.com/CosmosContracts/juno/v23/app/upgrades/testnet/v23.0.0-alpha.1"

Check failure on line 77 in app/app.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
v10 "github.com/CosmosContracts/juno/v23/app/upgrades/v10"
v11 "github.com/CosmosContracts/juno/v23/app/upgrades/v11"
v12 "github.com/CosmosContracts/juno/v23/app/upgrades/v12"
Expand All @@ -85,6 +87,7 @@ import (
v19 "github.com/CosmosContracts/juno/v23/app/upgrades/v19"
v21 "github.com/CosmosContracts/juno/v23/app/upgrades/v21"
v22 "github.com/CosmosContracts/juno/v23/app/upgrades/v22"
v23 "github.com/CosmosContracts/juno/v23/app/upgrades/v23"
"github.com/CosmosContracts/juno/v23/docs"
)

Expand Down Expand Up @@ -114,7 +117,8 @@ var (
testnetV19alpha3.Upgrade,
testnetV21alpha1.Upgrade,
testnetV22alpha1.Upgrade,

testnetV23alpha1.Upgrade,

Check failure on line 121 in app/app.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
v10.Upgrade,
v11.Upgrade,
v12.Upgrade,
Expand All @@ -127,6 +131,7 @@ var (
v19.Upgrade,
v21.Upgrade,
v22.Upgrade,
v23.Upgrade,
}
)

Expand Down
51 changes: 51 additions & 0 deletions app/upgrades/testnet/v23.0.0-alpha.1/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package v23

import (
"fmt"

Check failure on line 5 in app/upgrades/testnet/v23.0.0-alpha.1/constants.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"

Check failure on line 10 in app/upgrades/testnet/v23.0.0-alpha.1/constants.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)

"github.com/CosmosContracts/juno/v23/app/keepers"
"github.com/CosmosContracts/juno/v23/app/upgrades"
)

// UpgradeName defines the on-chain upgrade name for the upgrade.
const UpgradeName = "v2300alpha1"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: v2300Alpha1UpgradeHandler,
StoreUpgrades: store.StoreUpgrades{

Check failure on line 22 in app/upgrades/testnet/v23.0.0-alpha.1/constants.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
Added: []string{
// updated modules
icqtypes.ModuleName,
},
},
}

func v2300Alpha1UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
_ *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)

nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
logger.Info(fmt.Sprintf("With native denom %s", nativeDenom))

// Run migrations
logger.Info(fmt.Sprintf("pre migrate version map: %v", vm))
versionMap, err := mm.RunMigrations(ctx, cfg, vm)
if err != nil {
return nil, err
}
logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap))

return versionMap, err
}
}
40 changes: 40 additions & 0 deletions app/upgrades/testnet/v23.0.0-alpha.1/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v23_test

import (
"testing"

"github.com/stretchr/testify/suite"

"github.com/CosmosContracts/juno/v23/app/apptesting"
v23alpha1 "github.com/CosmosContracts/juno/v23/app/upgrades/testnet/v22.0.0-alpha.1"
)

type UpgradeTestSuite struct {
apptesting.KeeperTestHelper
}

func (s *UpgradeTestSuite) SetupTest() {
s.Setup()
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(UpgradeTestSuite))
}

// Ensures the test does not error out.
func (s *UpgradeTestSuite) TestUpgrade() {
s.Setup()

preUpgradeChecks(s)

upgradeHeight := int64(5)
s.ConfirmUpgradeSucceeded(v23alpha1.UpgradeName, upgradeHeight)

postUpgradeChecks(s)
}

func preUpgradeChecks(_ *UpgradeTestSuite) {
}

func postUpgradeChecks(_ *UpgradeTestSuite) {
}
22 changes: 22 additions & 0 deletions app/upgrades/v23/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package v23

import (
store "github.com/cosmos/cosmos-sdk/store/types"

Check failure on line 4 in app/upgrades/v23/constants.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"

Check failure on line 6 in app/upgrades/v23/constants.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
"github.com/CosmosContracts/juno/v23/app/upgrades"
)

// UpgradeName defines the on-chain upgrade name for the upgrade.
const UpgradeName = "v23"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateV23UpgradeHandler,
StoreUpgrades: store.StoreUpgrades{

Check failure on line 16 in app/upgrades/v23/constants.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
Added: []string{
// updated modules
icqtypes.ModuleName,
},
},
}
39 changes: 39 additions & 0 deletions app/upgrades/v23/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package v23_test

import (
"testing"

"github.com/stretchr/testify/suite"

"github.com/CosmosContracts/juno/v23/app/apptesting"
v23 "github.com/CosmosContracts/juno/v23/app/upgrades/v23"
)

type UpgradeTestSuite struct {
apptesting.KeeperTestHelper
}

func (s *UpgradeTestSuite) SetupTest() {
s.Setup()
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(UpgradeTestSuite))
}

// Ensures the test does not error out.
func (s *UpgradeTestSuite) TestUpgrade() {
s.Setup()
preUpgradeChecks(s)

upgradeHeight := int64(5)
s.ConfirmUpgradeSucceeded(v23.UpgradeName, upgradeHeight)

postUpgradeChecks(s)
}

func preUpgradeChecks(_ *UpgradeTestSuite) {
}

func postUpgradeChecks(_ *UpgradeTestSuite) {
}
35 changes: 35 additions & 0 deletions app/upgrades/v23/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package v23

import (
"fmt"

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

"github.com/CosmosContracts/juno/v23/app/keepers"
"github.com/CosmosContracts/juno/v23/app/upgrades"
)

func CreateV23UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
_ *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)

nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
logger.Info(fmt.Sprintf("With native denom %s", nativeDenom))

// Run migrations
logger.Info(fmt.Sprintf("pre migrate version map: %v", vm))
versionMap, err := mm.RunMigrations(ctx, cfg, vm)
if err != nil {
return nil, err
}
logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap))

return versionMap, err
}
}
4 changes: 2 additions & 2 deletions interchaintest/chain_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

const (
chainName = "juno"
upgradeName = "v21"
upgradeName = "v23"

haltHeightDelta = int64(9) // will propose upgrade this many blocks in the future
blocksAfterUpgrade = int64(7)
Expand All @@ -34,7 +34,7 @@ var (
// baseChain is the current version of the chain that will be upgraded from
baseChain = ibc.DockerImage{
Repository: JunoMainRepo,
Version: "v20.0.0",
Version: "v22.0.1",
UidGid: "1025:1025",
}
)
Expand Down

0 comments on commit c17202b

Please sign in to comment.