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 all commits
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
31 changes: 30 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 @@ -34,6 +36,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 @@ -77,9 +85,30 @@ 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")

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 axlr usdc denom
axlrDenom := "ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349"
denoms = append(denoms, axlrDenom)

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

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

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

"github.com/neutron-org/neutron/app/params"

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

sdk "github.com/cosmos/cosmos-sdk/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/gaia/v11/x/globalfee"
Expand Down Expand Up @@ -67,3 +71,34 @@ func (suite *UpgradeTestSuite) TestGlobalFeesUpgrade() {
requiredTotalBypassMinFeeMsgGasUsage := uint64(1_000_000)
suite.Require().Equal(requiredTotalBypassMinFeeMsgGasUsage, actualTotalBypassMinFeeMsgGasUsage)
}

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))

// emulate mainnet/testnet state
ccvConsumerSubspace.Set(ctx, ccvconsumertypes.KeyRewardDenoms, &[]string{params.DefaultDenom})

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)
suite.Require().Equal(denomsBefore, []string{params.DefaultDenom})

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{params.DefaultDenom, "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