Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add axlr reward denom #305

Merged
merged 5 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1025,14 +1025,15 @@ func (app *App) setupUpgradeHandlers() {
app.mm,
app.configurator,
&upgrades.UpgradeKeepers{
FeeBurnerKeeper: app.FeeBurnerKeeper,
CronKeeper: app.CronKeeper,
IcqKeeper: app.InterchainQueriesKeeper,
TokenFactoryKeeper: app.TokenFactoryKeeper,
SlashingKeeper: app.SlashingKeeper,
ParamsKeeper: app.ParamsKeeper,
CapabilityKeeper: app.CapabilityKeeper,
GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName),
FeeBurnerKeeper: app.FeeBurnerKeeper,
CronKeeper: app.CronKeeper,
IcqKeeper: app.InterchainQueriesKeeper,
TokenFactoryKeeper: app.TokenFactoryKeeper,
SlashingKeeper: app.SlashingKeeper,
ParamsKeeper: app.ParamsKeeper,
CapabilityKeeper: app.CapabilityKeeper,
GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName),
CcvConsumerSubspace: app.GetSubspace(ccvconsumertypes.ModuleName),
},
app,
app.AppCodec(),
Expand Down
30 changes: 29 additions & 1 deletion app/upgrades/nextupgrade/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package nextupgrade
import (
"errors"

ccvconsumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"

ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcchanneltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"

Expand Down Expand Up @@ -42,6 +44,12 @@ func CreateUpgradeHandler(
return vm, err
}

err = migrateRewardDenoms(ctx, keepers)
if err != nil {
ctx.Logger().Error("failed to migrate reward denoms", "err", err)
return vm, err
}

ctx.Logger().Info("Upgrade complete")
return vm, err
}
Expand Down Expand Up @@ -85,7 +93,7 @@ func migrateGlobalFees(ctx sdk.Context, keepers *upgrades.UpgradeKeepers) error

ctx.Logger().Info("Bypass min fee msg types was set successfully")

keepers.GlobalFeeSubspace.Set(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, types.DefaultmaxTotalBypassMinFeeMsgGasUsage)
keepers.GlobalFeeSubspace.Set(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &types.DefaultmaxTotalBypassMinFeeMsgGasUsage)

ctx.Logger().Info("Max total bypass min fee msg gas usage set successfully")

Expand Down Expand Up @@ -129,3 +137,23 @@ func migrateFailures(ctx sdk.Context, storeKeys upgrades.StoreKeys, cdc codec.Co

return nil
}

func migrateRewardDenoms(ctx sdk.Context, keepers *upgrades.UpgradeKeepers) error {
ctx.Logger().Info("Migrating reword denoms...")

if !keepers.CcvConsumerSubspace.Has(ctx, ccvconsumertypes.KeyRewardDenoms) {
return errors.New("key_reward_denoms param not found")
}

var denoms []string
keepers.CcvConsumerSubspace.Get(ctx, ccvconsumertypes.KeyRewardDenoms, &denoms)

// add new denom
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify what denom is that exactly

denoms = append(denoms, "ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349")

keepers.CcvConsumerSubspace.Set(ctx, ccvconsumertypes.KeyRewardDenoms, &denoms)

ctx.Logger().Info("Finished migrating reward denoms")

return nil
}
31 changes: 31 additions & 0 deletions app/upgrades/nextupgrade/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package nextupgrade_test
import (
"testing"

ccvconsumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"

ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcchanneltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
contractmanagertypes "github.com/neutron-org/neutron/x/contractmanager/types"
Expand Down Expand Up @@ -160,3 +162,32 @@ func (suite *UpgradeTestSuite) TestFailuresUpgrade() {
twoKey := app.ContractManagerKeeper.GetNextFailureIDKey(ctx, addressTwo)
suite.Require().Equal(twoKey, uint64(2))
}

func (suite *UpgradeTestSuite) TestRewardDenomsUpgrade() {
var (
app = suite.GetNeutronZoneApp(suite.ChainA)
ccvConsumerSubspace = app.GetSubspace(ccvconsumertypes.ModuleName)
ctx = suite.ChainA.GetContext()
)

suite.Require().True(ccvConsumerSubspace.Has(ctx, ccvconsumertypes.KeyRewardDenoms))

var denomsBefore []string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be "ntrtn" actually, cause we have it on mainnet currently

ccvConsumerSubspace.Get(ctx, ccvconsumertypes.KeyRewardDenoms, &denomsBefore)
var empty []string = nil
suite.Require().Equal(denomsBefore, empty)

upgrade := upgradetypes.Plan{
Name: nextupgrade.UpgradeName,
Info: "some text here",
Height: 100,
}
app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade)

suite.Require().True(ccvConsumerSubspace.Has(ctx, ccvconsumertypes.KeyRewardDenoms))

var denoms []string
ccvConsumerSubspace.Get(ctx, ccvconsumertypes.KeyRewardDenoms, &denoms)
requiredDenoms := []string{"ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349"}
suite.Require().Equal(requiredDenoms, denoms)
}
3 changes: 2 additions & 1 deletion app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ type UpgradeKeepers struct {
CapabilityKeeper *capabilitykeeper.Keeper
BuilderKeeper builderkeeper.Keeper
// subspaces
GlobalFeeSubspace paramtypes.Subspace
GlobalFeeSubspace paramtypes.Subspace
CcvConsumerSubspace paramtypes.Subspace
}

type StoreKeys interface {
Expand Down