Skip to content

Commit

Permalink
fix(upgrade): clock params (#952)
Browse files Browse the repository at this point in the history
* fix(clock): v19 params set 250k gas

* backport to mainnet v19

* lintorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
  • Loading branch information
Reecepbcups authored Jan 26, 2024
1 parent fadec0a commit 7e50425
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
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

0 comments on commit 7e50425

Please sign in to comment.