-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* basic upgrade handler for v23 * remove icq from store upgrades * migrate icq params in upgrade handler * builder module account conversion * port back tf patch from mainnet with a better implementation * lint * refuse in tf update * core1 vesting migration * lint * lint 2 * remove uneccessary consensus params migration * ci: allow flaky interchaintest to rerun. (#1034) * ci * test * test2 * test3 --------- Co-authored-by: Tuan Tran <[email protected]>
- Loading branch information
1 parent
386f90b
commit bf140aa
Showing
12 changed files
with
493 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.