From e545bbfe9512f70e027cc1d12fa2272136d259b1 Mon Sep 17 00:00:00 2001 From: Mohammed Affan Date: Fri, 22 Mar 2024 11:10:28 -0400 Subject: [PATCH] [OTE-221] Add query for PendingSendPacket (#1176) * Add query for PendingSendPacket * update go.mod * lint fixes * newline * protos * proto stuff * update tests * Update protocol/x/ratelimit/types/keys.go Co-authored-by: Teddy Ding * address comments * add error handling * indexer protos * nit --------- Co-authored-by: Teddy Ding --- .../src/codegen/dydxprotocol/bundle.ts | 276 ++++++------ .../ratelimit/pending_send_packet.ts | 75 ++++ .../dydxprotocol/ratelimit/query.lcd.ts | 10 +- .../dydxprotocol/ratelimit/query.rpc.Query.ts | 16 +- .../codegen/dydxprotocol/ratelimit/query.ts | 108 +++++ .../v4-protos/src/codegen/gogoproto/bundle.ts | 4 +- .../v4-protos/src/codegen/google/bundle.ts | 22 +- .../ratelimit/pending_send_packet.proto | 11 + proto/dydxprotocol/ratelimit/query.proto | 18 + protocol/go.mod | 2 +- .../client/cli/pending_send_packets.go | 35 ++ .../client/cli/pending_send_packets_test.go | 30 ++ protocol/x/ratelimit/client/cli/query.go | 1 + protocol/x/ratelimit/keeper/grpc_query.go | 31 ++ .../x/ratelimit/keeper/grpc_query_test.go | 29 ++ protocol/x/ratelimit/module_test.go | 3 +- protocol/x/ratelimit/types/keys.go | 21 +- protocol/x/ratelimit/types/keys_test.go | 11 + .../ratelimit/types/pending_send_packet.pb.go | 356 +++++++++++++++ protocol/x/ratelimit/types/query.pb.go | 404 ++++++++++++++++-- protocol/x/ratelimit/types/query.pb.gw.go | 65 +++ 21 files changed, 1345 insertions(+), 183 deletions(-) create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/pending_send_packet.ts create mode 100644 proto/dydxprotocol/ratelimit/pending_send_packet.proto create mode 100644 protocol/x/ratelimit/client/cli/pending_send_packets.go create mode 100644 protocol/x/ratelimit/client/cli/pending_send_packets_test.go create mode 100644 protocol/x/ratelimit/types/pending_send_packet.pb.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts index 499e146f14..4cf72f481d 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts @@ -67,99 +67,100 @@ import * as _70 from "./prices/tx"; import * as _71 from "./ratelimit/capacity"; import * as _72 from "./ratelimit/genesis"; import * as _73 from "./ratelimit/limit_params"; -import * as _74 from "./ratelimit/query"; -import * as _75 from "./ratelimit/tx"; -import * as _76 from "./rewards/genesis"; -import * as _77 from "./rewards/params"; -import * as _78 from "./rewards/query"; -import * as _79 from "./rewards/reward_share"; -import * as _80 from "./rewards/tx"; -import * as _81 from "./sending/genesis"; -import * as _82 from "./sending/query"; -import * as _83 from "./sending/transfer"; -import * as _84 from "./sending/tx"; -import * as _85 from "./stats/genesis"; -import * as _86 from "./stats/params"; -import * as _87 from "./stats/query"; -import * as _88 from "./stats/stats"; -import * as _89 from "./stats/tx"; -import * as _90 from "./subaccounts/asset_position"; -import * as _91 from "./subaccounts/genesis"; -import * as _92 from "./subaccounts/perpetual_position"; -import * as _93 from "./subaccounts/query"; -import * as _94 from "./subaccounts/subaccount"; -import * as _95 from "./vault/genesis"; -import * as _96 from "./vault/query"; -import * as _97 from "./vault/tx"; -import * as _98 from "./vault/vault"; -import * as _99 from "./vest/genesis"; -import * as _100 from "./vest/query"; -import * as _101 from "./vest/tx"; -import * as _102 from "./vest/vest_entry"; -import * as _110 from "./assets/query.lcd"; -import * as _111 from "./blocktime/query.lcd"; -import * as _112 from "./bridge/query.lcd"; -import * as _113 from "./clob/query.lcd"; -import * as _114 from "./delaymsg/query.lcd"; -import * as _115 from "./epochs/query.lcd"; -import * as _116 from "./feetiers/query.lcd"; -import * as _117 from "./perpetuals/query.lcd"; -import * as _118 from "./prices/query.lcd"; -import * as _119 from "./ratelimit/query.lcd"; -import * as _120 from "./rewards/query.lcd"; -import * as _121 from "./stats/query.lcd"; -import * as _122 from "./subaccounts/query.lcd"; -import * as _123 from "./vest/query.lcd"; -import * as _124 from "./assets/query.rpc.Query"; -import * as _125 from "./blocktime/query.rpc.Query"; -import * as _126 from "./bridge/query.rpc.Query"; -import * as _127 from "./clob/query.rpc.Query"; -import * as _128 from "./delaymsg/query.rpc.Query"; -import * as _129 from "./epochs/query.rpc.Query"; -import * as _130 from "./feetiers/query.rpc.Query"; -import * as _131 from "./govplus/query.rpc.Query"; -import * as _132 from "./perpetuals/query.rpc.Query"; -import * as _133 from "./prices/query.rpc.Query"; -import * as _134 from "./ratelimit/query.rpc.Query"; -import * as _135 from "./rewards/query.rpc.Query"; -import * as _136 from "./sending/query.rpc.Query"; -import * as _137 from "./stats/query.rpc.Query"; -import * as _138 from "./subaccounts/query.rpc.Query"; -import * as _139 from "./vault/query.rpc.Query"; -import * as _140 from "./vest/query.rpc.Query"; -import * as _141 from "./blocktime/tx.rpc.msg"; -import * as _142 from "./bridge/tx.rpc.msg"; -import * as _143 from "./clob/tx.rpc.msg"; -import * as _144 from "./delaymsg/tx.rpc.msg"; -import * as _145 from "./feetiers/tx.rpc.msg"; -import * as _146 from "./govplus/tx.rpc.msg"; -import * as _147 from "./perpetuals/tx.rpc.msg"; -import * as _148 from "./prices/tx.rpc.msg"; -import * as _149 from "./ratelimit/tx.rpc.msg"; -import * as _150 from "./rewards/tx.rpc.msg"; -import * as _151 from "./sending/tx.rpc.msg"; -import * as _152 from "./stats/tx.rpc.msg"; -import * as _153 from "./vault/tx.rpc.msg"; -import * as _154 from "./vest/tx.rpc.msg"; -import * as _155 from "./lcd"; -import * as _156 from "./rpc.query"; -import * as _157 from "./rpc.tx"; +import * as _74 from "./ratelimit/pending_send_packet"; +import * as _75 from "./ratelimit/query"; +import * as _76 from "./ratelimit/tx"; +import * as _77 from "./rewards/genesis"; +import * as _78 from "./rewards/params"; +import * as _79 from "./rewards/query"; +import * as _80 from "./rewards/reward_share"; +import * as _81 from "./rewards/tx"; +import * as _82 from "./sending/genesis"; +import * as _83 from "./sending/query"; +import * as _84 from "./sending/transfer"; +import * as _85 from "./sending/tx"; +import * as _86 from "./stats/genesis"; +import * as _87 from "./stats/params"; +import * as _88 from "./stats/query"; +import * as _89 from "./stats/stats"; +import * as _90 from "./stats/tx"; +import * as _91 from "./subaccounts/asset_position"; +import * as _92 from "./subaccounts/genesis"; +import * as _93 from "./subaccounts/perpetual_position"; +import * as _94 from "./subaccounts/query"; +import * as _95 from "./subaccounts/subaccount"; +import * as _96 from "./vault/genesis"; +import * as _97 from "./vault/query"; +import * as _98 from "./vault/tx"; +import * as _99 from "./vault/vault"; +import * as _100 from "./vest/genesis"; +import * as _101 from "./vest/query"; +import * as _102 from "./vest/tx"; +import * as _103 from "./vest/vest_entry"; +import * as _111 from "./assets/query.lcd"; +import * as _112 from "./blocktime/query.lcd"; +import * as _113 from "./bridge/query.lcd"; +import * as _114 from "./clob/query.lcd"; +import * as _115 from "./delaymsg/query.lcd"; +import * as _116 from "./epochs/query.lcd"; +import * as _117 from "./feetiers/query.lcd"; +import * as _118 from "./perpetuals/query.lcd"; +import * as _119 from "./prices/query.lcd"; +import * as _120 from "./ratelimit/query.lcd"; +import * as _121 from "./rewards/query.lcd"; +import * as _122 from "./stats/query.lcd"; +import * as _123 from "./subaccounts/query.lcd"; +import * as _124 from "./vest/query.lcd"; +import * as _125 from "./assets/query.rpc.Query"; +import * as _126 from "./blocktime/query.rpc.Query"; +import * as _127 from "./bridge/query.rpc.Query"; +import * as _128 from "./clob/query.rpc.Query"; +import * as _129 from "./delaymsg/query.rpc.Query"; +import * as _130 from "./epochs/query.rpc.Query"; +import * as _131 from "./feetiers/query.rpc.Query"; +import * as _132 from "./govplus/query.rpc.Query"; +import * as _133 from "./perpetuals/query.rpc.Query"; +import * as _134 from "./prices/query.rpc.Query"; +import * as _135 from "./ratelimit/query.rpc.Query"; +import * as _136 from "./rewards/query.rpc.Query"; +import * as _137 from "./sending/query.rpc.Query"; +import * as _138 from "./stats/query.rpc.Query"; +import * as _139 from "./subaccounts/query.rpc.Query"; +import * as _140 from "./vault/query.rpc.Query"; +import * as _141 from "./vest/query.rpc.Query"; +import * as _142 from "./blocktime/tx.rpc.msg"; +import * as _143 from "./bridge/tx.rpc.msg"; +import * as _144 from "./clob/tx.rpc.msg"; +import * as _145 from "./delaymsg/tx.rpc.msg"; +import * as _146 from "./feetiers/tx.rpc.msg"; +import * as _147 from "./govplus/tx.rpc.msg"; +import * as _148 from "./perpetuals/tx.rpc.msg"; +import * as _149 from "./prices/tx.rpc.msg"; +import * as _150 from "./ratelimit/tx.rpc.msg"; +import * as _151 from "./rewards/tx.rpc.msg"; +import * as _152 from "./sending/tx.rpc.msg"; +import * as _153 from "./stats/tx.rpc.msg"; +import * as _154 from "./vault/tx.rpc.msg"; +import * as _155 from "./vest/tx.rpc.msg"; +import * as _156 from "./lcd"; +import * as _157 from "./rpc.query"; +import * as _158 from "./rpc.tx"; export namespace dydxprotocol { export const assets = { ..._5, ..._6, ..._7, ..._8, - ..._110, - ..._124 + ..._111, + ..._125 }; export const blocktime = { ..._9, ..._10, ..._11, ..._12, ..._13, - ..._111, - ..._125, - ..._141 + ..._112, + ..._126, + ..._142 }; export const bridge = { ..._14, ..._15, @@ -167,9 +168,9 @@ export namespace dydxprotocol { ..._17, ..._18, ..._19, - ..._112, - ..._126, - ..._142 + ..._113, + ..._127, + ..._143 }; export const clob = { ..._20, ..._21, @@ -185,9 +186,9 @@ export namespace dydxprotocol { ..._31, ..._32, ..._33, - ..._113, - ..._127, - ..._143 + ..._114, + ..._128, + ..._144 }; export namespace daemons { export const bridge = { ..._34 @@ -202,29 +203,29 @@ export namespace dydxprotocol { ..._39, ..._40, ..._41, - ..._114, - ..._128, - ..._144 + ..._115, + ..._129, + ..._145 }; export const epochs = { ..._42, ..._43, ..._44, - ..._115, - ..._129 + ..._116, + ..._130 }; export const feetiers = { ..._45, ..._46, ..._47, ..._48, - ..._116, - ..._130, - ..._145 + ..._117, + ..._131, + ..._146 }; export const govplus = { ..._49, ..._50, ..._51, - ..._131, - ..._146 + ..._132, + ..._147 }; export namespace indexer { export const events = { ..._52 @@ -251,78 +252,79 @@ export namespace dydxprotocol { ..._63, ..._64, ..._65, - ..._117, - ..._132, - ..._147 + ..._118, + ..._133, + ..._148 }; export const prices = { ..._66, ..._67, ..._68, ..._69, ..._70, - ..._118, - ..._133, - ..._148 + ..._119, + ..._134, + ..._149 }; export const ratelimit = { ..._71, ..._72, ..._73, ..._74, ..._75, - ..._119, - ..._134, - ..._149 + ..._76, + ..._120, + ..._135, + ..._150 }; - export const rewards = { ..._76, - ..._77, + export const rewards = { ..._77, ..._78, ..._79, ..._80, - ..._120, - ..._135, - ..._150 + ..._81, + ..._121, + ..._136, + ..._151 }; - export const sending = { ..._81, - ..._82, + export const sending = { ..._82, ..._83, ..._84, - ..._136, - ..._151 + ..._85, + ..._137, + ..._152 }; - export const stats = { ..._85, - ..._86, + export const stats = { ..._86, ..._87, ..._88, ..._89, - ..._121, - ..._137, - ..._152 + ..._90, + ..._122, + ..._138, + ..._153 }; - export const subaccounts = { ..._90, - ..._91, + export const subaccounts = { ..._91, ..._92, ..._93, ..._94, - ..._122, - ..._138 + ..._95, + ..._123, + ..._139 }; - export const vault = { ..._95, - ..._96, + export const vault = { ..._96, ..._97, ..._98, - ..._139, - ..._153 + ..._99, + ..._140, + ..._154 }; - export const vest = { ..._99, - ..._100, + export const vest = { ..._100, ..._101, ..._102, - ..._123, - ..._140, - ..._154 + ..._103, + ..._124, + ..._141, + ..._155 }; - export const ClientFactory = { ..._155, - ..._156, - ..._157 + export const ClientFactory = { ..._156, + ..._157, + ..._158 }; } \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/pending_send_packet.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/pending_send_packet.ts new file mode 100644 index 0000000000..e2b8b10de9 --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/pending_send_packet.ts @@ -0,0 +1,75 @@ +import * as _m0 from "protobufjs/minimal"; +import { Long, DeepPartial } from "../../helpers"; +/** + * PendingSendPacket contains the channel_id and sequence pair to identify a + * pending packet + */ + +export interface PendingSendPacket { + channelId: string; + sequence: Long; +} +/** + * PendingSendPacket contains the channel_id and sequence pair to identify a + * pending packet + */ + +export interface PendingSendPacketSDKType { + channel_id: string; + sequence: Long; +} + +function createBasePendingSendPacket(): PendingSendPacket { + return { + channelId: "", + sequence: Long.UZERO + }; +} + +export const PendingSendPacket = { + encode(message: PendingSendPacket, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.channelId !== "") { + writer.uint32(10).string(message.channelId); + } + + if (!message.sequence.isZero()) { + writer.uint32(16).uint64(message.sequence); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): PendingSendPacket { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePendingSendPacket(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.channelId = reader.string(); + break; + + case 2: + message.sequence = (reader.uint64() as Long); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): PendingSendPacket { + const message = createBasePendingSendPacket(); + message.channelId = object.channelId ?? ""; + message.sequence = object.sequence !== undefined && object.sequence !== null ? Long.fromValue(object.sequence) : Long.UZERO; + return message; + } + +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.lcd.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.lcd.ts index 88809acdff..24d3f27edc 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.lcd.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.lcd.ts @@ -1,5 +1,5 @@ import { LCDClient } from "@osmonauts/lcd"; -import { ListLimitParamsRequest, ListLimitParamsResponseSDKType, QueryCapacityByDenomRequest, QueryCapacityByDenomResponseSDKType } from "./query"; +import { ListLimitParamsRequest, ListLimitParamsResponseSDKType, QueryCapacityByDenomRequest, QueryCapacityByDenomResponseSDKType, QueryAllPendingSendPacketsRequest, QueryAllPendingSendPacketsResponseSDKType } from "./query"; export class LCDQueryClient { req: LCDClient; @@ -11,6 +11,7 @@ export class LCDQueryClient { this.req = requestClient; this.listLimitParams = this.listLimitParams.bind(this); this.capacityByDenom = this.capacityByDenom.bind(this); + this.allPendingSendPackets = this.allPendingSendPackets.bind(this); } /* List all limit params. */ @@ -34,5 +35,12 @@ export class LCDQueryClient { const endpoint = `dydxprotocol/v4/ratelimit/capacity_by_denom`; return await this.req.get(endpoint, options); } + /* Get all pending send packets */ + + + async allPendingSendPackets(_params: QueryAllPendingSendPacketsRequest = {}): Promise { + const endpoint = `dydxprotocol/v4/ratelimit/get_all_pending_send_packet`; + return await this.req.get(endpoint); + } } \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.rpc.Query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.rpc.Query.ts index c617aa46f4..70cf931a86 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.rpc.Query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.rpc.Query.ts @@ -1,7 +1,7 @@ import { Rpc } from "../../helpers"; import * as _m0 from "protobufjs/minimal"; import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; -import { ListLimitParamsRequest, ListLimitParamsResponse, QueryCapacityByDenomRequest, QueryCapacityByDenomResponse } from "./query"; +import { ListLimitParamsRequest, ListLimitParamsResponse, QueryCapacityByDenomRequest, QueryCapacityByDenomResponse, QueryAllPendingSendPacketsRequest, QueryAllPendingSendPacketsResponse } from "./query"; /** Query defines the gRPC querier service. */ export interface Query { @@ -10,6 +10,9 @@ export interface Query { /** Query capacity by denom. */ capacityByDenom(request: QueryCapacityByDenomRequest): Promise; + /** Get all pending send packets */ + + allPendingSendPackets(request?: QueryAllPendingSendPacketsRequest): Promise; } export class QueryClientImpl implements Query { private readonly rpc: Rpc; @@ -18,6 +21,7 @@ export class QueryClientImpl implements Query { this.rpc = rpc; this.listLimitParams = this.listLimitParams.bind(this); this.capacityByDenom = this.capacityByDenom.bind(this); + this.allPendingSendPackets = this.allPendingSendPackets.bind(this); } listLimitParams(request: ListLimitParamsRequest = {}): Promise { @@ -32,6 +36,12 @@ export class QueryClientImpl implements Query { return promise.then(data => QueryCapacityByDenomResponse.decode(new _m0.Reader(data))); } + allPendingSendPackets(request: QueryAllPendingSendPacketsRequest = {}): Promise { + const data = QueryAllPendingSendPacketsRequest.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.ratelimit.Query", "AllPendingSendPackets", data); + return promise.then(data => QueryAllPendingSendPacketsResponse.decode(new _m0.Reader(data))); + } + } export const createRpcQueryExtension = (base: QueryClient) => { const rpc = createProtobufRpcClient(base); @@ -43,6 +53,10 @@ export const createRpcQueryExtension = (base: QueryClient) => { capacityByDenom(request: QueryCapacityByDenomRequest): Promise { return queryService.capacityByDenom(request); + }, + + allPendingSendPackets(request?: QueryAllPendingSendPacketsRequest): Promise { + return queryService.allPendingSendPackets(request); } }; diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.ts index 8274347939..32846a6805 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/ratelimit/query.ts @@ -1,5 +1,6 @@ import { LimitParams, LimitParamsSDKType } from "./limit_params"; import { LimiterCapacity, LimiterCapacitySDKType } from "./capacity"; +import { PendingSendPacket, PendingSendPacketSDKType } from "./pending_send_packet"; import * as _m0 from "protobufjs/minimal"; import { DeepPartial } from "../../helpers"; /** ListLimitParamsRequest is a request type of the ListLimitParams RPC method. */ @@ -58,6 +59,34 @@ export interface QueryCapacityByDenomResponse { export interface QueryCapacityByDenomResponseSDKType { limiter_capacity_list: LimiterCapacitySDKType[]; } +/** + * QueryAllPendingSendPacketsRequest is a request type for the + * AllPendingSendPackets RPC + */ + +export interface QueryAllPendingSendPacketsRequest {} +/** + * QueryAllPendingSendPacketsRequest is a request type for the + * AllPendingSendPackets RPC + */ + +export interface QueryAllPendingSendPacketsRequestSDKType {} +/** + * QueryAllPendingSendPacketsResponse is a response type of the + * AllPendingSendPackets RPC + */ + +export interface QueryAllPendingSendPacketsResponse { + pendingSendPackets: PendingSendPacket[]; +} +/** + * QueryAllPendingSendPacketsResponse is a response type of the + * AllPendingSendPackets RPC + */ + +export interface QueryAllPendingSendPacketsResponseSDKType { + pending_send_packets: PendingSendPacketSDKType[]; +} function createBaseListLimitParamsRequest(): ListLimitParamsRequest { return {}; @@ -226,4 +255,83 @@ export const QueryCapacityByDenomResponse = { return message; } +}; + +function createBaseQueryAllPendingSendPacketsRequest(): QueryAllPendingSendPacketsRequest { + return {}; +} + +export const QueryAllPendingSendPacketsRequest = { + encode(_: QueryAllPendingSendPacketsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllPendingSendPacketsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllPendingSendPacketsRequest(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(_: DeepPartial): QueryAllPendingSendPacketsRequest { + const message = createBaseQueryAllPendingSendPacketsRequest(); + return message; + } + +}; + +function createBaseQueryAllPendingSendPacketsResponse(): QueryAllPendingSendPacketsResponse { + return { + pendingSendPackets: [] + }; +} + +export const QueryAllPendingSendPacketsResponse = { + encode(message: QueryAllPendingSendPacketsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.pendingSendPackets) { + PendingSendPacket.encode(v!, writer.uint32(10).fork()).ldelim(); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllPendingSendPacketsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllPendingSendPacketsResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.pendingSendPackets.push(PendingSendPacket.decode(reader, reader.uint32())); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): QueryAllPendingSendPacketsResponse { + const message = createBaseQueryAllPendingSendPacketsResponse(); + message.pendingSendPackets = object.pendingSendPackets?.map(e => PendingSendPacket.fromPartial(e)) || []; + return message; + } + }; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts index c3b6b38b3f..1a8dc184de 100644 --- a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts @@ -1,3 +1,3 @@ -import * as _103 from "./gogo"; -export const gogoproto = { ..._103 +import * as _104 from "./gogo"; +export const gogoproto = { ..._104 }; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/google/bundle.ts b/indexer/packages/v4-protos/src/codegen/google/bundle.ts index 8878e6797b..3ae0e3f38d 100644 --- a/indexer/packages/v4-protos/src/codegen/google/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/google/bundle.ts @@ -1,16 +1,16 @@ -import * as _104 from "./api/annotations"; -import * as _105 from "./api/http"; -import * as _106 from "./protobuf/descriptor"; -import * as _107 from "./protobuf/duration"; -import * as _108 from "./protobuf/timestamp"; -import * as _109 from "./protobuf/any"; +import * as _105 from "./api/annotations"; +import * as _106 from "./api/http"; +import * as _107 from "./protobuf/descriptor"; +import * as _108 from "./protobuf/duration"; +import * as _109 from "./protobuf/timestamp"; +import * as _110 from "./protobuf/any"; export namespace google { - export const api = { ..._104, - ..._105 + export const api = { ..._105, + ..._106 }; - export const protobuf = { ..._106, - ..._107, + export const protobuf = { ..._107, ..._108, - ..._109 + ..._109, + ..._110 }; } \ No newline at end of file diff --git a/proto/dydxprotocol/ratelimit/pending_send_packet.proto b/proto/dydxprotocol/ratelimit/pending_send_packet.proto new file mode 100644 index 0000000000..e52677c4e9 --- /dev/null +++ b/proto/dydxprotocol/ratelimit/pending_send_packet.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package dydxprotocol.ratelimit; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types"; + +// PendingSendPacket contains the channel_id and sequence pair to identify a +// pending packet +message PendingSendPacket { + string channel_id = 1; + uint64 sequence = 2; +} \ No newline at end of file diff --git a/proto/dydxprotocol/ratelimit/query.proto b/proto/dydxprotocol/ratelimit/query.proto index 47ab6e62fb..ad462251d4 100644 --- a/proto/dydxprotocol/ratelimit/query.proto +++ b/proto/dydxprotocol/ratelimit/query.proto @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "dydxprotocol/ratelimit/limit_params.proto"; import "dydxprotocol/ratelimit/capacity.proto"; +import "dydxprotocol/ratelimit/pending_send_packet.proto"; option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types"; @@ -23,6 +24,12 @@ service Query { option (google.api.http).get = "/dydxprotocol/v4/ratelimit/capacity_by_denom"; } + // Get all pending send packets + rpc AllPendingSendPackets(QueryAllPendingSendPacketsRequest) + returns (QueryAllPendingSendPacketsResponse) { + option (google.api.http).get = + "/dydxprotocol/v4/ratelimit/get_all_pending_send_packet"; + } } // ListLimitParamsRequest is a request type of the ListLimitParams RPC method. @@ -43,3 +50,14 @@ message QueryCapacityByDenomResponse { repeated LimiterCapacity limiter_capacity_list = 1 [ (gogoproto.nullable) = false ]; } + +// QueryAllPendingSendPacketsRequest is a request type for the +// AllPendingSendPackets RPC +message QueryAllPendingSendPacketsRequest {} + +// QueryAllPendingSendPacketsResponse is a response type of the +// AllPendingSendPackets RPC +message QueryAllPendingSendPacketsResponse { + repeated PendingSendPacket pending_send_packets = 1 + [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/protocol/go.mod b/protocol/go.mod index 34d7031d46..4303d3034d 100644 --- a/protocol/go.mod +++ b/protocol/go.mod @@ -72,6 +72,7 @@ require ( go.uber.org/zap v1.27.0 google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 google.golang.org/protobuf v1.32.0 + gotest.tools/v3 v3.5.1 ) require ( @@ -413,7 +414,6 @@ require ( gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - gotest.tools/v3 v3.5.1 // indirect honnef.co/go/tools v0.4.6 // indirect mvdan.cc/gofumpt v0.6.0 // indirect mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect diff --git a/protocol/x/ratelimit/client/cli/pending_send_packets.go b/protocol/x/ratelimit/client/cli/pending_send_packets.go new file mode 100644 index 0000000000..6ea4e4d2c8 --- /dev/null +++ b/protocol/x/ratelimit/client/cli/pending_send_packets.go @@ -0,0 +1,35 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types" + "github.com/spf13/cobra" +) + +func CmdPendingSendPackets() *cobra.Command { + cmd := &cobra.Command{ + Use: "pending-send-packets", + Short: "gets all pending send packets", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.AllPendingSendPackets(cmd.Context(), &types.QueryAllPendingSendPacketsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/protocol/x/ratelimit/client/cli/pending_send_packets_test.go b/protocol/x/ratelimit/client/cli/pending_send_packets_test.go new file mode 100644 index 0000000000..4af1b6abb0 --- /dev/null +++ b/protocol/x/ratelimit/client/cli/pending_send_packets_test.go @@ -0,0 +1,30 @@ +//go:build all || integration_test + +package cli_test + +import ( + "fmt" + "testing" + + tmcli "github.com/cometbft/cometbft/libs/cli" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/client/cli" + "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types" + "github.com/stretchr/testify/require" + "gotest.tools/v3/assert" +) + +func TestPendingSendPackets(t *testing.T) { + net, ctx := setupNetwork(t) + + out, err := clitestutil.ExecTestCLICmd(ctx, + cli.CmdPendingSendPackets(), + []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }) + + require.NoError(t, err) + var resp types.QueryAllPendingSendPacketsResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + assert.Equal(t, 0, len(resp.PendingSendPackets)) +} diff --git a/protocol/x/ratelimit/client/cli/query.go b/protocol/x/ratelimit/client/cli/query.go index c031087082..2908d00a4e 100644 --- a/protocol/x/ratelimit/client/cli/query.go +++ b/protocol/x/ratelimit/client/cli/query.go @@ -22,6 +22,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdListLimitParams()) cmd.AddCommand(CmdQueryCapacityByDenom()) + cmd.AddCommand(CmdPendingSendPackets()) return cmd } diff --git a/protocol/x/ratelimit/keeper/grpc_query.go b/protocol/x/ratelimit/keeper/grpc_query.go index a73a8eaf11..42cf8c6ea3 100644 --- a/protocol/x/ratelimit/keeper/grpc_query.go +++ b/protocol/x/ratelimit/keeper/grpc_query.go @@ -3,7 +3,9 @@ package keeper import ( "context" + "cosmossdk.io/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dydxprotocol/v4-chain/protocol/lib/log" "github.com/dydxprotocol/v4-chain/protocol/x/ratelimit/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -47,3 +49,32 @@ func (k Keeper) CapacityByDenom( LimiterCapacityList: limiterCapacityList, }, nil } + +func (k Keeper) AllPendingSendPackets( + ctx context.Context, + req *types.QueryAllPendingSendPacketsRequest, +) (*types.QueryAllPendingSendPacketsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + sdkCtx := sdk.UnwrapSDKContext(ctx) + + store := prefix.NewStore(sdkCtx.KVStore(k.storeKey), []byte(types.PendingSendPacketPrefix)) + pendingPackets := make([]types.PendingSendPacket, 0) + iterator := store.Iterator(nil, nil) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + channelId, sequence, err := types.SplitPendingSendPacketKey(iterator.Key()) + if err != nil { + log.ErrorLog(sdkCtx, "unexpected PendingSendPacket key format", err) + return nil, err + } + pendingPackets = append(pendingPackets, types.PendingSendPacket{ + ChannelId: channelId, + Sequence: sequence, + }) + } + return &types.QueryAllPendingSendPacketsResponse{ + PendingSendPackets: pendingPackets, + }, nil +} diff --git a/protocol/x/ratelimit/keeper/grpc_query_test.go b/protocol/x/ratelimit/keeper/grpc_query_test.go index d726455cf7..c7a788c393 100644 --- a/protocol/x/ratelimit/keeper/grpc_query_test.go +++ b/protocol/x/ratelimit/keeper/grpc_query_test.go @@ -139,3 +139,32 @@ func TestCapacityByDenom(t *testing.T) { }) } } + +func TestGetAllPendingSendPacket(t *testing.T) { + tApp := testapp.NewTestAppBuilder(t).Build() + ctx := tApp.InitChain() + k := tApp.App.RatelimitKeeper + + channels := []string{"channel-0", "channel-1"} + sequences := []uint64{20, 22} + + for i := range channels { + k.SetPendingSendPacket(ctx, channels[i], sequences[i]) + } + + req := &types.QueryAllPendingSendPacketsRequest{} + res, err := k.AllPendingSendPackets(ctx, req) + require.NoError(t, err) + require.Equal(t, &types.QueryAllPendingSendPacketsResponse{ + PendingSendPackets: []types.PendingSendPacket{ + { + ChannelId: channels[0], + Sequence: sequences[0], + }, + { + ChannelId: channels[1], + Sequence: sequences[1], + }, + }, + }, res) +} diff --git a/protocol/x/ratelimit/module_test.go b/protocol/x/ratelimit/module_test.go index 1ac9620a5e..fe9b96fe96 100644 --- a/protocol/x/ratelimit/module_test.go +++ b/protocol/x/ratelimit/module_test.go @@ -132,7 +132,8 @@ func TestAppModuleBasic_GetQueryCmd(t *testing.T) { cmd := am.GetQueryCmd() require.Equal(t, "ratelimit", cmd.Use) - require.Equal(t, 2, len(cmd.Commands())) + require.Equal(t, 3, len(cmd.Commands())) require.Equal(t, "capacity-by-denom", cmd.Commands()[0].Name()) require.Equal(t, "list-limit-params", cmd.Commands()[1].Name()) + require.Equal(t, "pending-send-packets", cmd.Commands()[2].Name()) } diff --git a/protocol/x/ratelimit/types/keys.go b/protocol/x/ratelimit/types/keys.go index 5477868046..356e6005ff 100644 --- a/protocol/x/ratelimit/types/keys.go +++ b/protocol/x/ratelimit/types/keys.go @@ -1,6 +1,10 @@ package types -import fmt "fmt" +import ( + "bytes" + "fmt" + "strconv" +) // Module name and store keys const ( @@ -27,3 +31,18 @@ const () func GetPendingSendPacketKey(channelId string, sequenceNumber uint64) []byte { return []byte(fmt.Sprintf("%s_%d", channelId, sequenceNumber)) } + +func SplitPendingSendPacketKey(key []byte) (string, uint64, error) { + err := error(nil) + parts := bytes.Split(key, []byte("_")) + if len(parts) != 2 { + err = fmt.Errorf("unexpected PendingSendPacket key format: %s", key) + return "", 0, err + } + channelId := string(parts[0]) + + // convert parts[1] to uint64 parts[1] is a byte array with numeric characters of variable length + sequenceNumberInt, _ := strconv.Atoi(string(parts[1])) + sequenceNumber := uint64(sequenceNumberInt) + return channelId, sequenceNumber, err +} diff --git a/protocol/x/ratelimit/types/keys_test.go b/protocol/x/ratelimit/types/keys_test.go index b2e9cb16e4..25b0edebec 100644 --- a/protocol/x/ratelimit/types/keys_test.go +++ b/protocol/x/ratelimit/types/keys_test.go @@ -16,3 +16,14 @@ func TestStateKeys(t *testing.T) { require.Equal(t, "DenomCapacity:", types.DenomCapacityKeyPrefix) require.Equal(t, "LimitParams:", types.LimitParamsKeyPrefix) } + +func TestSplitPendingSendPacketKey(t *testing.T) { + channelId := "channel-0" + sequenceNumber := uint64(2) + channelIdReceived, sequenceNumberReceived, err := types.SplitPendingSendPacketKey( + types.GetPendingSendPacketKey(channelId, sequenceNumber), + ) + require.NoError(t, err) + require.Equal(t, channelId, channelIdReceived) + require.Equal(t, sequenceNumber, sequenceNumberReceived) +} diff --git a/protocol/x/ratelimit/types/pending_send_packet.pb.go b/protocol/x/ratelimit/types/pending_send_packet.pb.go new file mode 100644 index 0000000000..64a789df7c --- /dev/null +++ b/protocol/x/ratelimit/types/pending_send_packet.pb.go @@ -0,0 +1,356 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/ratelimit/pending_send_packet.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// PendingSendPacket contains the channel_id and sequence pair to identify a +// pending packet +type PendingSendPacket struct { + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *PendingSendPacket) Reset() { *m = PendingSendPacket{} } +func (m *PendingSendPacket) String() string { return proto.CompactTextString(m) } +func (*PendingSendPacket) ProtoMessage() {} +func (*PendingSendPacket) Descriptor() ([]byte, []int) { + return fileDescriptor_0fa331693b6a2ba4, []int{0} +} +func (m *PendingSendPacket) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PendingSendPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PendingSendPacket.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PendingSendPacket) XXX_Merge(src proto.Message) { + xxx_messageInfo_PendingSendPacket.Merge(m, src) +} +func (m *PendingSendPacket) XXX_Size() int { + return m.Size() +} +func (m *PendingSendPacket) XXX_DiscardUnknown() { + xxx_messageInfo_PendingSendPacket.DiscardUnknown(m) +} + +var xxx_messageInfo_PendingSendPacket proto.InternalMessageInfo + +func (m *PendingSendPacket) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *PendingSendPacket) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +func init() { + proto.RegisterType((*PendingSendPacket)(nil), "dydxprotocol.ratelimit.PendingSendPacket") +} + +func init() { + proto.RegisterFile("dydxprotocol/ratelimit/pending_send_packet.proto", fileDescriptor_0fa331693b6a2ba4) +} + +var fileDescriptor_0fa331693b6a2ba4 = []byte{ + // 206 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x48, 0xa9, 0x4c, 0xa9, + 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x2f, 0x4a, 0x2c, 0x49, 0xcd, 0xc9, 0xcc, + 0xcd, 0x2c, 0xd1, 0x2f, 0x48, 0xcd, 0x4b, 0xc9, 0xcc, 0x4b, 0x8f, 0x2f, 0x4e, 0xcd, 0x4b, 0x89, + 0x2f, 0x48, 0x4c, 0xce, 0x4e, 0x2d, 0xd1, 0x03, 0x2b, 0x13, 0x12, 0x43, 0xd6, 0xa1, 0x07, 0xd7, + 0xa1, 0xe4, 0xc7, 0x25, 0x18, 0x00, 0xd1, 0x14, 0x9c, 0x9a, 0x97, 0x12, 0x00, 0xd6, 0x22, 0x24, + 0xcb, 0xc5, 0x95, 0x9c, 0x91, 0x98, 0x97, 0x97, 0x9a, 0x13, 0x9f, 0x99, 0x22, 0xc1, 0xa8, 0xc0, + 0xa8, 0xc1, 0x19, 0xc4, 0x09, 0x15, 0xf1, 0x4c, 0x11, 0x92, 0xe2, 0xe2, 0x28, 0x4e, 0x2d, 0x2c, + 0x4d, 0xcd, 0x4b, 0x4e, 0x95, 0x60, 0x52, 0x60, 0xd4, 0x60, 0x09, 0x82, 0xf3, 0x9d, 0x42, 0x4f, + 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, + 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x3a, 0x3d, 0xb3, 0x24, 0xa3, 0x34, + 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xc5, 0xf9, 0x65, 0x26, 0xba, 0xc9, 0x19, 0x89, 0x99, 0x79, + 0xfa, 0x70, 0x91, 0x0a, 0x24, 0x2f, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xe5, 0x8c, + 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x41, 0x30, 0xc9, 0xf2, 0xf9, 0x00, 0x00, 0x00, +} + +func (m *PendingSendPacket) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PendingSendPacket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PendingSendPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintPendingSendPacket(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintPendingSendPacket(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintPendingSendPacket(dAtA []byte, offset int, v uint64) int { + offset -= sovPendingSendPacket(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PendingSendPacket) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovPendingSendPacket(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovPendingSendPacket(uint64(m.Sequence)) + } + return n +} + +func sovPendingSendPacket(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPendingSendPacket(x uint64) (n int) { + return sovPendingSendPacket(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PendingSendPacket) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPendingSendPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PendingSendPacket: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PendingSendPacket: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPendingSendPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPendingSendPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPendingSendPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPendingSendPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPendingSendPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPendingSendPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPendingSendPacket(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPendingSendPacket + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPendingSendPacket + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPendingSendPacket + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPendingSendPacket + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPendingSendPacket + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPendingSendPacket + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPendingSendPacket = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPendingSendPacket = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPendingSendPacket = fmt.Errorf("proto: unexpected end of group") +) diff --git a/protocol/x/ratelimit/types/query.pb.go b/protocol/x/ratelimit/types/query.pb.go index 184ff22ca1..ae4e013110 100644 --- a/protocol/x/ratelimit/types/query.pb.go +++ b/protocol/x/ratelimit/types/query.pb.go @@ -203,11 +203,97 @@ func (m *QueryCapacityByDenomResponse) GetLimiterCapacityList() []LimiterCapacit return nil } +// QueryAllPendingSendPacketsRequest is a request type for the +// AllPendingSendPackets RPC +type QueryAllPendingSendPacketsRequest struct { +} + +func (m *QueryAllPendingSendPacketsRequest) Reset() { *m = QueryAllPendingSendPacketsRequest{} } +func (m *QueryAllPendingSendPacketsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllPendingSendPacketsRequest) ProtoMessage() {} +func (*QueryAllPendingSendPacketsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f2e2dd1cb27aa65a, []int{4} +} +func (m *QueryAllPendingSendPacketsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllPendingSendPacketsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllPendingSendPacketsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllPendingSendPacketsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllPendingSendPacketsRequest.Merge(m, src) +} +func (m *QueryAllPendingSendPacketsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllPendingSendPacketsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllPendingSendPacketsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllPendingSendPacketsRequest proto.InternalMessageInfo + +// QueryAllPendingSendPacketsResponse is a response type of the +// AllPendingSendPackets RPC +type QueryAllPendingSendPacketsResponse struct { + PendingSendPackets []PendingSendPacket `protobuf:"bytes,1,rep,name=pending_send_packets,json=pendingSendPackets,proto3" json:"pending_send_packets"` +} + +func (m *QueryAllPendingSendPacketsResponse) Reset() { *m = QueryAllPendingSendPacketsResponse{} } +func (m *QueryAllPendingSendPacketsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllPendingSendPacketsResponse) ProtoMessage() {} +func (*QueryAllPendingSendPacketsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f2e2dd1cb27aa65a, []int{5} +} +func (m *QueryAllPendingSendPacketsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllPendingSendPacketsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllPendingSendPacketsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllPendingSendPacketsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllPendingSendPacketsResponse.Merge(m, src) +} +func (m *QueryAllPendingSendPacketsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllPendingSendPacketsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllPendingSendPacketsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllPendingSendPacketsResponse proto.InternalMessageInfo + +func (m *QueryAllPendingSendPacketsResponse) GetPendingSendPackets() []PendingSendPacket { + if m != nil { + return m.PendingSendPackets + } + return nil +} + func init() { proto.RegisterType((*ListLimitParamsRequest)(nil), "dydxprotocol.ratelimit.ListLimitParamsRequest") proto.RegisterType((*ListLimitParamsResponse)(nil), "dydxprotocol.ratelimit.ListLimitParamsResponse") proto.RegisterType((*QueryCapacityByDenomRequest)(nil), "dydxprotocol.ratelimit.QueryCapacityByDenomRequest") proto.RegisterType((*QueryCapacityByDenomResponse)(nil), "dydxprotocol.ratelimit.QueryCapacityByDenomResponse") + proto.RegisterType((*QueryAllPendingSendPacketsRequest)(nil), "dydxprotocol.ratelimit.QueryAllPendingSendPacketsRequest") + proto.RegisterType((*QueryAllPendingSendPacketsResponse)(nil), "dydxprotocol.ratelimit.QueryAllPendingSendPacketsResponse") } func init() { @@ -215,34 +301,40 @@ func init() { } var fileDescriptor_f2e2dd1cb27aa65a = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xa9, 0x4c, 0xa9, - 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x2f, 0x4a, 0x2c, 0x49, 0xcd, 0xc9, 0xcc, - 0xcd, 0x2c, 0xd1, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x03, 0x4b, 0x08, 0x89, 0x21, 0xab, 0xd1, - 0x83, 0xab, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x8b, 0xeb, 0x83, 0x58, 0x10, 0xd5, 0x52, - 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, 0x79, 0x79, 0xf9, - 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x50, 0x59, 0x4d, 0x1c, 0xf6, 0x81, 0xc9, 0xf8, 0x82, - 0xc4, 0xa2, 0xc4, 0x5c, 0x98, 0x52, 0x55, 0x1c, 0x4a, 0x93, 0x13, 0x0b, 0x12, 0x93, 0x33, 0x4b, - 0xa0, 0xae, 0x53, 0x92, 0xe0, 0x12, 0xf3, 0xc9, 0x2c, 0x2e, 0xf1, 0x01, 0xc9, 0x05, 0x80, 0xf5, - 0x07, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x28, 0x15, 0x70, 0x89, 0x63, 0xc8, 0x14, 0x17, 0xe4, - 0xe7, 0x15, 0xa7, 0x0a, 0x85, 0x72, 0x09, 0x22, 0xdb, 0x18, 0x9f, 0x93, 0x59, 0x5c, 0x22, 0xc1, - 0xa8, 0xc0, 0xac, 0xc1, 0x6d, 0xa4, 0xac, 0x87, 0xdd, 0xbb, 0x7a, 0x48, 0xe6, 0x38, 0xb1, 0x9c, - 0xb8, 0x27, 0xcf, 0x10, 0xc4, 0x9f, 0x83, 0x10, 0x02, 0xd9, 0xa4, 0x64, 0xcc, 0x25, 0x1d, 0x08, - 0x0a, 0x38, 0x67, 0xa8, 0x13, 0x9d, 0x2a, 0x5d, 0x52, 0xf3, 0xf2, 0x73, 0xa1, 0x0e, 0x12, 0x12, - 0xe1, 0x62, 0x4d, 0x01, 0xf1, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x20, 0x1c, 0xa5, 0x46, - 0x46, 0x2e, 0x19, 0xec, 0xba, 0xa0, 0x8e, 0x4d, 0xe4, 0x12, 0x05, 0x5b, 0x94, 0x5a, 0x14, 0x0f, - 0xf3, 0x3b, 0xb2, 0x83, 0xd5, 0xf1, 0x3a, 0x38, 0xb5, 0x08, 0x6e, 0x2c, 0xc4, 0xd1, 0xc2, 0x39, - 0xa8, 0xc2, 0x20, 0x87, 0x1b, 0x3d, 0x67, 0xe2, 0x62, 0x05, 0xbb, 0x41, 0x68, 0x05, 0x23, 0x17, - 0x3f, 0x5a, 0xa8, 0x09, 0xe9, 0xe1, 0xb6, 0x01, 0x5b, 0xc0, 0x4b, 0xe9, 0x13, 0xad, 0x1e, 0xe2, - 0x43, 0x25, 0x93, 0xa6, 0xcb, 0x4f, 0x26, 0x33, 0xe9, 0x09, 0xe9, 0xe8, 0xa3, 0xc4, 0x79, 0x99, - 0x09, 0x4a, 0x0a, 0x29, 0x2e, 0x89, 0x47, 0x8e, 0x34, 0xa1, 0x4d, 0x8c, 0x5c, 0xfc, 0x68, 0x61, - 0x26, 0x64, 0x8c, 0xcb, 0x6a, 0x3c, 0xf1, 0x22, 0x65, 0x42, 0x9a, 0x26, 0x12, 0x1c, 0x0d, 0x8f, - 0xaf, 0xa4, 0xca, 0x78, 0x70, 0x6c, 0x3b, 0x85, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, - 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, - 0x1c, 0x43, 0x94, 0x75, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0x2e, 0xba, 0x89, - 0xba, 0xc9, 0x19, 0x89, 0x99, 0x79, 0xfa, 0x70, 0x91, 0x0a, 0x24, 0x2b, 0x4a, 0x2a, 0x0b, 0x52, - 0x8b, 0x93, 0xd8, 0xc0, 0x72, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x36, 0x18, 0xca, - 0xd0, 0x03, 0x00, 0x00, + // 526 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0xcf, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x6b, 0xd8, 0x90, 0x30, 0x87, 0x09, 0xd3, 0x8d, 0x2a, 0x4c, 0x61, 0x64, 0x42, 0x6c, + 0x12, 0x24, 0x68, 0xad, 0x10, 0x3f, 0x24, 0x24, 0x0a, 0xc7, 0x1d, 0x4a, 0xd1, 0x2e, 0x5c, 0x22, + 0x37, 0xb1, 0x32, 0x0b, 0xd7, 0xf6, 0x62, 0x17, 0x2d, 0x47, 0xb8, 0x70, 0x45, 0xe2, 0x9f, 0xe0, + 0xcc, 0x89, 0x3f, 0x61, 0x27, 0x34, 0x89, 0x0b, 0x27, 0x84, 0x5a, 0xfe, 0x10, 0x14, 0x27, 0x0b, + 0x69, 0x9b, 0x44, 0x8c, 0x4b, 0x55, 0xdb, 0xdf, 0xf7, 0xde, 0xe7, 0xbd, 0xf7, 0x0d, 0x74, 0xc2, + 0x24, 0x3c, 0x96, 0xb1, 0xd0, 0x22, 0x10, 0xcc, 0x8b, 0xb1, 0x26, 0x8c, 0x8e, 0xa9, 0xf6, 0x8e, + 0x26, 0x24, 0x4e, 0x5c, 0xf3, 0x80, 0x36, 0xca, 0x1a, 0xb7, 0xd0, 0x58, 0xed, 0x48, 0x44, 0xc2, + 0xdc, 0x7b, 0xe9, 0xbf, 0x4c, 0x6d, 0x6d, 0x46, 0x42, 0x44, 0x8c, 0x78, 0x58, 0x52, 0x0f, 0x73, + 0x2e, 0x34, 0xd6, 0x54, 0x70, 0x95, 0xbf, 0xee, 0xd6, 0xd4, 0x33, 0xbf, 0xbe, 0xc4, 0x31, 0x1e, + 0x9f, 0x49, 0x6f, 0xd7, 0x48, 0x03, 0x2c, 0x71, 0x40, 0x75, 0x4e, 0x67, 0xdd, 0xaf, 0x91, 0x49, + 0xc2, 0x43, 0xca, 0x23, 0x5f, 0x11, 0x1e, 0xfa, 0x12, 0x07, 0x6f, 0x88, 0xce, 0x22, 0x9c, 0x0e, + 0xdc, 0xd8, 0xa7, 0x4a, 0xef, 0xa7, 0xb2, 0x81, 0xa9, 0x38, 0x24, 0x47, 0x13, 0xa2, 0xb4, 0x23, + 0xe1, 0xf5, 0xa5, 0x17, 0x25, 0x05, 0x57, 0x04, 0x1d, 0xc0, 0xab, 0x65, 0x46, 0x9f, 0x51, 0xa5, + 0x3b, 0x60, 0xeb, 0xe2, 0xce, 0x95, 0xbd, 0x6d, 0xb7, 0x7a, 0x40, 0x6e, 0x29, 0x4f, 0x7f, 0xe5, + 0xe4, 0xe7, 0xcd, 0xd6, 0x70, 0x8d, 0xfd, 0xbd, 0x4a, 0x2b, 0x39, 0x5d, 0x78, 0xe3, 0x65, 0x3a, + 0xea, 0xe7, 0x79, 0x53, 0xfd, 0xe4, 0x05, 0xe1, 0x62, 0x9c, 0x03, 0xa1, 0x36, 0x5c, 0x0d, 0xd3, + 0x73, 0x07, 0x6c, 0x81, 0x9d, 0xcb, 0xc3, 0xec, 0xe0, 0xbc, 0x03, 0x70, 0xb3, 0x3a, 0x2a, 0x87, + 0xc5, 0x70, 0xdd, 0x14, 0x22, 0xb1, 0x7f, 0x36, 0xad, 0x32, 0xf0, 0x9d, 0x46, 0x60, 0x12, 0x17, + 0x69, 0x33, 0xe8, 0x6b, 0x6c, 0xfe, 0xda, 0x80, 0x6f, 0xc3, 0x5b, 0x06, 0xe1, 0x19, 0x63, 0x83, + 0x6c, 0xd2, 0xaf, 0x08, 0x0f, 0x07, 0x66, 0xce, 0xc5, 0x3c, 0x3f, 0x00, 0xe8, 0x34, 0xa9, 0x0a, + 0xdc, 0x76, 0xc5, 0xb6, 0x54, 0x4e, 0xbb, 0x5b, 0x47, 0xbb, 0x94, 0x31, 0xe7, 0x45, 0x72, 0xa9, + 0xd4, 0xde, 0xd7, 0x15, 0xb8, 0x6a, 0x48, 0xd0, 0x67, 0x00, 0xd7, 0x16, 0x96, 0x8c, 0xdc, 0xfa, + 0x81, 0x54, 0xf9, 0xc4, 0xf2, 0xfe, 0x59, 0x9f, 0x75, 0xe8, 0xf4, 0xde, 0x7f, 0xff, 0xfd, 0xe9, + 0x82, 0x8b, 0xee, 0x7a, 0x73, 0x6e, 0x7d, 0xdb, 0x9b, 0xfb, 0x04, 0x94, 0xf6, 0xcb, 0x1e, 0x43, + 0x5f, 0x00, 0x5c, 0x5b, 0x58, 0x31, 0xea, 0xd6, 0x95, 0x6e, 0xb0, 0x91, 0xd5, 0x3b, 0x5f, 0xd0, + 0x39, 0xa0, 0x0b, 0x7b, 0x8d, 0x12, 0xdf, 0x98, 0x13, 0x7d, 0x03, 0x70, 0xbd, 0x72, 0xdd, 0xe8, + 0x51, 0x23, 0x45, 0x93, 0x91, 0xac, 0xc7, 0xff, 0x13, 0x9a, 0xb7, 0xf1, 0xd4, 0xb4, 0xf1, 0x10, + 0x3d, 0x68, 0x68, 0x23, 0x22, 0xda, 0xc7, 0x8c, 0xf9, 0x15, 0x36, 0xec, 0x1f, 0x9c, 0x4c, 0x6d, + 0x70, 0x3a, 0xb5, 0xc1, 0xaf, 0xa9, 0x0d, 0x3e, 0xce, 0xec, 0xd6, 0xe9, 0xcc, 0x6e, 0xfd, 0x98, + 0xd9, 0xad, 0xd7, 0x4f, 0x22, 0xaa, 0x0f, 0x27, 0x23, 0x37, 0x10, 0xe3, 0xc5, 0xdc, 0xf7, 0x82, + 0x43, 0x4c, 0xb9, 0x57, 0xdc, 0x1c, 0x97, 0x8a, 0xe9, 0x44, 0x12, 0x35, 0xba, 0x64, 0xde, 0xba, + 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x02, 0x33, 0xb1, 0x82, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -261,6 +353,8 @@ type QueryClient interface { ListLimitParams(ctx context.Context, in *ListLimitParamsRequest, opts ...grpc.CallOption) (*ListLimitParamsResponse, error) // Query capacity by denom. CapacityByDenom(ctx context.Context, in *QueryCapacityByDenomRequest, opts ...grpc.CallOption) (*QueryCapacityByDenomResponse, error) + // Get all pending send packets + AllPendingSendPackets(ctx context.Context, in *QueryAllPendingSendPacketsRequest, opts ...grpc.CallOption) (*QueryAllPendingSendPacketsResponse, error) } type queryClient struct { @@ -289,12 +383,23 @@ func (c *queryClient) CapacityByDenom(ctx context.Context, in *QueryCapacityByDe return out, nil } +func (c *queryClient) AllPendingSendPackets(ctx context.Context, in *QueryAllPendingSendPacketsRequest, opts ...grpc.CallOption) (*QueryAllPendingSendPacketsResponse, error) { + out := new(QueryAllPendingSendPacketsResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.ratelimit.Query/AllPendingSendPackets", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // List all limit params. ListLimitParams(context.Context, *ListLimitParamsRequest) (*ListLimitParamsResponse, error) // Query capacity by denom. CapacityByDenom(context.Context, *QueryCapacityByDenomRequest) (*QueryCapacityByDenomResponse, error) + // Get all pending send packets + AllPendingSendPackets(context.Context, *QueryAllPendingSendPacketsRequest) (*QueryAllPendingSendPacketsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -307,6 +412,9 @@ func (*UnimplementedQueryServer) ListLimitParams(ctx context.Context, req *ListL func (*UnimplementedQueryServer) CapacityByDenom(ctx context.Context, req *QueryCapacityByDenomRequest) (*QueryCapacityByDenomResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CapacityByDenom not implemented") } +func (*UnimplementedQueryServer) AllPendingSendPackets(ctx context.Context, req *QueryAllPendingSendPacketsRequest) (*QueryAllPendingSendPacketsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AllPendingSendPackets not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -348,6 +456,24 @@ func _Query_CapacityByDenom_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Query_AllPendingSendPackets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllPendingSendPacketsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AllPendingSendPackets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.ratelimit.Query/AllPendingSendPackets", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AllPendingSendPackets(ctx, req.(*QueryAllPendingSendPacketsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "dydxprotocol.ratelimit.Query", HandlerType: (*QueryServer)(nil), @@ -360,6 +486,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "CapacityByDenom", Handler: _Query_CapacityByDenom_Handler, }, + { + MethodName: "AllPendingSendPackets", + Handler: _Query_AllPendingSendPackets_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "dydxprotocol/ratelimit/query.proto", @@ -492,6 +622,66 @@ func (m *QueryCapacityByDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *QueryAllPendingSendPacketsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllPendingSendPacketsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllPendingSendPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryAllPendingSendPacketsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllPendingSendPacketsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllPendingSendPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PendingSendPackets) > 0 { + for iNdEx := len(m.PendingSendPackets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PendingSendPackets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -555,6 +745,30 @@ func (m *QueryCapacityByDenomResponse) Size() (n int) { return n } +func (m *QueryAllPendingSendPacketsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryAllPendingSendPacketsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PendingSendPackets) > 0 { + for _, e := range m.PendingSendPackets { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -861,6 +1075,140 @@ func (m *QueryCapacityByDenomResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryAllPendingSendPacketsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllPendingSendPacketsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllPendingSendPacketsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllPendingSendPacketsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllPendingSendPacketsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllPendingSendPacketsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PendingSendPackets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PendingSendPackets = append(m.PendingSendPackets, PendingSendPacket{}) + if err := m.PendingSendPackets[len(m.PendingSendPackets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/protocol/x/ratelimit/types/query.pb.gw.go b/protocol/x/ratelimit/types/query.pb.gw.go index d94c451c14..c925078c29 100644 --- a/protocol/x/ratelimit/types/query.pb.gw.go +++ b/protocol/x/ratelimit/types/query.pb.gw.go @@ -87,6 +87,24 @@ func local_request_Query_CapacityByDenom_0(ctx context.Context, marshaler runtim } +func request_Query_AllPendingSendPackets_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllPendingSendPacketsRequest + var metadata runtime.ServerMetadata + + msg, err := client.AllPendingSendPackets(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AllPendingSendPackets_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllPendingSendPacketsRequest + var metadata runtime.ServerMetadata + + msg, err := server.AllPendingSendPackets(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -139,6 +157,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_AllPendingSendPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AllPendingSendPackets_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AllPendingSendPackets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -220,6 +261,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_AllPendingSendPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AllPendingSendPackets_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AllPendingSendPackets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -227,10 +288,14 @@ var ( pattern_Query_ListLimitParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dydxprotocol", "v4", "ratelimit", "list_limit_params"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_CapacityByDenom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dydxprotocol", "v4", "ratelimit", "capacity_by_denom"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_AllPendingSendPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dydxprotocol", "v4", "ratelimit", "get_all_pending_send_packet"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_ListLimitParams_0 = runtime.ForwardResponseMessage forward_Query_CapacityByDenom_0 = runtime.ForwardResponseMessage + + forward_Query_AllPendingSendPackets_0 = runtime.ForwardResponseMessage )