-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #797 from neutron-org/chore/releases-to-main
chore: releases to main
- Loading branch information
Showing
22 changed files
with
377 additions
and
50 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,18 @@ | ||
package v504 | ||
|
||
import ( | ||
storetypes "cosmossdk.io/store/types" | ||
|
||
"github.com/neutron-org/neutron/v5/app/upgrades" | ||
) | ||
|
||
const ( | ||
// UpgradeName defines the on-chain upgrade name. | ||
UpgradeName = "v5.0.4" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: storetypes.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,35 @@ | ||
package v504 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
upgradetypes "cosmossdk.io/x/upgrade/types" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
|
||
"github.com/neutron-org/neutron/v5/app/upgrades" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
_ *upgrades.UpgradeKeepers, | ||
_ upgrades.StoreKeys, | ||
_ codec.Codec, | ||
) upgradetypes.UpgradeHandler { | ||
return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
ctx := sdk.UnwrapSDKContext(c) | ||
|
||
ctx.Logger().Info("Starting module migrations...") | ||
|
||
vm, err := mm.RunMigrations(ctx, configurator, vm) | ||
if err != nil { | ||
return vm, err | ||
} | ||
|
||
ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName)) | ||
return vm, 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,37 @@ | ||
package v504_test | ||
|
||
import ( | ||
"testing" | ||
|
||
upgradetypes "cosmossdk.io/x/upgrade/types" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
|
||
v504 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.4" | ||
"github.com/neutron-org/neutron/v5/testutil" | ||
) | ||
|
||
type UpgradeTestSuite struct { | ||
testutil.IBCConnectionTestSuite | ||
} | ||
|
||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(UpgradeTestSuite)) | ||
} | ||
|
||
func (suite *UpgradeTestSuite) SetupTest() { | ||
suite.IBCConnectionTestSuite.SetupTest() | ||
} | ||
|
||
func (suite *UpgradeTestSuite) TestOracleUpgrade() { | ||
app := suite.GetNeutronZoneApp(suite.ChainA) | ||
ctx := suite.ChainA.GetContext().WithChainID("neutron-1") | ||
t := suite.T() | ||
|
||
upgrade := upgradetypes.Plan{ | ||
Name: v504.UpgradeName, | ||
Info: "some text here", | ||
Height: 100, | ||
} | ||
require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade)) | ||
} |
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,18 @@ | ||
package v505 | ||
|
||
import ( | ||
storetypes "cosmossdk.io/store/types" | ||
|
||
"github.com/neutron-org/neutron/v5/app/upgrades" | ||
) | ||
|
||
const ( | ||
// UpgradeName defines the on-chain upgrade name. | ||
UpgradeName = "v5.0.5" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: storetypes.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,45 @@ | ||
package v505 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" | ||
|
||
upgradetypes "cosmossdk.io/x/upgrade/types" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
|
||
"github.com/neutron-org/neutron/v5/app/upgrades" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
keepers *upgrades.UpgradeKeepers, | ||
_ upgrades.StoreKeys, | ||
_ codec.Codec, | ||
) upgradetypes.UpgradeHandler { | ||
return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
ctx := sdk.UnwrapSDKContext(c) | ||
|
||
ctx.Logger().Info("Starting module migrations...") | ||
|
||
vm, err := mm.RunMigrations(ctx, configurator, vm) | ||
if err != nil { | ||
return vm, err | ||
} | ||
|
||
transferChannels := keepers.ChannelKeeper.GetAllChannelsWithPortPrefix(ctx, keepers.TransferKeeper.GetPort(ctx)) | ||
for _, channel := range transferChannels { | ||
escrowAddress := transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId) | ||
ctx.Logger().Info("Saving escrow address", "port_id", channel.PortId, "channel_id", | ||
channel.ChannelId, "address", escrowAddress.String()) | ||
keepers.TokenFactoryKeeper.StoreEscrowAddress(ctx, escrowAddress) | ||
} | ||
|
||
ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName)) | ||
return vm, 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,52 @@ | ||
package v505_test | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" | ||
|
||
upgradetypes "cosmossdk.io/x/upgrade/types" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
|
||
v505 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.5" | ||
"github.com/neutron-org/neutron/v5/testutil" | ||
) | ||
|
||
type UpgradeTestSuite struct { | ||
testutil.IBCConnectionTestSuite | ||
} | ||
|
||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(UpgradeTestSuite)) | ||
} | ||
|
||
func (suite *UpgradeTestSuite) SetupTest() { | ||
suite.IBCConnectionTestSuite.SetupTest() | ||
} | ||
|
||
func (suite *UpgradeTestSuite) TestUpgrade() { | ||
app := suite.GetNeutronZoneApp(suite.ChainA) | ||
ctx := suite.ChainA.GetContext().WithChainID("neutron-1") | ||
t := suite.T() | ||
|
||
upgrade := upgradetypes.Plan{ | ||
Name: v505.UpgradeName, | ||
Info: "some text here", | ||
Height: 100, | ||
} | ||
|
||
var escrowAddresses []sdk.AccAddress | ||
transferChannels := app.IBCKeeper.ChannelKeeper.GetAllChannelsWithPortPrefix(ctx, app.TransferKeeper.GetPort(ctx)) | ||
for _, channel := range transferChannels { | ||
escrowAddresses = append(escrowAddresses, transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId)) | ||
} | ||
require.Greater(t, len(escrowAddresses), 0) | ||
require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade)) | ||
|
||
for _, escrowAddress := range escrowAddresses { | ||
require.True(t, app.TokenFactoryKeeper.IsEscrowAddress(ctx, escrowAddress)) | ||
} | ||
require.False(t, app.TokenFactoryKeeper.IsEscrowAddress(ctx, []byte{1, 2, 3, 4, 5})) | ||
} |
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
Oops, something went wrong.