Skip to content

Commit

Permalink
add ibc rate limit contract init to upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
quasisamurai committed Oct 1, 2024
1 parent b1d32a8 commit ef2d0b0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ccvconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper"
dexkeeper "github.com/neutron-org/neutron/v5/x/dex/keeper"
ibcratelimitkeeper "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/keeper"
auctionkeeper "github.com/skip-mev/block-sdk/v2/x/auction/keeper"
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
marketmapkeeper "github.com/skip-mev/slinky/x/marketmap/keeper"
Expand Down Expand Up @@ -66,6 +67,7 @@ type UpgradeKeepers struct {
FeeMarketKeeper *feemarketkeeper.Keeper
DynamicfeesKeeper *dynamicfeeskeeper.Keeper
DexKeeper *dexkeeper.Keeper
IbcRateLimitKeeper *ibcratelimitkeeper.Keeper
// subspaces
GlobalFeeSubspace paramtypes.Subspace
CcvConsumerSubspace paramtypes.Subspace
Expand Down
3 changes: 3 additions & 0 deletions app/upgrades/v5.0.0/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v5.0.0"
// RateLimitContract defines the RL contract addr which we set as a contract address in ibc-rate-limit middleware
// https://neutron.celat.one/neutron-1/contracts/neutron15aqgplxcavqhurr0g5wwtdw6025dknkqwkfh0n46gp2qjl6236cs2yd3nl
RateLimitContract = "neutron15aqgplxcavqhurr0g5wwtdw6025dknkqwkfh0n46gp2qjl6236cs2yd3nl"
)

var Upgrade = upgrades.Upgrade{
Expand Down
24 changes: 24 additions & 0 deletions app/upgrades/v5.0.0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/neutron-org/neutron/v5/app/upgrades"
dexkeeper "github.com/neutron-org/neutron/v5/x/dex/keeper"
ibcratelimitkeeper "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/keeper"
ibcratelimittypes "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types"
)

func CreateUpgradeHandler(
Expand Down Expand Up @@ -37,6 +39,15 @@ func CreateUpgradeHandler(
}
}

ctx.Logger().Info("Running ibc-rate-limit upgrades...")
// Only set rate limit contract for mainnet
if ctx.ChainID() == "neutron-1" {
err = upgradeIbcRateLimitSetContract(ctx, *keepers.IbcRateLimitKeeper)
if err != nil {
return nil, err
}
}

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))
return vm, nil
}
Expand All @@ -57,3 +68,16 @@ func upgradeDexPause(ctx sdk.Context, k dexkeeper.Keeper) error {

return nil
}

func upgradeIbcRateLimitSetContract(ctx sdk.Context, k ibcratelimitkeeper.Keeper) error {
// Set the dex to paused
ctx.Logger().Info("Setting ibc rate limiting contract...")

if err := k.SetParams(ctx, ibcratelimittypes.Params{ContractAddress: RateLimitContract}); err != nil {
return err
}

ctx.Logger().Info("Rate limit contract is set")

return nil
}

0 comments on commit ef2d0b0

Please sign in to comment.