-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: strbrian <[email protected]> Co-authored-by: strbrian <[email protected]> Co-authored-by: sampocs <[email protected]>
- Loading branch information
1 parent
54358c3
commit 65a10d6
Showing
7 changed files
with
110 additions
and
25 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,43 @@ | ||
package v13 | ||
|
||
import ( | ||
errorsmod "cosmossdk.io/errors" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
|
||
stakeibckeeper "github.com/Stride-Labs/stride/v13/x/stakeibc/keeper" | ||
stakeibctypes "github.com/Stride-Labs/stride/v13/x/stakeibc/types" | ||
) | ||
|
||
var ( | ||
UpgradeName = "v13" | ||
) | ||
|
||
// CreateUpgradeHandler creates an SDK upgrade handler for v13 | ||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
stakeibcKeeper stakeibckeeper.Keeper, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
ctx.Logger().Info("Starting upgrade v13...") | ||
|
||
ctx.Logger().Info("Registering stTokens to consumer reward denom whitelist...") | ||
hostZones := stakeibcKeeper.GetAllHostZone(ctx) | ||
allDenoms := []string{} | ||
|
||
// get all stToken denoms | ||
for _, zone := range hostZones { | ||
allDenoms = append(allDenoms, stakeibctypes.StAssetDenomFromHostZoneDenom(zone.HostDenom)) | ||
} | ||
|
||
err := stakeibcKeeper.RegisterStTokenDenomsToWhitelist(ctx, allDenoms) | ||
if err != nil { | ||
return nil, errorsmod.Wrapf(err, "unable to register stTokens to whitelist") | ||
} | ||
|
||
return mm.RunMigrations(ctx, configurator, vm) | ||
} | ||
} |
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,49 @@ | ||
package v13_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/Stride-Labs/stride/v13/app/apptesting" | ||
stakeibctypes "github.com/Stride-Labs/stride/v13/x/stakeibc/types" | ||
) | ||
|
||
type UpgradeTestSuite struct { | ||
apptesting.AppTestHelper | ||
} | ||
|
||
func (s *UpgradeTestSuite) SetupTest() { | ||
s.Setup() | ||
} | ||
|
||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(UpgradeTestSuite)) | ||
} | ||
|
||
func (s *UpgradeTestSuite) TestUpgrade() { | ||
dummyUpgradeHeight := int64(5) | ||
|
||
// Clear the reward denoms in the consumer keeper | ||
consumerParams := s.App.ConsumerKeeper.GetConsumerParams(s.Ctx) | ||
consumerParams.RewardDenoms = []string{"denomA", "denomB"} | ||
s.App.ConsumerKeeper.SetParams(s.Ctx, consumerParams) | ||
|
||
// Add host zones | ||
hostZones := []stakeibctypes.HostZone{ | ||
{ChainId: "cosmoshub-4", HostDenom: "uatom"}, | ||
{ChainId: "osmosis-1", HostDenom: "uosmo"}, | ||
{ChainId: "juno-1", HostDenom: "ujuno"}, | ||
} | ||
for _, hostZone := range hostZones { | ||
s.App.StakeibcKeeper.SetHostZone(s.Ctx, hostZone) | ||
} | ||
|
||
// Submit the upgrade which should register the new host denoms | ||
s.ConfirmUpgradeSucceededs("v13", dummyUpgradeHeight) | ||
|
||
// Confirm the new reward denoms were registered | ||
expectedRewardDenoms := []string{"denomA", "denomB", "stuatom", "stuosmo", "stujuno"} | ||
consumerParams = s.App.ConsumerKeeper.GetConsumerParams(s.Ctx) | ||
s.Require().ElementsMatch(expectedRewardDenoms, consumerParams.RewardDenoms) | ||
} |
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