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

[CORE-824] Implement keeper methods for LimitParams and DenomCapacity #877

Merged
merged 5 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
18 changes: 9 additions & 9 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ import * as _45 from "./feetiers/genesis";
import * as _46 from "./feetiers/params";
import * as _47 from "./feetiers/query";
import * as _48 from "./feetiers/tx";
import * as _49 from "./ibcratelimit/capacity";
import * as _50 from "./ibcratelimit/genesis";
import * as _51 from "./ibcratelimit/limit_params";
import * as _52 from "./ibcratelimit/query";
import * as _53 from "./ibcratelimit/tx";
import * as _49 from "./ratelimit/capacity";
import * as _50 from "./ratelimit/genesis";
import * as _51 from "./ratelimit/limit_params";
import * as _52 from "./ratelimit/query";
import * as _53 from "./ratelimit/tx";
import * as _54 from "./indexer/events/events";
import * as _55 from "./indexer/indexer_manager/event";
import * as _56 from "./indexer/off_chain_updates/off_chain_updates";
Expand Down Expand Up @@ -95,7 +95,7 @@ import * as _105 from "./clob/query.lcd";
import * as _106 from "./delaymsg/query.lcd";
import * as _107 from "./epochs/query.lcd";
import * as _108 from "./feetiers/query.lcd";
import * as _109 from "./ibcratelimit/query.lcd";
import * as _109 from "./ratelimit/query.lcd";
import * as _110 from "./perpetuals/query.lcd";
import * as _111 from "./prices/query.lcd";
import * as _112 from "./rewards/query.lcd";
Expand All @@ -109,7 +109,7 @@ import * as _119 from "./clob/query.rpc.Query";
import * as _120 from "./delaymsg/query.rpc.Query";
import * as _121 from "./epochs/query.rpc.Query";
import * as _122 from "./feetiers/query.rpc.Query";
import * as _123 from "./ibcratelimit/query.rpc.Query";
import * as _123 from "./ratelimit/query.rpc.Query";
import * as _124 from "./perpetuals/query.rpc.Query";
import * as _125 from "./prices/query.rpc.Query";
import * as _126 from "./rewards/query.rpc.Query";
Expand All @@ -122,7 +122,7 @@ import * as _132 from "./bridge/tx.rpc.msg";
import * as _133 from "./clob/tx.rpc.msg";
import * as _134 from "./delaymsg/tx.rpc.msg";
import * as _135 from "./feetiers/tx.rpc.msg";
import * as _136 from "./ibcratelimit/tx.rpc.msg";
import * as _136 from "./ratelimit/tx.rpc.msg";
import * as _137 from "./perpetuals/tx.rpc.msg";
import * as _138 from "./prices/tx.rpc.msg";
import * as _139 from "./rewards/tx.rpc.msg";
Expand Down Expand Up @@ -208,7 +208,7 @@ export namespace dydxprotocol {
..._122,
..._135
};
export const ibcratelimit = { ..._49,
export const ratelimit = { ..._49,
..._50,
..._51,
..._52,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { LimitParams, LimitParamsSDKType } from "./limit_params";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** GenesisState defines the ibcratelimit module's genesis state. */
/** GenesisState defines the ratelimit module's genesis state. */

export interface GenesisState {
/** limit_params_list defines the list of `LimitParams` at genesis. */
limitParamsList: LimitParams[];
}
/** GenesisState defines the ibcratelimit module's genesis state. */
/** GenesisState defines the ratelimit module's genesis state. */

export interface GenesisStateSDKType {
/** limit_params_list defines the list of `LimitParams` at genesis. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class LCDQueryClient {


async listLimitParams(_params: ListLimitParamsRequest = {}): Promise<ListLimitParamsResponseSDKType> {
const endpoint = `dydxprotocol/v4/ibcratelimit/list_limit_params`;
const endpoint = `dydxprotocol/v4/ratelimit/list_limit_params`;
return await this.req.get<ListLimitParamsResponseSDKType>(endpoint);
}
/* Query capacity by denom. */
Expand All @@ -31,7 +31,7 @@ export class LCDQueryClient {
options.params.denom = params.denom;
}

const endpoint = `dydxprotocol/v4/ibcratelimit/capacity_by_denom`;
const endpoint = `dydxprotocol/v4/ratelimit/capacity_by_denom`;
return await this.req.get<QueryCapacityByDenomResponseSDKType>(endpoint, options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export class QueryClientImpl implements Query {

listLimitParams(request: ListLimitParamsRequest = {}): Promise<ListLimitParamsResponse> {
const data = ListLimitParamsRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.ibcratelimit.Query", "ListLimitParams", data);
const promise = this.rpc.request("dydxprotocol.ratelimit.Query", "ListLimitParams", data);
return promise.then(data => ListLimitParamsResponse.decode(new _m0.Reader(data)));
}

capacityByDenom(request: QueryCapacityByDenomRequest): Promise<QueryCapacityByDenomResponse> {
const data = QueryCapacityByDenomRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.ibcratelimit.Query", "CapacityByDenom", data);
const promise = this.rpc.request("dydxprotocol.ratelimit.Query", "CapacityByDenom", data);
return promise.then(data => QueryCapacityByDenomResponse.decode(new _m0.Reader(data)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export class MsgClientImpl implements Msg {

setLimitParams(request: MsgSetLimitParams): Promise<MsgSetLimitParamsResponse> {
const data = MsgSetLimitParams.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.ibcratelimit.Msg", "SetLimitParams", data);
const promise = this.rpc.request("dydxprotocol.ratelimit.Msg", "SetLimitParams", data);
return promise.then(data => MsgSetLimitParamsResponse.decode(new _m0.Reader(data)));
}

deleteLimitParams(request: MsgDeleteLimitParams): Promise<MsgDeleteLimitParamsResponse> {
const data = MsgDeleteLimitParams.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.ibcratelimit.Msg", "DeleteLimitParams", data);
const promise = this.rpc.request("dydxprotocol.ratelimit.Msg", "DeleteLimitParams", data);
return promise.then(data => MsgDeleteLimitParamsResponse.decode(new _m0.Reader(data)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const createLCDClient = async ({
feetiers: new (await import("./feetiers/query.lcd")).LCDQueryClient({
requestClient
}),
ibcratelimit: new (await import("./ibcratelimit/query.lcd")).LCDQueryClient({
ratelimit: new (await import("./ratelimit/query.lcd")).LCDQueryClient({
requestClient
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 NOTE
Codebase verification is a beta feature.

The verification process has revealed that the query.lcd.ts file is still located within the ibcratelimit directory, not the ratelimit directory as would be expected following the PR's objectives and summary. This suggests that the file may not have been correctly renamed or moved according to the changes described in the PR. Please verify the implementation of the file renaming and movement to align with the module reorganization.

  • The query.lcd.ts file is located in the ibcratelimit directory instead of the ratelimit directory.
Analysis chain

The addition of the ratelimit property to the createLCDClient function's return object is consistent with the PR's objectives and the renaming of the module. Ensure that the new import path ./ratelimit/query.lcd is correct and that the file exists.


Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the existence of the `query.lcd.ts` file in the `ratelimit` directory.
fd 'query.lcd.ts' 'indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit'

Length of output: 228



Script:

#!/bin/bash
# Search for the `query.lcd.ts` file within the `ratelimit` directory across the entire codebase.
fd 'query.lcd.ts' --exec echo {} \; | grep 'ratelimit/query.lcd.ts'

Length of output: 148

perpetuals: new (await import("./perpetuals/query.lcd")).LCDQueryClient({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const createRPCQueryClient = async ({
delaymsg: (await import("./delaymsg/query.rpc.Query")).createRpcQueryExtension(client),
epochs: (await import("./epochs/query.rpc.Query")).createRpcQueryExtension(client),
feetiers: (await import("./feetiers/query.rpc.Query")).createRpcQueryExtension(client),
ibcratelimit: (await import("./ibcratelimit/query.rpc.Query")).createRpcQueryExtension(client),
ratelimit: (await import("./ratelimit/query.rpc.Query")).createRpcQueryExtension(client),
perpetuals: (await import("./perpetuals/query.rpc.Query")).createRpcQueryExtension(client),
prices: (await import("./prices/query.rpc.Query")).createRpcQueryExtension(client),
rewards: (await import("./rewards/query.rpc.Query")).createRpcQueryExtension(client),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const createRPCMsgClient = async ({
clob: new (await import("./clob/tx.rpc.msg")).MsgClientImpl(rpc),
delaymsg: new (await import("./delaymsg/tx.rpc.msg")).MsgClientImpl(rpc),
feetiers: new (await import("./feetiers/tx.rpc.msg")).MsgClientImpl(rpc),
ibcratelimit: new (await import("./ibcratelimit/tx.rpc.msg")).MsgClientImpl(rpc),
ratelimit: new (await import("./ratelimit/tx.rpc.msg")).MsgClientImpl(rpc),
perpetuals: new (await import("./perpetuals/tx.rpc.msg")).MsgClientImpl(rpc),
prices: new (await import("./prices/tx.rpc.msg")).MsgClientImpl(rpc),
rewards: new (await import("./rewards/tx.rpc.msg")).MsgClientImpl(rpc),
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 NOTE
Codebase verification is a beta feature.

The verification process has revealed that the ratelimit/tx.rpc.msg.ts file does not exist in the expected directory, which is inconsistent with the changes made in the pull request. The ast-grep command did not produce any output, which is consistent with the file not being present. Therefore, the reference to the ratelimit module in the createRPCMsgClient function cannot be resolved correctly.

  • The ratelimit/tx.rpc.msg.ts file is not present in the indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit directory as expected.
Analysis chain

The change from ibcratelimit to ratelimit in the createRPCMsgClient function aligns with the PR objectives and the renaming of the module. Ensure that the new import path is correct and that all references to the old module name have been updated throughout the codebase.


I will correct the script to properly verify the existence of the new import path and to ensure that the commands for searching for references to ibcratelimit and its usage are accurate.


I will adjust the script to specifically check for the tx.rpc.msg.ts file within the ratelimit directory and verify the presence of the new ratelimit property to ensure the replacement is complete.


I will verify the existence of the ratelimit/tx.rpc.msg.ts file directly and confirm the accuracy of the ast-grep command.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the new import path exists.
fd 'tx.rpc.msg.ts' --exec test -f {} \; -a -d 'src/codegen/dydxprotocol/ratelimit'

# Search for any remaining references to the old module name.
rg 'ibcratelimit'

# Verify that the old property is not used anymore.
ast-grep --lang typescript --pattern $'ibcratelimit: new (await import("./ibcratelimit/tx.rpc.msg")).MsgClientImpl($_)'

Length of output: 372



Script:

#!/bin/bash
# Corrected command to verify the new import path exists by checking for the file within the specified directory.
fd 'tx.rpc.msg.ts' --exec sh -c 'test -f {} && echo {} is present' \;

# Re-run the search for any remaining references to the old module name to confirm the lack of output.
rg 'ibcratelimit'

# Re-run the ast-grep command to confirm that the old property is not used anymore.
ast-grep --lang typescript --pattern $'ibcratelimit: new (await import("./ibcratelimit/tx.rpc.msg")).MsgClientImpl($_)'

Length of output: 1255



Script:

#!/bin/bash
# Adjusted command to specifically check for the tx.rpc.msg.ts file within the ratelimit directory.
fd 'tx.rpc.msg.ts' --exec sh -c 'test -f {} && echo {} is present' \; | grep 'ratelimit/tx.rpc.msg.ts'

# Verify the presence of the new ratelimit property to ensure the replacement is complete.
ast-grep --lang typescript --pattern $'ratelimit: new (await import("./ratelimit/tx.rpc.msg")).MsgClientImpl($_)'

Length of output: 308



Script:

#!/bin/bash
# Directly check for the existence of the ratelimit/tx.rpc.msg.ts file.
test -f ./indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/tx.rpc.msg.ts && echo "ratelimit/tx.rpc.msg.ts is present" || echo "ratelimit/tx.rpc.msg.ts is not present"

# Confirm the accuracy of the ast-grep command for the new ratelimit property.
ast-grep --lang typescript --pattern $'ratelimit: new (await import("./ratelimit/tx.rpc.msg")).MsgClientImpl($_)'

Length of output: 289

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";
package dydxprotocol.ibcratelimit;
package dydxprotocol.ratelimit;

import "gogoproto/gogo.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";
option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types";

// DenomCapacity stores a list of rate limit capacity for a denom.
message DenomCapacity {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
syntax = "proto3";
package dydxprotocol.ibcratelimit;
package dydxprotocol.ratelimit;

import "gogoproto/gogo.proto";
import "dydxprotocol/ibcratelimit/limit_params.proto";
import "dydxprotocol/ratelimit/limit_params.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";
option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types";

// GenesisState defines the ibcratelimit module's genesis state.
// GenesisState defines the ratelimit module's genesis state.
message GenesisState {
// limit_params_list defines the list of `LimitParams` at genesis.
repeated LimitParams limit_params_list = 1 [ (gogoproto.nullable) = false ];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";
package dydxprotocol.ibcratelimit;
package dydxprotocol.ratelimit;

import "gogoproto/gogo.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";
option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types";

// LimitParams defines rate limit params on a denom.
message LimitParams {
Expand All @@ -12,7 +12,7 @@ message LimitParams {
string denom = 1;
// limiters is a list of rate-limiters on this denom. All limiters
// must be satified for a withdrawal to proceed.
repeated Limiter limiters = 2;
repeated Limiter limiters = 2 [ (gogoproto.nullable) = false ];
}

// Limiter defines one rate-limiter on a specfic denom.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
syntax = "proto3";
package dydxprotocol.ibcratelimit;
package dydxprotocol.ratelimit;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "dydxprotocol/ibcratelimit/limit_params.proto";
import "dydxprotocol/ratelimit/limit_params.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";
option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types";

// Query defines the gRPC querier service.
service Query {
// List all limit params.
rpc ListLimitParams(ListLimitParamsRequest)
returns (ListLimitParamsResponse) {
option (google.api.http).get =
"/dydxprotocol/v4/ibcratelimit/list_limit_params";
"/dydxprotocol/v4/ratelimit/list_limit_params";
}

// Query capacity by denom.
rpc CapacityByDenom(QueryCapacityByDenomRequest)
returns (QueryCapacityByDenomResponse) {
option (google.api.http).get =
"/dydxprotocol/v4/ibcratelimit/capacity_by_denom";
"/dydxprotocol/v4/ratelimit/capacity_by_denom";
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
syntax = "proto3";
package dydxprotocol.ibcratelimit;
package dydxprotocol.ratelimit;

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";
option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types";

import "cosmos/msg/v1/msg.proto";
import "dydxprotocol/ibcratelimit/limit_params.proto";
import "dydxprotocol/ratelimit/limit_params.proto";

// Msg defines the Msg service.
service Msg {
Expand Down
20 changes: 20 additions & 0 deletions protocol/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ import (
pricesmodule "github.com/dydxprotocol/v4-chain/protocol/x/prices"
pricesmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/prices/keeper"
pricesmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/prices/types"
ratelimitmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/keeper"
ratelimitmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types"
rewardsmodule "github.com/dydxprotocol/v4-chain/protocol/x/rewards"
rewardsmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/rewards/keeper"
rewardsmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/rewards/types"
Expand Down Expand Up @@ -237,6 +239,7 @@ type App struct {
IBCKeeper *ibckeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
RatelimitKeeper ratelimitmodulekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper

Expand Down Expand Up @@ -343,6 +346,7 @@ func New(
distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
ibcexported.StoreKey, ibctransfertypes.StoreKey,
ratelimitmoduletypes.StoreKey,
evidencetypes.StoreKey,
capabilitytypes.StoreKey,
pricesmoduletypes.StoreKey,
Expand Down Expand Up @@ -533,6 +537,18 @@ func New(
transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)

app.RatelimitKeeper = *ratelimitmodulekeeper.NewKeeper(
appCodec,
keys[ratelimitmoduletypes.StoreKey],
// set the governance and delaymsg module accounts as the authority for conducting upgrades
[]string{
lib.GovModuleAddress.String(),
delaymsgmoduletypes.ModuleAddress.String(),
},
)

// TODO(CORE-834): Add ratelimitKeeper to the IBC transfer stack.

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
Expand Down Expand Up @@ -972,6 +988,7 @@ func New(
stakingtypes.ModuleName,
ibcexported.ModuleName,
ibctransfertypes.ModuleName,
ratelimitmoduletypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
govtypes.ModuleName,
Expand Down Expand Up @@ -1014,6 +1031,7 @@ func New(
upgradetypes.ModuleName,
ibcexported.ModuleName,
ibctransfertypes.ModuleName,
ratelimitmoduletypes.ModuleName,
consensusparamtypes.ModuleName,
pricesmoduletypes.ModuleName,
assetsmoduletypes.ModuleName,
Expand Down Expand Up @@ -1052,6 +1070,7 @@ func New(
paramstypes.ModuleName,
upgradetypes.ModuleName,
ibctransfertypes.ModuleName,
ratelimitmoduletypes.ModuleName,
feegrant.ModuleName,
consensusparamtypes.ModuleName,
pricesmoduletypes.ModuleName,
Expand Down Expand Up @@ -1087,6 +1106,7 @@ func New(
paramstypes.ModuleName,
upgradetypes.ModuleName,
ibctransfertypes.ModuleName,
ratelimitmoduletypes.ModuleName,
feegrant.ModuleName,
consensusparamtypes.ModuleName,
pricesmoduletypes.ModuleName,
Expand Down
49 changes: 0 additions & 49 deletions protocol/x/ibcratelimit/keeper/keeper.go

This file was deleted.

1 change: 0 additions & 1 deletion protocol/x/ibcratelimit/keeper/keeper_test.go

This file was deleted.

3 changes: 0 additions & 3 deletions protocol/x/ibcratelimit/keeper/msg_server_test.go

This file was deleted.

13 changes: 0 additions & 13 deletions protocol/x/ibcratelimit/types/keys.go

This file was deleted.

Loading
Loading