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

upgrade handler for v23 #1032

Merged
merged 12 commits into from
Jul 9, 2024
15 changes: 15 additions & 0 deletions .github/workflows/interchaintest-E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,19 @@ jobs:
docker image ls -a

- name: Run Test
id: run_test
continue-on-error: true
run: make ${{ matrix.test }}

- name: Retry Failed Test
if: steps.run_test.outcome == 'failure'
run: |
for i in 1 2; do
echo "Retry attempt $i"
if make ${{ matrix.test }}; then
echo "Test passed on retry"
exit 0
fi
done
echo "Test failed after retries"
exit 1
4 changes: 4 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ 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"
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 +86,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,6 +116,7 @@ var (
testnetV19alpha3.Upgrade,
testnetV21alpha1.Upgrade,
testnetV22alpha1.Upgrade,
testnetV23alpha1.Upgrade,

v10.Upgrade,
v11.Upgrade,
Expand All @@ -127,6 +130,7 @@ var (
v19.Upgrade,
v21.Upgrade,
v22.Upgrade,
v23.Upgrade,
}
)

Expand Down
52 changes: 52 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,52 @@
package v23

import (
"fmt"

icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"

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/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{
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) {
}
16 changes: 16 additions & 0 deletions app/upgrades/v23/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package v23

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

"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{},
}
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) {
}
120 changes: 120 additions & 0 deletions app/upgrades/v23/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package v23

import (
"fmt"

icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

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

type IndividualAccount struct {
Owner string
Address string
}

// Core1VestingAccounts https://daodao.zone/dao/juno1j6glql3xmrcnga0gytecsucq3kd88jexxamxg3yn2xnqhunyvflqr7lxx3/members
// we are including only lobo, dimi and jake because the other ones do not agree on giving up their vesting
var Core1VestingAccounts = []IndividualAccount{
{
Owner: "dimi",
Address: "juno1s33zct2zhhaf60x4a90cpe9yquw99jj0zen8pt",
},
{
Owner: "jake",
Address: "juno18qw9ydpewh405w4lvmuhlg9gtaep79vy2gmtr2",
},
{
Owner: "wolf",
Address: "juno1a8u47ggy964tv9trjxfjcldutau5ls705djqyu",
},
}

func CreateV23UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
keepers *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))

// migrate ICQ params
for _, subspace := range keepers.ParamsKeeper.GetSubspaces() {
subspace := subspace

var keyTable paramstypes.KeyTable
if subspace.Name() == icqtypes.ModuleName {
keyTable = icqtypes.ParamKeyTable()
} else {
continue
}

if !subspace.HasKeyTable() {
subspace.WithKeyTable(keyTable)
}
}

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

// convert pob builder account to an actual module account
// during upgrade from v15 to v16 it wasn't correctly created, and since it received tokens on mainnet is now a base account
// it's like this on both mainnet and uni
if ctx.ChainID() == "juno-1" || ctx.ChainID() == "uni-6" {
logger.Info("converting x/pob builder module account")

address := sdk.MustAccAddressFromBech32("juno1ma4sw9m2nvtucny6lsjhh4qywvh86zdh5dlkd4")

acc := keepers.AccountKeeper.NewAccount(
ctx,
authtypes.NewModuleAccount(
authtypes.NewBaseAccountWithAddress(address),
"builder",
),
)
keepers.AccountKeeper.SetAccount(ctx, acc)

logger.Info("x/pob builder module address is now a module account")
}

// only on mainnet and uni, migrate core1 vesting accounts
if ctx.ChainID() == "juno-1" || ctx.ChainID() == "uni-6" {
if err := migrateCore1VestingAccounts(ctx, keepers, nativeDenom); err != nil {
return nil, err
}
}

return versionMap, err
}
}

// Migrate balances from the Core-1 vesting accounts to the Council SubDAO.
func migrateCore1VestingAccounts(ctx sdk.Context, keepers *keepers.AppKeepers, bondDenom string) error {
for _, account := range Core1VestingAccounts {
if err := MoveVestingCoinFromVestingAccount(ctx,
keepers,
bondDenom,
account.Owner,
sdk.MustAccAddressFromBech32(account.Address),
); err != nil {
return err
}
}
return nil
}
Loading
Loading