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

fix(upgrade): clock params #952

Merged
merged 3 commits into from
Jan 26, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import (
testnetV18alpha2 "github.com/CosmosContracts/juno/v19/app/upgrades/testnet/v18.0.0-alpha.2"
testnetV18alpha3 "github.com/CosmosContracts/juno/v19/app/upgrades/testnet/v18.0.0-alpha.3"
testnetV18alpha4 "github.com/CosmosContracts/juno/v19/app/upgrades/testnet/v18.0.0-alpha.4"
testnetV19alpha2 "github.com/CosmosContracts/juno/v19/app/upgrades/testnet/v19.0.0-alpha.2"
v10 "github.com/CosmosContracts/juno/v19/app/upgrades/v10"
v11 "github.com/CosmosContracts/juno/v19/app/upgrades/v11"
v12 "github.com/CosmosContracts/juno/v19/app/upgrades/v12"
Expand Down Expand Up @@ -106,6 +107,7 @@ var (
testnetV18alpha2.Upgrade,
testnetV18alpha3.Upgrade,
testnetV18alpha4.Upgrade,
testnetV19alpha2.Upgrade,

v10.Upgrade,
v11.Upgrade,
Expand Down
48 changes: 48 additions & 0 deletions app/upgrades/testnet/v19.0.0-alpha.2/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package v18

import (
"fmt"

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"

"github.com/CosmosContracts/juno/v19/app/keepers"
"github.com/CosmosContracts/juno/v19/app/upgrades"
clocktypes "github.com/CosmosContracts/juno/v19/x/clock/types"
)

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

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

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

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))

if err := k.ClockKeeper.SetParams(ctx, clocktypes.Params{
ContractGasLimit: 250_000,
}); err != nil {
return nil, err
}

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

import (
"testing"

"github.com/stretchr/testify/suite"

"github.com/CosmosContracts/juno/v19/app/apptesting"
v19alpha2 "github.com/CosmosContracts/juno/v19/app/upgrades/testnet/v19.0.0-alpha.2"
)

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(v19alpha2.UpgradeName, upgradeHeight)

postUpgradeChecks(s)
}

func preUpgradeChecks(_ *UpgradeTestSuite) {
}

func postUpgradeChecks(_ *UpgradeTestSuite) {
}
7 changes: 7 additions & 0 deletions app/upgrades/v19/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
decorators "github.com/CosmosContracts/juno/v19/app/decorators"
"github.com/CosmosContracts/juno/v19/app/keepers"
"github.com/CosmosContracts/juno/v19/app/upgrades"
clocktypes "github.com/CosmosContracts/juno/v19/x/clock/types"
)

func CreateV19UpgradeHandler(
Expand Down Expand Up @@ -58,6 +59,12 @@ func CreateV19UpgradeHandler(
params.AllowedClients = append(params.AllowedClients, wasmlctypes.Wasm)
k.IBCKeeper.ClientKeeper.SetParams(ctx, params)

if err := k.ClockKeeper.SetParams(ctx, clocktypes.Params{
ContractGasLimit: 250_000,
}); err != nil {
return nil, err
}

return versionMap, err
}
}
Expand Down
Loading