-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
120946f
commit ab47770
Showing
5 changed files
with
147 additions
and
7 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,27 @@ | ||
package v19 | ||
|
||
import ( | ||
wasmlctypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" | ||
|
||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
|
||
"github.com/CosmosContracts/juno/v19/app/upgrades" | ||
) | ||
|
||
const ( | ||
Core1MultisigVestingAccount = "juno190g5j8aszqhvtg7cprmev8xcxs6csra7xnk3n3" | ||
CharterCouncil = "juno1nmezpepv3lx45mndyctz2lzqxa6d9xzd2xumkxf7a6r4nxt0y95qypm6c0" | ||
) | ||
|
||
// UpgradeName defines the on-chain upgrade name for the upgrade. | ||
const UpgradeName = "v20" | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateV19UpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{ | ||
Added: []string{ | ||
wasmlctypes.ModuleName, | ||
}, | ||
}, | ||
} |
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,63 @@ | ||
package v19_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
Check failure on line 8 in app/upgrades/v20/upgrade_test.go GitHub Actions / lint
|
||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
Check failure on line 11 in app/upgrades/v20/upgrade_test.go GitHub Actions / lint
|
||
|
||
"github.com/CosmosContracts/juno/v19/app/apptesting" | ||
v20 "github.com/CosmosContracts/juno/v19/app/upgrades/v20" | ||
) | ||
|
||
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) | ||
|
||
// == CREATE MOCK CORE-1 BASE ACCOUNT == | ||
acc := sdk.MustAccAddressFromBech32(v20.Core1MultisigVestingAccount) | ||
|
||
// set account and mint it some balance | ||
s.App.AppKeepers.AccountKeeper.SetAccount(s.Ctx, authtypes.NewBaseAccount(acc, nil, 0, 0)) | ||
|
||
amt := int64(9406347457268) | ||
s.App.AppKeepers.BankKeeper.MintCoins(s.Ctx, "mint", sdk.NewCoins(sdk.NewInt64Coin("ujuno", amt))) | ||
s.App.AppKeepers.BankKeeper.SendCoinsFromModuleToAccount(s.Ctx, "mint", acc, sdk.NewCoins(sdk.NewInt64Coin("ujuno", amt))) | ||
|
||
accBal := s.App.AppKeepers.BankKeeper.GetAllBalances(s.Ctx, acc) | ||
fmt.Printf("Core1 bal: %s\n", accBal) | ||
|
||
// == UPGRADE == | ||
upgradeHeight := int64(5) | ||
s.ConfirmUpgradeSucceeded(v20.UpgradeName, upgradeHeight) | ||
postUpgradeChecks(s) | ||
|
||
// == POST VERIFICATION == | ||
charterBal := s.App.AppKeepers.BankKeeper.GetAllBalances(s.Ctx, sdk.MustAccAddressFromBech32(v20.CharterCouncil)) | ||
fmt.Printf("Council Post Upgrade Balance: %s\n", charterBal) | ||
|
||
s.Require().True(charterBal.AmountOf("ujuno").GTE(accBal.AmountOf("ujuno"))) | ||
} | ||
|
||
func preUpgradeChecks(s *UpgradeTestSuite) { | ||
} | ||
|
||
func postUpgradeChecks(s *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,47 @@ | ||
package v19 | ||
|
||
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/v19/app/keepers" | ||
"github.com/CosmosContracts/juno/v19/app/upgrades" | ||
) | ||
|
||
func CreateV19UpgradeHandler( | ||
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) | ||
|
||
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)) | ||
|
||
// migrate the rest of Core-1 funds to the council | ||
if ctx.ChainID() == "juno-1" { | ||
core1MultisigAcc := sdk.MustAccAddressFromBech32(Core1MultisigVestingAccount) | ||
chaterAcc := sdk.MustAccAddressFromBech32(CharterCouncil) | ||
|
||
bal := k.BankKeeper.GetBalance(ctx, core1MultisigAcc, nativeDenom) | ||
|
||
if err = k.BankKeeper.SendCoins(ctx, core1MultisigAcc, chaterAcc, sdk.NewCoins(bal)); err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return versionMap, err | ||
} | ||
} |