Skip to content

Commit

Permalink
[CORE-824] Add upgrade handler for ratelimit keeper (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyding authored Jan 26, 2024
1 parent 13c29f9 commit e06aea3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions protocol/app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func (app *App) setupUpgradeHandlers() {
v4_0_0.CreateUpgradeHandler(
app.ModuleManager,
app.configurator,
app.RatelimitKeeper,
),
)
}
Expand Down
11 changes: 10 additions & 1 deletion protocol/app/upgrades/v4.0.0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@ import (
upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

ratelimitkeeper "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/keeper"
ratelimittypes "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
rateLimitKeepr ratelimitkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
sdkCtx.Logger().Info(fmt.Sprintf("Running %s Upgrade...", UpgradeName))

// TODO(CORE-824): Initialize ratelimit module params to desired state.
if err := rateLimitKeepr.SetLimitParams(
sdkCtx,
ratelimittypes.DefaultUsdcRateLimitParams(),
); err != nil {
panic(fmt.Sprintf("failed to set default x/ratelimit params: %s", err))
}

return mm.RunMigrations(ctx, configurator, vm)
}
Expand Down

0 comments on commit e06aea3

Please sign in to comment.