-
Notifications
You must be signed in to change notification settings - Fork 208
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
Showing
6 changed files
with
189 additions
and
2 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,15 @@ | ||
package v9 | ||
|
||
var ( | ||
UpgradeName = "v9" | ||
|
||
EvmosAirdropId = "evmos" | ||
AirdropChainIds = map[string]string{ | ||
"stride": "stride-1", | ||
"gaia": "cosmoshub-4", | ||
"osmosis": "osmosis-1", | ||
"juno": "juno-1", | ||
"stars": "stargaze-1", | ||
"evmos": "evmos_9001-2", | ||
} | ||
) |
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 v9 | ||
|
||
import ( | ||
"fmt" | ||
|
||
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" | ||
|
||
claimkeeper "github.com/Stride-Labs/stride/v8/x/claim/keeper" | ||
) | ||
|
||
// CreateUpgradeHandler creates an SDK upgrade handler for v29 | ||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
claimKeeper claimkeeper.Keeper, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
ctx.Logger().Info("Starting upgrade v9...") | ||
|
||
if err := AddFieldsToAirdropType(ctx, claimKeeper); err != nil { | ||
return vm, errorsmod.Wrapf(err, "unable to update airdrop schema") | ||
} | ||
|
||
ctx.Logger().Info("Running module migrations...") | ||
return mm.RunMigrations(ctx, configurator, vm) | ||
} | ||
} | ||
|
||
func AddFieldsToAirdropType(ctx sdk.Context, claimKeeper claimkeeper.Keeper) error { | ||
ctx.Logger().Info("Adding additional fields to airdrop struct...") | ||
|
||
// Get list of airdrops from claim parameters | ||
claimParams, err := claimKeeper.GetParams(ctx) | ||
if err != nil { | ||
return errorsmod.Wrapf(err, "unable to get claim parameters") | ||
} | ||
|
||
for _, airdrop := range claimParams.Airdrops { | ||
// Add the chain ID to each airdrop | ||
chainId, ok := AirdropChainIds[airdrop.AirdropIdentifier] | ||
if !ok { | ||
ctx.Logger().Error(fmt.Sprintf("Chain ID not specified for %s airdrop", chainId)) | ||
continue | ||
} | ||
airdrop.ChainId = chainId | ||
|
||
// Enable autopilot for evmos only | ||
if airdrop.AirdropIdentifier == EvmosAirdropId { | ||
airdrop.AutopilotEnabled = true | ||
} else { | ||
airdrop.AutopilotEnabled = false | ||
} | ||
} | ||
|
||
// Update list of airdrops | ||
if err := claimKeeper.SetParams(ctx, claimParams); err != nil { | ||
return errorsmod.Wrapf(err, "unable to set claim parameters") | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package v9_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/Stride-Labs/stride/v8/app" | ||
"github.com/Stride-Labs/stride/v8/app/apptesting" | ||
v9 "github.com/Stride-Labs/stride/v8/app/upgrades/v9" | ||
"github.com/Stride-Labs/stride/v8/utils" | ||
|
||
claimtypes "github.com/Stride-Labs/stride/v8/x/claim/types" | ||
|
||
// This isn't the exact type host zone schema as the one that's will be in the store | ||
// before the upgrade, but the only thing that matters, for the sake of the test, | ||
// is that it doesn't have min/max redemption rate as attributes | ||
"github.com/Stride-Labs/stride/v8/x/claim/migrations/v2/types" | ||
oldclaimtypes "github.com/Stride-Labs/stride/v8/x/claim/migrations/v2/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() { | ||
s.Setup() | ||
|
||
dummyUpgradeHeight := int64(5) | ||
|
||
s.SetupAirdropsBeforeUpgrade() | ||
s.ConfirmUpgradeSucceededs("v9", dummyUpgradeHeight) | ||
s.CheckAirdropsAfterUpgrade() | ||
} | ||
|
||
func (s *UpgradeTestSuite) SetupAirdropsBeforeUpgrade() { | ||
// Create a list of airdrops of the old data type | ||
airdrops := []*oldclaimtypes.Airdrop{} | ||
for i, identifier := range utils.StringMapKeys(v9.AirdropChainIds) { | ||
airdrops = append(airdrops, &oldclaimtypes.Airdrop{ | ||
AirdropIdentifier: identifier, | ||
ClaimDenom: fmt.Sprintf("denom-%d", i), | ||
}) | ||
} | ||
|
||
// Add in another airdrop that's not in the map | ||
airdrops = append(airdrops, &types.Airdrop{ | ||
AirdropIdentifier: "different_airdrop", | ||
}) | ||
|
||
// Store the airdrops using the old schema | ||
codec := app.MakeEncodingConfig().Marshaler | ||
claimStore := s.Ctx.KVStore(s.App.GetKey(claimtypes.StoreKey)) | ||
|
||
paramsBz, err := codec.MarshalJSON(&oldclaimtypes.Params{Airdrops: airdrops}) | ||
s.Require().NoError(err, "no error expected when marshalling claim params") | ||
claimStore.Set([]byte(claimtypes.ParamsKey), paramsBz) | ||
} | ||
|
||
func (s *UpgradeTestSuite) CheckAirdropsAfterUpgrade() { | ||
// Read in the airdrops using the new schema - which should include chainId and AirdropEnabled | ||
claimParams, err := s.App.ClaimKeeper.GetParams(s.Ctx) | ||
s.Require().NoError(err, "no error expected when getting claims params") | ||
s.Require().Len(claimParams.Airdrops, len(v9.AirdropChainIds)+1, "number of airdrops after migration") | ||
|
||
// Confirm the new fields were added and the old fields (e.g. ChainDenom) remain the same | ||
for i, identifier := range utils.StringMapKeys(v9.AirdropChainIds) { | ||
expectedChainId := v9.AirdropChainIds[identifier] | ||
expectedDenom := fmt.Sprintf("denom-%d", i) | ||
expectedAutopilotEnabled := identifier == v9.EvmosAirdropId | ||
|
||
actual := claimParams.Airdrops[i] | ||
s.Require().Equal(identifier, actual.AirdropIdentifier, "identifier after migration") | ||
s.Require().Equal(expectedChainId, actual.ChainId, "chain-id after migration") | ||
s.Require().Equal(expectedDenom, actual.ClaimDenom, "denom after migration") | ||
s.Require().Equal(expectedAutopilotEnabled, actual.AutopilotEnabled, "autopilot enabled after migration") | ||
} | ||
|
||
// Confirm the airdrop that was not in the map | ||
airdropWithoutChainId := claimParams.Airdrops[len(v9.AirdropChainIds)] | ||
s.Require().Equal("different_airdrop", airdropWithoutChainId.AirdropIdentifier, "airdrop id for outsider") | ||
s.Require().Equal("", airdropWithoutChainId.ChainId, "chain-id for outsider") | ||
} | ||
|
||
func (s *UpgradeTestSuite) TestAddFieldsToAirdropType() { | ||
s.SetupAirdropsBeforeUpgrade() | ||
|
||
err := v9.AddFieldsToAirdropType(s.Ctx, s.App.ClaimKeeper) | ||
s.Require().NoError(err, "no error expected when migrating airdrop schema") | ||
|
||
s.CheckAirdropsAfterUpgrade() | ||
} |
Submodule relayer
updated
27 files
+3 −3 | README.md | |
+107 −84 | cmd/appstate.go | |
+70 −73 | cmd/chains.go | |
+98 −133 | cmd/config.go | |
+8 −8 | cmd/keys.go | |
+177 −175 | cmd/paths.go | |
+32 −32 | cmd/query.go | |
+11 −11 | cmd/root.go | |
+17 −17 | cmd/start.go | |
+87 −87 | cmd/tx.go | |
+1 −1 | cmd/version.go | |
+6 −2 | docs/advanced_usage.md | |
+2 −2 | interchaintest/go.mod | |
+4 −4 | interchaintest/go.sum | |
+334 −0 | interchaintest/ica_channel_close_test.go | |
+59 −28 | interchaintest/interchain_accounts_test.go | |
+5 −4 | interchaintest/relay_many_test.go | |
+5 −4 | interchaintest/relayer_override_test.go | |
+6 −5 | interchaintest/tendermint_v0.37_boundary_test.go | |
+18 −5 | relayer/chains/cosmos/cosmos_chain_processor.go | |
+6 −1 | relayer/chains/cosmos/query.go | |
+44 −17 | relayer/channel.go | |
+44 −2 | relayer/processor/path_end_runtime.go | |
+3 −3 | relayer/processor/path_processor.go | |
+253 −84 | relayer/processor/path_processor_internal.go | |
+12 −0 | relayer/processor/types.go | |
+17 −10 | relayer/processor/types_internal.go |