diff --git a/app/upgrades/v5.0.5/upgrades.go b/app/upgrades/v5.0.5/upgrades.go index 0ba93e8f2..112225a24 100644 --- a/app/upgrades/v5.0.5/upgrades.go +++ b/app/upgrades/v5.0.5/upgrades.go @@ -33,6 +33,8 @@ func CreateUpgradeHandler( 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) } diff --git a/app/upgrades/v5.0.5/upgrades_test.go b/app/upgrades/v5.0.5/upgrades_test.go index 3590362bd..be9cbde86 100644 --- a/app/upgrades/v5.0.5/upgrades_test.go +++ b/app/upgrades/v5.0.5/upgrades_test.go @@ -1,6 +1,8 @@ package v505_test import ( + sdk "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" "testing" upgradetypes "cosmossdk.io/x/upgrade/types" @@ -23,7 +25,7 @@ func (suite *UpgradeTestSuite) SetupTest() { suite.IBCConnectionTestSuite.SetupTest() } -func (suite *UpgradeTestSuite) TestOracleUpgrade() { +func (suite *UpgradeTestSuite) TestUpgrade() { app := suite.GetNeutronZoneApp(suite.ChainA) ctx := suite.ChainA.GetContext().WithChainID("neutron-1") t := suite.T() @@ -33,5 +35,17 @@ func (suite *UpgradeTestSuite) TestOracleUpgrade() { 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})) } diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index 552bbdb0c..e9bc92171 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -50,7 +50,7 @@ func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) erro return status.Errorf(codes.Internal, "burning from module accounts is forbidden") } - if k.isEscrowAddress(ctx, burnFromAcc) { + if k.IsEscrowAddress(ctx, burnFromAcc) { return status.Errorf(codes.Internal, "burning from escrow accounts is forbidden") } @@ -90,11 +90,11 @@ func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr, toAddr return status.Errorf(codes.Internal, "force transfer to module accounts is forbidden") } - if k.isEscrowAddress(ctx, transferFromAcc) { + if k.IsEscrowAddress(ctx, transferFromAcc) { return status.Errorf(codes.Internal, "force transfer from IBC escrow accounts is forbidden") } - if k.isEscrowAddress(ctx, transferToAcc) { + if k.IsEscrowAddress(ctx, transferToAcc) { return status.Errorf(codes.Internal, "force transfer to IBC escrow accounts is forbidden") } diff --git a/x/tokenfactory/keeper/escrow_addresses.go b/x/tokenfactory/keeper/escrow_addresses.go index a4af97a13..5189a3e7d 100644 --- a/x/tokenfactory/keeper/escrow_addresses.go +++ b/x/tokenfactory/keeper/escrow_addresses.go @@ -13,7 +13,7 @@ func (k Keeper) StoreEscrowAddress(ctx sdk.Context, address sdk.AccAddress) { prefixStore.Set(address.Bytes(), []byte{0}) } -func (k Keeper) isEscrowAddress(ctx sdk.Context, address sdk.AccAddress) bool { +func (k Keeper) IsEscrowAddress(ctx sdk.Context, address sdk.AccAddress) bool { prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.EscrowAddressKey) bz := prefixStore.Get(address.Bytes())