-
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
f029efe
commit 87c5ad1
Showing
8 changed files
with
200 additions
and
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package v20 | ||
|
||
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" | ||
) | ||
|
||
// UpgradeName defines the on-chain upgrade name for the upgrade. | ||
const UpgradeName = "v20" | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateV20UpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{ | ||
Added: []string{ | ||
wasmlctypes.ModuleName, | ||
}, | ||
}, | ||
} |
2 changes: 1 addition & 1 deletion
2
app/upgrades/v19/mainnet_accounts.go → app/upgrades/v20/mainnet_accounts.go
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 v19 | ||
package v20 | ||
|
||
import ( | ||
"encoding/json" | ||
|
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,73 @@ | ||
package v20_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
|
||
"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) | ||
|
||
upgradeHeight := int64(5) | ||
s.ConfirmUpgradeSucceeded(v20.UpgradeName, upgradeHeight) | ||
|
||
postUpgradeChecks(s) | ||
} | ||
|
||
func preUpgradeChecks(s *UpgradeTestSuite) { | ||
// Setup mainnet account | ||
_, err := v20.CreateMainnetVestingAccount(s.Ctx, s.App.AppKeepers) | ||
s.Require().NoError(err) | ||
|
||
// Create 3 generic validators | ||
val1 := s.SetupValidator(stakingtypes.Bonded) | ||
val2 := s.SetupValidator(stakingtypes.Bonded) | ||
val3 := s.SetupValidator(stakingtypes.Bonded) | ||
|
||
// Get last validator, set as mock jack validator | ||
val, found := s.App.AppKeepers.StakingKeeper.GetValidator(s.Ctx, val3) | ||
s.Require().True(found) | ||
v20.JackValidatorAddress = val.OperatorAddress | ||
|
||
validators := []sdk.ValAddress{val1, val2, val3} | ||
|
||
// Should equal 4, including default validator | ||
s.Require().Equal(4, len(s.App.AppKeepers.StakingKeeper.GetAllValidators(s.Ctx))) | ||
|
||
// Create delegations to each validator 2x, ensuring multiple delegations | ||
// are created for each validator and combined in state. | ||
for i := 0; i < 2; i++ { | ||
for _, delegator := range v20.Core1VestingAccounts { | ||
delegatorAddr := sdk.MustAccAddressFromBech32(delegator.Address) | ||
|
||
for _, validator := range validators { | ||
s.StakingHelper.Delegate(delegatorAddr, validator, sdk.NewInt(1_000_000)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
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,101 @@ | ||
package v20 | ||
|
||
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" | ||
) | ||
|
||
const ( | ||
// Charter Council's SubDAO Address | ||
CharterCouncil = "juno1nmezpepv3lx45mndyctz2lzqxa6d9xzd2xumkxf7a6r4nxt0y95qypm6c0" | ||
JackKey = "jack" | ||
) | ||
|
||
// JackValidatorAddress must be mutable for testing | ||
var JackValidatorAddress = "junovaloper130mdu9a0etmeuw52qfxk73pn0ga6gawk2tz77l" | ||
|
||
type IndividualAccount struct { | ||
Owner string | ||
Address string | ||
} | ||
|
||
// Core1VestingAccounts https://daodao.zone/dao/juno1j6glql3xmrcnga0gytecsucq3kd88jexxamxg3yn2xnqhunyvflqr7lxx3/members | ||
var Core1VestingAccounts = []IndividualAccount{ | ||
{ | ||
Owner: "block", | ||
Address: "juno17py8gfneaam64vt9kaec0fseqwxvkq0flmsmhg", | ||
}, | ||
{ | ||
Owner: "dimi", | ||
Address: "juno1s33zct2zhhaf60x4a90cpe9yquw99jj0zen8pt", | ||
}, | ||
{ | ||
Owner: JackKey, | ||
Address: "juno130mdu9a0etmeuw52qfxk73pn0ga6gawk4k539x", | ||
}, | ||
{ | ||
Owner: "jake", | ||
Address: "juno18qw9ydpewh405w4lvmuhlg9gtaep79vy2gmtr2", | ||
}, | ||
{ | ||
Owner: "multisig", | ||
Address: "juno190g5j8aszqhvtg7cprmev8xcxs6csra7xnk3n3", | ||
}, | ||
{ | ||
Owner: "wolf", | ||
Address: "juno1a8u47ggy964tv9trjxfjcldutau5ls705djqyu", | ||
}, | ||
} | ||
|
||
func CreateV20UpgradeHandler( | ||
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 Core-1 vesting account remaining funds -> Council SubDAO | ||
if ctx.ChainID() == "juno-1" { | ||
if err := migrateCore1VestingAccounts(ctx, k, 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 { | ||
// A new vesting contract will not be created if the account name is 'wolf'. | ||
if err := MoveVestingCoinFromVestingAccount(ctx, | ||
keepers, | ||
bondDenom, | ||
account.Owner, | ||
sdk.MustAccAddressFromBech32(account.Address), | ||
sdk.MustAccAddressFromBech32(CharterCouncil), | ||
); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |
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 v19 | ||
package v20 | ||
|
||
import ( | ||
"fmt" | ||
|