-
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.
DNM: [uni-a] Standalone Upgrade Patch for Testnet (#821)
* uni-a standalone upgrade * 100m tokens from 1m (oops, thanks dimi!) * make it easier to read * Use IAVL v0.20.1 (#826) * v17: Migrate SubDAOs from distribution module -> gov (#831) * migrateChainOwnedSubDaos from distr -> gov * lint * simplify addr logic * minor: comment typo * Fix v17 Upgrade Package Name (#832) * chore: ci bumps (#840) --------- Co-authored-by: Matt, Park <[email protected]> Co-authored-by: Joel Smith <[email protected]>
- Loading branch information
1 parent
68bfd2f
commit d307dff
Showing
18 changed files
with
210 additions
and
51 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
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
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 was deleted.
Oops, something went wrong.
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,16 @@ | ||
package unia | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
|
||
"github.com/CosmosContracts/juno/v17/app/upgrades" | ||
) | ||
|
||
// UpgradeName defines the on-chain upgrade name for the upgrade. | ||
const UpgradeName = "uni-a" | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUniAUpgradeHandler, | ||
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,52 @@ | ||
package unia_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/CosmosContracts/juno/v17/app/apptesting" | ||
unia "github.com/CosmosContracts/juno/v17/app/upgrades/uni-a" | ||
) | ||
|
||
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(unia.UpgradeName, upgradeHeight) | ||
|
||
postUpgradeChecks(s) | ||
} | ||
|
||
func preUpgradeChecks(s *UpgradeTestSuite) { | ||
bal := getAccBalance(s, unia.ReeceBech32) | ||
s.Require().Equal(bal, sdk.NewCoins()) | ||
} | ||
|
||
func postUpgradeChecks(s *UpgradeTestSuite) { | ||
bal := getAccBalance(s, unia.ReeceBech32) | ||
// 100m tokens | ||
s.Require().Equal(bal, sdk.NewCoins(sdk.NewCoin("ujunox", sdk.NewInt(100_000_000*1_000_000)))) | ||
} | ||
|
||
func getAccBalance(s *UpgradeTestSuite, bech32 string) sdk.Coins { | ||
addr := sdk.MustAccAddressFromBech32(bech32) | ||
return s.App.AppKeepers.BankKeeper.GetAllBalances(s.Ctx, addr) | ||
} |
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,64 @@ | ||
package unia | ||
|
||
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/v17/app/keepers" | ||
"github.com/CosmosContracts/juno/v17/app/upgrades" | ||
minttypes "github.com/CosmosContracts/juno/v17/x/mint/types" | ||
) | ||
|
||
const ( | ||
// Reece's validator account. | ||
ReeceBech32 = "juno15twk6xu5rnrrlnf7c5zy92gvykcs4h5ucxzzqq" | ||
) | ||
|
||
// TokensAmount is for testnet only. | ||
var TokensAmount = sdk.NewCoins(sdk.NewCoin("ujunox", sdk.NewInt(100_000_000_000000))) | ||
|
||
func CreateUniAUpgradeHandler( | ||
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)) | ||
|
||
// Run migrations | ||
versionMap, err := mm.RunMigrations(ctx, cfg, vm) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Turn off inflation | ||
minter := keepers.MintKeeper.GetMinter(ctx) | ||
minter.Inflation = sdk.NewDecWithPrec(0, 2) | ||
keepers.MintKeeper.SetMinter(ctx, minter) | ||
|
||
// set blocks per year to be very high | ||
mp := keepers.MintKeeper.GetParams(ctx) | ||
mp.BlocksPerYear = 1_000_000_000_000 | ||
if err := keepers.MintKeeper.SetParams(ctx, mp); err != nil { | ||
return nil, err | ||
} | ||
|
||
// Mint Tokens for Account | ||
acc := sdk.MustAccAddressFromBech32(ReeceBech32) | ||
if err := keepers.BankKeeper.MintCoins(ctx, minttypes.ModuleName, TokensAmount); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := keepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, acc, TokensAmount); err != nil { | ||
return nil, err | ||
} | ||
|
||
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package v16 | ||
package v17 | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package v16_test | ||
package v17_test | ||
|
||
import ( | ||
"testing" | ||
|
Oops, something went wrong.