From 2a47cf537a7b6e8ba2a2ac9f95c81ee8c6760374 Mon Sep 17 00:00:00 2001 From: jayy04 <103467857+jayy04@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:52:14 -0400 Subject: [PATCH] [Backport v3.x] backport full node streaming PRs (#1181) * [CT-645] Move off chain updates and v1 to a different package (#1131) * [CT-645] Add protos for orderbook stream query service * move removal reasons to a separate package * [CT-645] Add protos for orderbook stream query service (#1133) * [CT-645] Add protos for orderbook stream query service * make update not nullable * fix build * [CT-644] instantiate grpc stream manager (#1134) * [CT-644] instantiate grpc stream manager * update type * update channel type * [CT-646] stream offchain updates through stream manager (#1138) * [CT-646] stream offchain updates through stream manager * comments * fix lint * get rid of finished * comments * comments * [CT-652] add command line flag for full node streaming (#1145) * [CT-647] construct the initial orderbook snapshot (#1147) * [CT-647] construct the initial orderbook snapshot * [CT-647] initialize new streams and send orderbook snapshot (#1152) * [CT-647] initialize new streams and send orderbook snapshot * use sync once * comments * fix test --- .../dydxprotocol/clob/query.rpc.Query.ts | 16 +- .../src/codegen/dydxprotocol/clob/query.ts | 165 +++++ proto/dydxprotocol/clob/query.proto | 28 + .../off_chain_updates/off_chain_updates.proto | 2 +- .../indexer/protocol/v1/clob.proto | 2 +- .../indexer/protocol/v1/subaccount.proto | 2 +- .../indexer/shared/removal_reason.proto | 2 +- protocol/app/ante_whitebox_test.go | 1 + protocol/app/app.go | 30 +- protocol/app/flags/flags.go | 32 + protocol/app/flags/flags_test.go | 29 +- protocol/indexer/events/events.pb.go | 124 ++-- .../events/perpetual_market_create_test.go | 4 +- protocol/indexer/events/stateful_order.go | 6 +- .../indexer/events/stateful_order_test.go | 6 +- .../off_chain_updates/off_chain_updates.go | 46 +- .../off_chain_updates_test.go | 43 +- .../{ => types}/off_chain_updates.pb.go | 115 +-- .../protocol/v1/{ => types}/clob.pb.go | 109 +-- .../protocol/v1/{ => types}/subaccount.pb.go | 56 +- protocol/indexer/protocol/v1/v1_mappers.go | 69 +- .../indexer/protocol/v1/v1_mappers_test.go | 65 +- .../indexer/shared/order_removal_reason.go | 33 +- .../shared/order_removal_reason_test.go | 13 +- .../shared/{ => types}/removal_reason.pb.go | 63 +- protocol/mocks/ClobKeeper.go | 5 + protocol/mocks/MemClob.go | 85 +-- protocol/mocks/MemClobKeeper.go | 65 +- protocol/mocks/QueryClient.go | 30 + .../streaming/grpc/grpc_streaming_manager.go | 159 +++++ .../streaming/grpc/noop_streaming_manager.go | 37 + protocol/streaming/grpc/types/manager.go | 22 + protocol/testutil/keeper/clob.go | 26 +- protocol/testutil/memclob/offchain_updates.go | 5 +- protocol/x/clob/abci.go | 5 +- protocol/x/clob/abci_test.go | 2 +- protocol/x/clob/keeper/clob_pair_test.go | 2 +- protocol/x/clob/keeper/final_settlement.go | 2 +- .../x/clob/keeper/grpc_stream_orderbook.go | 20 + protocol/x/clob/keeper/keeper.go | 27 + .../x/clob/keeper/msg_server_cancel_orders.go | 2 +- .../keeper/msg_server_cancel_orders_test.go | 2 +- protocol/x/clob/keeper/orders.go | 7 +- protocol/x/clob/memclob/memclob.go | 36 +- .../x/clob/memclob/memclob_grpc_streaming.go | 88 +++ .../memclob/memclob_grpc_streaming_test.go | 99 +++ protocol/x/clob/memclob/memclob_test_util.go | 17 +- protocol/x/clob/types/clob_keeper.go | 1 + protocol/x/clob/types/errors.go | 12 + protocol/x/clob/types/memclob.go | 4 + protocol/x/clob/types/query.pb.go | 657 ++++++++++++++++-- 51 files changed, 1890 insertions(+), 588 deletions(-) rename protocol/indexer/off_chain_updates/{ => types}/off_chain_updates.pb.go (87%) rename protocol/indexer/protocol/v1/{ => types}/clob.pb.go (86%) rename protocol/indexer/protocol/v1/{ => types}/subaccount.pb.go (90%) rename protocol/indexer/shared/{ => types}/removal_reason.pb.go (68%) create mode 100644 protocol/streaming/grpc/grpc_streaming_manager.go create mode 100644 protocol/streaming/grpc/noop_streaming_manager.go create mode 100644 protocol/streaming/grpc/types/manager.go create mode 100644 protocol/x/clob/keeper/grpc_stream_orderbook.go create mode 100644 protocol/x/clob/memclob/memclob_grpc_streaming.go create mode 100644 protocol/x/clob/memclob/memclob_grpc_streaming_test.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.rpc.Query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.rpc.Query.ts index 643117c5ea..4b5ccc331b 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.rpc.Query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/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 { QueryGetClobPairRequest, QueryClobPairResponse, QueryAllClobPairRequest, QueryClobPairAllResponse, MevNodeToNodeCalculationRequest, MevNodeToNodeCalculationResponse, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponse, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponse, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponse } from "./query"; +import { QueryGetClobPairRequest, QueryClobPairResponse, QueryAllClobPairRequest, QueryClobPairAllResponse, MevNodeToNodeCalculationRequest, MevNodeToNodeCalculationResponse, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponse, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponse, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponse, StreamOrderbookUpdatesRequest, StreamOrderbookUpdatesResponse } from "./query"; /** Query defines the gRPC querier service. */ export interface Query { @@ -22,6 +22,9 @@ export interface Query { /** Queries LiquidationsConfiguration. */ liquidationsConfiguration(request?: QueryLiquidationsConfigurationRequest): Promise; + /** Streams orderbook updates. */ + + streamOrderbookUpdates(request: StreamOrderbookUpdatesRequest): Promise; } export class QueryClientImpl implements Query { private readonly rpc: Rpc; @@ -34,6 +37,7 @@ export class QueryClientImpl implements Query { this.equityTierLimitConfiguration = this.equityTierLimitConfiguration.bind(this); this.blockRateLimitConfiguration = this.blockRateLimitConfiguration.bind(this); this.liquidationsConfiguration = this.liquidationsConfiguration.bind(this); + this.streamOrderbookUpdates = this.streamOrderbookUpdates.bind(this); } clobPair(request: QueryGetClobPairRequest): Promise { @@ -74,6 +78,12 @@ export class QueryClientImpl implements Query { return promise.then(data => QueryLiquidationsConfigurationResponse.decode(new _m0.Reader(data))); } + streamOrderbookUpdates(request: StreamOrderbookUpdatesRequest): Promise { + const data = StreamOrderbookUpdatesRequest.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.clob.Query", "StreamOrderbookUpdates", data); + return promise.then(data => StreamOrderbookUpdatesResponse.decode(new _m0.Reader(data))); + } + } export const createRpcQueryExtension = (base: QueryClient) => { const rpc = createProtobufRpcClient(base); @@ -101,6 +111,10 @@ export const createRpcQueryExtension = (base: QueryClient) => { liquidationsConfiguration(request?: QueryLiquidationsConfigurationRequest): Promise { return queryService.liquidationsConfiguration(request); + }, + + streamOrderbookUpdates(request: StreamOrderbookUpdatesRequest): Promise { + return queryService.streamOrderbookUpdates(request); } }; diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts index f0ef3987b8..ddf8e9bd2d 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts @@ -4,6 +4,7 @@ import { ClobPair, ClobPairSDKType } from "./clob_pair"; import { EquityTierLimitConfiguration, EquityTierLimitConfigurationSDKType } from "./equity_tier_limit_config"; import { BlockRateLimitConfiguration, BlockRateLimitConfigurationSDKType } from "./block_rate_limit_config"; import { LiquidationsConfig, LiquidationsConfigSDKType } from "./liquidations_config"; +import { OffChainUpdateV1, OffChainUpdateV1SDKType } from "../indexer/off_chain_updates/off_chain_updates"; import * as _m0 from "protobufjs/minimal"; import { DeepPartial, Long } from "../../helpers"; /** QueryGetClobPairRequest is request type for the ClobPair method. */ @@ -198,6 +199,58 @@ export interface QueryLiquidationsConfigurationResponse { export interface QueryLiquidationsConfigurationResponseSDKType { liquidations_config?: LiquidationsConfigSDKType; } +/** + * StreamOrderbookUpdatesRequest is a request message for the + * StreamOrderbookUpdates method. + */ + +export interface StreamOrderbookUpdatesRequest { + /** Clob pair ids to stream orderbook updates for. */ + clobPairId: number[]; +} +/** + * StreamOrderbookUpdatesRequest is a request message for the + * StreamOrderbookUpdates method. + */ + +export interface StreamOrderbookUpdatesRequestSDKType { + /** Clob pair ids to stream orderbook updates for. */ + clob_pair_id: number[]; +} +/** + * StreamOrderbookUpdatesResponse is a response message for the + * StreamOrderbookUpdates method. + */ + +export interface StreamOrderbookUpdatesResponse { + /** Orderbook updates for the clob pair. */ + updates: OffChainUpdateV1[]; + /** + * Snapshot indicates if the response is from a snapshot of the orderbook. + * This is true for the initial response and false for all subsequent updates. + * Note that if the snapshot is true, then all previous entries should be + * discarded and the orderbook should be resynced. + */ + + snapshot: boolean; +} +/** + * StreamOrderbookUpdatesResponse is a response message for the + * StreamOrderbookUpdates method. + */ + +export interface StreamOrderbookUpdatesResponseSDKType { + /** Orderbook updates for the clob pair. */ + updates: OffChainUpdateV1SDKType[]; + /** + * Snapshot indicates if the response is from a snapshot of the orderbook. + * This is true for the initial response and false for all subsequent updates. + * Note that if the snapshot is true, then all previous entries should be + * discarded and the orderbook should be resynced. + */ + + snapshot: boolean; +} function createBaseQueryGetClobPairRequest(): QueryGetClobPairRequest { return { @@ -789,4 +842,116 @@ export const QueryLiquidationsConfigurationResponse = { return message; } +}; + +function createBaseStreamOrderbookUpdatesRequest(): StreamOrderbookUpdatesRequest { + return { + clobPairId: [] + }; +} + +export const StreamOrderbookUpdatesRequest = { + encode(message: StreamOrderbookUpdatesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + writer.uint32(10).fork(); + + for (const v of message.clobPairId) { + writer.uint32(v); + } + + writer.ldelim(); + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): StreamOrderbookUpdatesRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStreamOrderbookUpdatesRequest(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + + while (reader.pos < end2) { + message.clobPairId.push(reader.uint32()); + } + } else { + message.clobPairId.push(reader.uint32()); + } + + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): StreamOrderbookUpdatesRequest { + const message = createBaseStreamOrderbookUpdatesRequest(); + message.clobPairId = object.clobPairId?.map(e => e) || []; + return message; + } + +}; + +function createBaseStreamOrderbookUpdatesResponse(): StreamOrderbookUpdatesResponse { + return { + updates: [], + snapshot: false + }; +} + +export const StreamOrderbookUpdatesResponse = { + encode(message: StreamOrderbookUpdatesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.updates) { + OffChainUpdateV1.encode(v!, writer.uint32(10).fork()).ldelim(); + } + + if (message.snapshot === true) { + writer.uint32(16).bool(message.snapshot); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): StreamOrderbookUpdatesResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStreamOrderbookUpdatesResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.updates.push(OffChainUpdateV1.decode(reader, reader.uint32())); + break; + + case 2: + message.snapshot = reader.bool(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): StreamOrderbookUpdatesResponse { + const message = createBaseStreamOrderbookUpdatesResponse(); + message.updates = object.updates?.map(e => OffChainUpdateV1.fromPartial(e)) || []; + message.snapshot = object.snapshot ?? false; + return message; + } + }; \ No newline at end of file diff --git a/proto/dydxprotocol/clob/query.proto b/proto/dydxprotocol/clob/query.proto index 3fc37479c0..b4a61e2062 100644 --- a/proto/dydxprotocol/clob/query.proto +++ b/proto/dydxprotocol/clob/query.proto @@ -9,6 +9,7 @@ import "dydxprotocol/clob/clob_pair.proto"; import "dydxprotocol/clob/equity_tier_limit_config.proto"; import "dydxprotocol/clob/liquidations_config.proto"; import "dydxprotocol/clob/mev.proto"; +import "dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto"; option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/clob/types"; @@ -50,6 +51,12 @@ service Query { returns (QueryLiquidationsConfigurationResponse) { option (google.api.http).get = "/dydxprotocol/clob/liquidations_config"; } + + // GRPC Streams + + // Streams orderbook updates. + rpc StreamOrderbookUpdates(StreamOrderbookUpdatesRequest) + returns (stream StreamOrderbookUpdatesResponse); } // QueryGetClobPairRequest is request type for the ClobPair method. @@ -126,3 +133,24 @@ message QueryLiquidationsConfigurationRequest {} message QueryLiquidationsConfigurationResponse { LiquidationsConfig liquidations_config = 1 [ (gogoproto.nullable) = false ]; } + +// StreamOrderbookUpdatesRequest is a request message for the +// StreamOrderbookUpdates method. +message StreamOrderbookUpdatesRequest { + // Clob pair ids to stream orderbook updates for. + repeated uint32 clob_pair_id = 1; +} + +// StreamOrderbookUpdatesResponse is a response message for the +// StreamOrderbookUpdates method. +message StreamOrderbookUpdatesResponse { + // Orderbook updates for the clob pair. + repeated dydxprotocol.indexer.off_chain_updates.OffChainUpdateV1 updates = 1 + [ (gogoproto.nullable) = false ]; + + // Snapshot indicates if the response is from a snapshot of the orderbook. + // This is true for the initial response and false for all subsequent updates. + // Note that if the snapshot is true, then all previous entries should be + // discarded and the orderbook should be resynced. + bool snapshot = 2; +} diff --git a/proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto b/proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto index 59f137a3b8..1e80bddc6d 100644 --- a/proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto +++ b/proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto @@ -4,7 +4,7 @@ package dydxprotocol.indexer.off_chain_updates; import "dydxprotocol/indexer/shared/removal_reason.proto"; import "dydxprotocol/indexer/protocol/v1/clob.proto"; -option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates"; +option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates/types"; // Do not make any breaking changes to these protos, a new version should be // created if a breaking change is needed. diff --git a/proto/dydxprotocol/indexer/protocol/v1/clob.proto b/proto/dydxprotocol/indexer/protocol/v1/clob.proto index b061dae39b..b840d848bb 100644 --- a/proto/dydxprotocol/indexer/protocol/v1/clob.proto +++ b/proto/dydxprotocol/indexer/protocol/v1/clob.proto @@ -4,7 +4,7 @@ package dydxprotocol.indexer.protocol.v1; import "dydxprotocol/indexer/protocol/v1/subaccount.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1"; +option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1/types"; // Initial copy of protos from dYdX chain application state protos for the clob // module for use to send Indexer specific messages. Do not make any breaking diff --git a/proto/dydxprotocol/indexer/protocol/v1/subaccount.proto b/proto/dydxprotocol/indexer/protocol/v1/subaccount.proto index 1df766a338..d04ce61769 100644 --- a/proto/dydxprotocol/indexer/protocol/v1/subaccount.proto +++ b/proto/dydxprotocol/indexer/protocol/v1/subaccount.proto @@ -4,7 +4,7 @@ package dydxprotocol.indexer.protocol.v1; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1"; +option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1/types"; // Initial copy of protos from dYdX chain application state protos for the // subaccount module for use to send Indexer specific messages. Do not make any diff --git a/proto/dydxprotocol/indexer/shared/removal_reason.proto b/proto/dydxprotocol/indexer/shared/removal_reason.proto index be81d025d2..547206102a 100644 --- a/proto/dydxprotocol/indexer/shared/removal_reason.proto +++ b/proto/dydxprotocol/indexer/shared/removal_reason.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package dydxprotocol.indexer.shared; -option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/shared"; +option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types"; // TODO(DEC-869): Update reasons/statuses for Advanced Orders. diff --git a/protocol/app/ante_whitebox_test.go b/protocol/app/ante_whitebox_test.go index 4effb1619c..b3a67e200c 100644 --- a/protocol/app/ante_whitebox_test.go +++ b/protocol/app/ante_whitebox_test.go @@ -71,6 +71,7 @@ func newTestHandlerOptions() HandlerOptions { nil, nil, nil, + nil, flags.GetDefaultClobFlags(), rate_limit.NewNoOpRateLimiter[*types.MsgPlaceOrder](), rate_limit.NewNoOpRateLimiter[*types.MsgCancelOrder](), diff --git a/protocol/app/app.go b/protocol/app/app.go index cb3e38c93f..5e191efd0a 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -186,6 +186,10 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/indexer" "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" "github.com/dydxprotocol/v4-chain/protocol/indexer/msgsender" + + // Grpc Streaming + streaming "github.com/dydxprotocol/v4-chain/protocol/streaming/grpc" + streamingtypes "github.com/dydxprotocol/v4-chain/protocol/streaming/grpc/types" ) var ( @@ -284,8 +288,9 @@ type App struct { // module configurator configurator module.Configurator - IndexerEventManager indexer_manager.IndexerEventManager - Server *daemonserver.Server + IndexerEventManager indexer_manager.IndexerEventManager + GrpcStreamingManager streamingtypes.GrpcStreamingManager + Server *daemonserver.Server // startDaemons encapsulates the logic that starts all daemons and daemon services. This function contains a // closure of all relevant data structures that are shared with various keepers. Daemon services startup is @@ -593,6 +598,9 @@ func New( tkeys[indexer_manager.TransientStoreKey], indexerFlags.SendOffchainData, ) + + app.GrpcStreamingManager = getGrpcStreamingManagerFromOptions(appFlags, logger) + timeProvider := &timelib.TimeProviderImpl{} app.EpochsKeeper = *epochsmodulekeeper.NewKeeper( @@ -877,7 +885,9 @@ func New( clobFlags := clobflags.GetClobFlagValuesFromOptions(appOpts) logger.Info("Parsed CLOB flags", "Flags", clobFlags) - memClob := clobmodulememclob.NewMemClobPriceTimePriority(app.IndexerEventManager.Enabled()) + memClob := clobmodulememclob.NewMemClobPriceTimePriority( + app.IndexerEventManager.Enabled() || app.GrpcStreamingManager.Enabled(), + ) app.ClobKeeper = clobmodulekeeper.NewKeeper( appCodec, @@ -899,6 +909,7 @@ func New( app.StatsKeeper, app.RewardsKeeper, app.IndexerEventManager, + app.GrpcStreamingManager, txConfig.TxDecoder(), clobFlags, rate_limit.NewPanicRateLimiter[*clobmoduletypes.MsgPlaceOrder](), @@ -1592,3 +1603,16 @@ func getIndexerFromOptions( } return indexerMessageSender, indexerFlags } + +// getGrpcStreamingManagerFromOptions returns an instance of a streamingtypes.GrpcStreamingManager from the specified +// options. This function will default to returning a no-op instance. +func getGrpcStreamingManagerFromOptions( + appFlags flags.Flags, + logger log.Logger, +) (manager streamingtypes.GrpcStreamingManager) { + if appFlags.GrpcStreamingEnabled { + logger.Info("GRPC streaming is enabled") + return streaming.NewGrpcStreamingManager() + } + return streaming.NewNoopGrpcStreamingManager() +} diff --git a/protocol/app/flags/flags.go b/protocol/app/flags/flags.go index 6f67611a22..18fa78a19b 100644 --- a/protocol/app/flags/flags.go +++ b/protocol/app/flags/flags.go @@ -19,6 +19,9 @@ type Flags struct { // Existing flags GrpcAddress string GrpcEnable bool + + // Grpc Streaming + GrpcStreamingEnabled bool } // List of CLI flags. @@ -31,6 +34,9 @@ const ( // Cosmos flags below. These config values can be set as flags or in config.toml. GrpcAddress = "grpc.address" GrpcEnable = "grpc.enable" + + // Grpc Streaming + GrpcStreamingEnabled = "grpc-streaming-enabled" ) // Default values. @@ -39,6 +45,8 @@ const ( DefaultDdTraceAgentPort = 8126 DefaultNonValidatingFullNode = false DefaultDdErrorTrackingFormat = false + + DefaultGrpcStreamingEnabled = false ) // AddFlagsToCmd adds flags to app initialization. @@ -67,6 +75,11 @@ func AddFlagsToCmd(cmd *cobra.Command) { DefaultDdErrorTrackingFormat, "Enable formatting of log error tags to datadog error tracking format", ) + cmd.Flags().Bool( + GrpcStreamingEnabled, + DefaultGrpcStreamingEnabled, + "Whether to enable grpc streaming for full nodes", + ) } // Validate checks that the flags are valid. @@ -75,6 +88,17 @@ func (f *Flags) Validate() error { if !f.NonValidatingFullNode && !f.GrpcEnable { return fmt.Errorf("grpc.enable must be set to true - validating requires gRPC server") } + + // Grpc streaming + if f.GrpcStreamingEnabled { + if !f.GrpcEnable { + return fmt.Errorf("grpc.enable must be set to true - grpc streaming requires gRPC server") + } + + if !f.NonValidatingFullNode { + return fmt.Errorf("grpc-streaming-enabled can only be set to true for non-validating full nodes") + } + } return nil } @@ -93,6 +117,8 @@ func GetFlagValuesFromOptions( // These are the default values from the Cosmos flags. GrpcAddress: config.DefaultGRPCAddress, GrpcEnable: true, + + GrpcStreamingEnabled: DefaultGrpcStreamingEnabled, } // Populate the flags if they exist. @@ -132,5 +158,11 @@ func GetFlagValuesFromOptions( } } + if option := appOpts.Get(GrpcStreamingEnabled); option != nil { + if v, err := cast.ToBoolE(option); err == nil { + result.GrpcStreamingEnabled = v + } + } + return result } diff --git a/protocol/app/flags/flags_test.go b/protocol/app/flags/flags_test.go index aaba0016b3..c170ec864f 100644 --- a/protocol/app/flags/flags_test.go +++ b/protocol/app/flags/flags_test.go @@ -2,9 +2,10 @@ package flags_test import ( "fmt" - "github.com/cosmos/cosmos-sdk/server/config" "testing" + "github.com/cosmos/cosmos-sdk/server/config" + "github.com/dydxprotocol/v4-chain/protocol/app/flags" "github.com/dydxprotocol/v4-chain/protocol/mocks" "github.com/spf13/cobra" @@ -27,7 +28,11 @@ func TestAddFlagsToCommand(t *testing.T) { }, fmt.Sprintf("Has %s flag", flags.DdTraceAgentPort): { flagName: flags.DdTraceAgentPort, - }} + }, + fmt.Sprintf("Has %s flag", flags.GrpcStreamingEnabled): { + flagName: flags.GrpcStreamingEnabled, + }, + } for name, tc := range tests { t.Run(name, func(t *testing.T) { @@ -62,6 +67,22 @@ func TestValidate(t *testing.T) { }, expectedErr: fmt.Errorf("grpc.enable must be set to true - validating requires gRPC server"), }, + "failure - gRPC streaming enabled for validating nodes": { + flags: flags.Flags{ + NonValidatingFullNode: false, + GrpcEnable: true, + GrpcStreamingEnabled: true, + }, + expectedErr: fmt.Errorf("grpc-streaming-enabled can only be set to true for non-validating full nodes"), + }, + "failure - gRPC streaming enabled with gRPC disabled": { + flags: flags.Flags{ + NonValidatingFullNode: true, + GrpcEnable: false, + GrpcStreamingEnabled: true, + }, + expectedErr: fmt.Errorf("grpc.enable must be set to true - grpc streaming requires gRPC server"), + }, } for name, tc := range tests { t.Run(name, func(t *testing.T) { @@ -86,6 +107,7 @@ func TestGetFlagValuesFromOptions(t *testing.T) { expectedDdTraceAgentPort uint16 expectedGrpcAddress string expectedGrpcEnable bool + expectedGrpcStreamingEnable bool }{ "Sets to default if unset": { expectedNonValidatingFullNodeFlag: false, @@ -93,6 +115,7 @@ func TestGetFlagValuesFromOptions(t *testing.T) { expectedDdTraceAgentPort: 8126, expectedGrpcAddress: "localhost:9090", expectedGrpcEnable: true, + expectedGrpcStreamingEnable: false, }, "Sets values from options": { optsMap: map[string]any{ @@ -101,12 +124,14 @@ func TestGetFlagValuesFromOptions(t *testing.T) { flags.DdTraceAgentPort: uint16(777), flags.GrpcEnable: false, flags.GrpcAddress: "localhost:9091", + flags.GrpcStreamingEnabled: "true", }, expectedNonValidatingFullNodeFlag: true, expectedDdAgentHost: "agentHostTest", expectedDdTraceAgentPort: 777, expectedGrpcEnable: false, expectedGrpcAddress: "localhost:9091", + expectedGrpcStreamingEnable: true, }, } diff --git a/protocol/indexer/events/events.pb.go b/protocol/indexer/events/events.pb.go index ed087d557b..bb7533b768 100644 --- a/protocol/indexer/events/events.pb.go +++ b/protocol/indexer/events/events.pb.go @@ -9,8 +9,8 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" github_com_dydxprotocol_v4_chain_protocol_dtypes "github.com/dydxprotocol/v4-chain/protocol/dtypes" - v1 "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" - shared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + types "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1/types" + types1 "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" io "io" math "math" math_bits "math/bits" @@ -564,7 +564,7 @@ type isSourceOfFunds_Source interface { } type SourceOfFunds_SubaccountId struct { - SubaccountId *v1.IndexerSubaccountId `protobuf:"bytes,1,opt,name=subaccount_id,json=subaccountId,proto3,oneof" json:"subaccount_id,omitempty"` + SubaccountId *types.IndexerSubaccountId `protobuf:"bytes,1,opt,name=subaccount_id,json=subaccountId,proto3,oneof" json:"subaccount_id,omitempty"` } type SourceOfFunds_Address struct { Address string `protobuf:"bytes,2,opt,name=address,proto3,oneof" json:"address,omitempty"` @@ -580,7 +580,7 @@ func (m *SourceOfFunds) GetSource() isSourceOfFunds_Source { return nil } -func (m *SourceOfFunds) GetSubaccountId() *v1.IndexerSubaccountId { +func (m *SourceOfFunds) GetSubaccountId() *types.IndexerSubaccountId { if x, ok := m.GetSource().(*SourceOfFunds_SubaccountId); ok { return x.SubaccountId } @@ -607,8 +607,8 @@ func (*SourceOfFunds) XXX_OneofWrappers() []interface{} { // When a subaccount is involved, a SubaccountUpdateEvent message will // be produced with the updated asset positions. type TransferEventV1 struct { - SenderSubaccountId *v1.IndexerSubaccountId `protobuf:"bytes,1,opt,name=sender_subaccount_id,json=senderSubaccountId,proto3" json:"sender_subaccount_id,omitempty"` - RecipientSubaccountId *v1.IndexerSubaccountId `protobuf:"bytes,2,opt,name=recipient_subaccount_id,json=recipientSubaccountId,proto3" json:"recipient_subaccount_id,omitempty"` + SenderSubaccountId *types.IndexerSubaccountId `protobuf:"bytes,1,opt,name=sender_subaccount_id,json=senderSubaccountId,proto3" json:"sender_subaccount_id,omitempty"` + RecipientSubaccountId *types.IndexerSubaccountId `protobuf:"bytes,2,opt,name=recipient_subaccount_id,json=recipientSubaccountId,proto3" json:"recipient_subaccount_id,omitempty"` // Id of the asset transfered. AssetId uint32 `protobuf:"varint,3,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` // The amount of asset in quantums to transfer. @@ -656,14 +656,14 @@ func (m *TransferEventV1) XXX_DiscardUnknown() { var xxx_messageInfo_TransferEventV1 proto.InternalMessageInfo -func (m *TransferEventV1) GetSenderSubaccountId() *v1.IndexerSubaccountId { +func (m *TransferEventV1) GetSenderSubaccountId() *types.IndexerSubaccountId { if m != nil { return m.SenderSubaccountId } return nil } -func (m *TransferEventV1) GetRecipientSubaccountId() *v1.IndexerSubaccountId { +func (m *TransferEventV1) GetRecipientSubaccountId() *types.IndexerSubaccountId { if m != nil { return m.RecipientSubaccountId } @@ -702,7 +702,7 @@ func (m *TransferEventV1) GetRecipient() *SourceOfFunds { // the dYdX chain. This includes the maker/taker orders that matched and the // amount filled. type OrderFillEventV1 struct { - MakerOrder v1.IndexerOrder `protobuf:"bytes,1,opt,name=maker_order,json=makerOrder,proto3" json:"maker_order"` + MakerOrder types.IndexerOrder `protobuf:"bytes,1,opt,name=maker_order,json=makerOrder,proto3" json:"maker_order"` // The type of order fill this event represents. // // Types that are valid to be assigned to TakerOrder: @@ -763,7 +763,7 @@ type isOrderFillEventV1_TakerOrder interface { } type OrderFillEventV1_Order struct { - Order *v1.IndexerOrder `protobuf:"bytes,2,opt,name=order,proto3,oneof" json:"order,omitempty"` + Order *types.IndexerOrder `protobuf:"bytes,2,opt,name=order,proto3,oneof" json:"order,omitempty"` } type OrderFillEventV1_LiquidationOrder struct { LiquidationOrder *LiquidationOrderV1 `protobuf:"bytes,4,opt,name=liquidation_order,json=liquidationOrder,proto3,oneof" json:"liquidation_order,omitempty"` @@ -779,14 +779,14 @@ func (m *OrderFillEventV1) GetTakerOrder() isOrderFillEventV1_TakerOrder { return nil } -func (m *OrderFillEventV1) GetMakerOrder() v1.IndexerOrder { +func (m *OrderFillEventV1) GetMakerOrder() types.IndexerOrder { if m != nil { return m.MakerOrder } - return v1.IndexerOrder{} + return types.IndexerOrder{} } -func (m *OrderFillEventV1) GetOrder() *v1.IndexerOrder { +func (m *OrderFillEventV1) GetOrder() *types.IndexerOrder { if x, ok := m.GetTakerOrder().(*OrderFillEventV1_Order); ok { return x.Order } @@ -848,9 +848,9 @@ func (*OrderFillEventV1) XXX_OneofWrappers() []interface{} { // the amount filled. type DeleveragingEventV1 struct { // ID of the subaccount that was liquidated. - Liquidated v1.IndexerSubaccountId `protobuf:"bytes,1,opt,name=liquidated,proto3" json:"liquidated"` + Liquidated types.IndexerSubaccountId `protobuf:"bytes,1,opt,name=liquidated,proto3" json:"liquidated"` // ID of the subaccount that was used to offset the position. - Offsetting v1.IndexerSubaccountId `protobuf:"bytes,2,opt,name=offsetting,proto3" json:"offsetting"` + Offsetting types.IndexerSubaccountId `protobuf:"bytes,2,opt,name=offsetting,proto3" json:"offsetting"` // The ID of the perpetual that was liquidated. PerpetualId uint32 `protobuf:"varint,3,opt,name=perpetual_id,json=perpetualId,proto3" json:"perpetual_id,omitempty"` // The amount filled between the liquidated and offsetting position, in @@ -900,18 +900,18 @@ func (m *DeleveragingEventV1) XXX_DiscardUnknown() { var xxx_messageInfo_DeleveragingEventV1 proto.InternalMessageInfo -func (m *DeleveragingEventV1) GetLiquidated() v1.IndexerSubaccountId { +func (m *DeleveragingEventV1) GetLiquidated() types.IndexerSubaccountId { if m != nil { return m.Liquidated } - return v1.IndexerSubaccountId{} + return types.IndexerSubaccountId{} } -func (m *DeleveragingEventV1) GetOffsetting() v1.IndexerSubaccountId { +func (m *DeleveragingEventV1) GetOffsetting() types.IndexerSubaccountId { if m != nil { return m.Offsetting } - return v1.IndexerSubaccountId{} + return types.IndexerSubaccountId{} } func (m *DeleveragingEventV1) GetPerpetualId() uint32 { @@ -953,7 +953,7 @@ func (m *DeleveragingEventV1) GetIsFinalSettlement() bool { // liquidation order fill event. type LiquidationOrderV1 struct { // ID of the subaccount that was liquidated. - Liquidated v1.IndexerSubaccountId `protobuf:"bytes,1,opt,name=liquidated,proto3" json:"liquidated"` + Liquidated types.IndexerSubaccountId `protobuf:"bytes,1,opt,name=liquidated,proto3" json:"liquidated"` // The ID of the clob pair involved in the liquidation. ClobPairId uint32 `protobuf:"varint,2,opt,name=clob_pair_id,json=clobPairId,proto3" json:"clob_pair_id,omitempty"` // The ID of the perpetual involved in the liquidation. @@ -1004,11 +1004,11 @@ func (m *LiquidationOrderV1) XXX_DiscardUnknown() { var xxx_messageInfo_LiquidationOrderV1 proto.InternalMessageInfo -func (m *LiquidationOrderV1) GetLiquidated() v1.IndexerSubaccountId { +func (m *LiquidationOrderV1) GetLiquidated() types.IndexerSubaccountId { if m != nil { return m.Liquidated } - return v1.IndexerSubaccountId{} + return types.IndexerSubaccountId{} } func (m *LiquidationOrderV1) GetClobPairId() uint32 { @@ -1053,11 +1053,11 @@ func (m *LiquidationOrderV1) GetSubticks() uint64 { // at the end of a block which is why multiple asset/perpetual position // updates may exist. type SubaccountUpdateEventV1 struct { - SubaccountId *v1.IndexerSubaccountId `protobuf:"bytes,1,opt,name=subaccount_id,json=subaccountId,proto3" json:"subaccount_id,omitempty"` + SubaccountId *types.IndexerSubaccountId `protobuf:"bytes,1,opt,name=subaccount_id,json=subaccountId,proto3" json:"subaccount_id,omitempty"` // updated_perpetual_positions will each be for unique perpetuals. - UpdatedPerpetualPositions []*v1.IndexerPerpetualPosition `protobuf:"bytes,3,rep,name=updated_perpetual_positions,json=updatedPerpetualPositions,proto3" json:"updated_perpetual_positions,omitempty"` + UpdatedPerpetualPositions []*types.IndexerPerpetualPosition `protobuf:"bytes,3,rep,name=updated_perpetual_positions,json=updatedPerpetualPositions,proto3" json:"updated_perpetual_positions,omitempty"` // updated_asset_positions will each be for unique assets. - UpdatedAssetPositions []*v1.IndexerAssetPosition `protobuf:"bytes,4,rep,name=updated_asset_positions,json=updatedAssetPositions,proto3" json:"updated_asset_positions,omitempty"` + UpdatedAssetPositions []*types.IndexerAssetPosition `protobuf:"bytes,4,rep,name=updated_asset_positions,json=updatedAssetPositions,proto3" json:"updated_asset_positions,omitempty"` } func (m *SubaccountUpdateEventV1) Reset() { *m = SubaccountUpdateEventV1{} } @@ -1093,21 +1093,21 @@ func (m *SubaccountUpdateEventV1) XXX_DiscardUnknown() { var xxx_messageInfo_SubaccountUpdateEventV1 proto.InternalMessageInfo -func (m *SubaccountUpdateEventV1) GetSubaccountId() *v1.IndexerSubaccountId { +func (m *SubaccountUpdateEventV1) GetSubaccountId() *types.IndexerSubaccountId { if m != nil { return m.SubaccountId } return nil } -func (m *SubaccountUpdateEventV1) GetUpdatedPerpetualPositions() []*v1.IndexerPerpetualPosition { +func (m *SubaccountUpdateEventV1) GetUpdatedPerpetualPositions() []*types.IndexerPerpetualPosition { if m != nil { return m.UpdatedPerpetualPositions } return nil } -func (m *SubaccountUpdateEventV1) GetUpdatedAssetPositions() []*v1.IndexerAssetPosition { +func (m *SubaccountUpdateEventV1) GetUpdatedAssetPositions() []*types.IndexerAssetPosition { if m != nil { return m.UpdatedAssetPositions } @@ -1247,7 +1247,7 @@ func (*StatefulOrderEventV1) XXX_OneofWrappers() []interface{} { // A stateful order placement contains an order. type StatefulOrderEventV1_StatefulOrderPlacementV1 struct { - Order *v1.IndexerOrder `protobuf:"bytes,1,opt,name=order,proto3" json:"order,omitempty"` + Order *types.IndexerOrder `protobuf:"bytes,1,opt,name=order,proto3" json:"order,omitempty"` } func (m *StatefulOrderEventV1_StatefulOrderPlacementV1) Reset() { @@ -1287,7 +1287,7 @@ func (m *StatefulOrderEventV1_StatefulOrderPlacementV1) XXX_DiscardUnknown() { var xxx_messageInfo_StatefulOrderEventV1_StatefulOrderPlacementV1 proto.InternalMessageInfo -func (m *StatefulOrderEventV1_StatefulOrderPlacementV1) GetOrder() *v1.IndexerOrder { +func (m *StatefulOrderEventV1_StatefulOrderPlacementV1) GetOrder() *types.IndexerOrder { if m != nil { return m.Order } @@ -1297,8 +1297,8 @@ func (m *StatefulOrderEventV1_StatefulOrderPlacementV1) GetOrder() *v1.IndexerOr // A stateful order removal contains the id of an order that was already // placed and is now removed and the reason for the removal. type StatefulOrderEventV1_StatefulOrderRemovalV1 struct { - RemovedOrderId *v1.IndexerOrderId `protobuf:"bytes,1,opt,name=removed_order_id,json=removedOrderId,proto3" json:"removed_order_id,omitempty"` - Reason shared.OrderRemovalReason `protobuf:"varint,2,opt,name=reason,proto3,enum=dydxprotocol.indexer.shared.OrderRemovalReason" json:"reason,omitempty"` + RemovedOrderId *types.IndexerOrderId `protobuf:"bytes,1,opt,name=removed_order_id,json=removedOrderId,proto3" json:"removed_order_id,omitempty"` + Reason types1.OrderRemovalReason `protobuf:"varint,2,opt,name=reason,proto3,enum=dydxprotocol.indexer.shared.OrderRemovalReason" json:"reason,omitempty"` } func (m *StatefulOrderEventV1_StatefulOrderRemovalV1) Reset() { @@ -1338,24 +1338,24 @@ func (m *StatefulOrderEventV1_StatefulOrderRemovalV1) XXX_DiscardUnknown() { var xxx_messageInfo_StatefulOrderEventV1_StatefulOrderRemovalV1 proto.InternalMessageInfo -func (m *StatefulOrderEventV1_StatefulOrderRemovalV1) GetRemovedOrderId() *v1.IndexerOrderId { +func (m *StatefulOrderEventV1_StatefulOrderRemovalV1) GetRemovedOrderId() *types.IndexerOrderId { if m != nil { return m.RemovedOrderId } return nil } -func (m *StatefulOrderEventV1_StatefulOrderRemovalV1) GetReason() shared.OrderRemovalReason { +func (m *StatefulOrderEventV1_StatefulOrderRemovalV1) GetReason() types1.OrderRemovalReason { if m != nil { return m.Reason } - return shared.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED + return types1.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED } // A conditional order placement contains an order. The order is newly-placed // and untriggered when this event is emitted. type StatefulOrderEventV1_ConditionalOrderPlacementV1 struct { - Order *v1.IndexerOrder `protobuf:"bytes,1,opt,name=order,proto3" json:"order,omitempty"` + Order *types.IndexerOrder `protobuf:"bytes,1,opt,name=order,proto3" json:"order,omitempty"` } func (m *StatefulOrderEventV1_ConditionalOrderPlacementV1) Reset() { @@ -1395,7 +1395,7 @@ func (m *StatefulOrderEventV1_ConditionalOrderPlacementV1) XXX_DiscardUnknown() var xxx_messageInfo_StatefulOrderEventV1_ConditionalOrderPlacementV1 proto.InternalMessageInfo -func (m *StatefulOrderEventV1_ConditionalOrderPlacementV1) GetOrder() *v1.IndexerOrder { +func (m *StatefulOrderEventV1_ConditionalOrderPlacementV1) GetOrder() *types.IndexerOrder { if m != nil { return m.Order } @@ -1405,7 +1405,7 @@ func (m *StatefulOrderEventV1_ConditionalOrderPlacementV1) GetOrder() *v1.Indexe // A conditional order trigger event contains an order id and is emitted when // an order is triggered. type StatefulOrderEventV1_ConditionalOrderTriggeredV1 struct { - TriggeredOrderId *v1.IndexerOrderId `protobuf:"bytes,1,opt,name=triggered_order_id,json=triggeredOrderId,proto3" json:"triggered_order_id,omitempty"` + TriggeredOrderId *types.IndexerOrderId `protobuf:"bytes,1,opt,name=triggered_order_id,json=triggeredOrderId,proto3" json:"triggered_order_id,omitempty"` } func (m *StatefulOrderEventV1_ConditionalOrderTriggeredV1) Reset() { @@ -1445,7 +1445,7 @@ func (m *StatefulOrderEventV1_ConditionalOrderTriggeredV1) XXX_DiscardUnknown() var xxx_messageInfo_StatefulOrderEventV1_ConditionalOrderTriggeredV1 proto.InternalMessageInfo -func (m *StatefulOrderEventV1_ConditionalOrderTriggeredV1) GetTriggeredOrderId() *v1.IndexerOrderId { +func (m *StatefulOrderEventV1_ConditionalOrderTriggeredV1) GetTriggeredOrderId() *types.IndexerOrderId { if m != nil { return m.TriggeredOrderId } @@ -1454,7 +1454,7 @@ func (m *StatefulOrderEventV1_ConditionalOrderTriggeredV1) GetTriggeredOrderId() // A long term order placement contains an order. type StatefulOrderEventV1_LongTermOrderPlacementV1 struct { - Order *v1.IndexerOrder `protobuf:"bytes,1,opt,name=order,proto3" json:"order,omitempty"` + Order *types.IndexerOrder `protobuf:"bytes,1,opt,name=order,proto3" json:"order,omitempty"` } func (m *StatefulOrderEventV1_LongTermOrderPlacementV1) Reset() { @@ -1494,7 +1494,7 @@ func (m *StatefulOrderEventV1_LongTermOrderPlacementV1) XXX_DiscardUnknown() { var xxx_messageInfo_StatefulOrderEventV1_LongTermOrderPlacementV1 proto.InternalMessageInfo -func (m *StatefulOrderEventV1_LongTermOrderPlacementV1) GetOrder() *v1.IndexerOrder { +func (m *StatefulOrderEventV1_LongTermOrderPlacementV1) GetOrder() *types.IndexerOrder { if m != nil { return m.Order } @@ -1607,7 +1607,7 @@ type PerpetualMarketCreateEventV1 struct { // Defined in perpetuals.perpetual MarketId uint32 `protobuf:"varint,4,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` // Status of the CLOB - Status v1.ClobPairStatus `protobuf:"varint,5,opt,name=status,proto3,enum=dydxprotocol.indexer.protocol.v1.ClobPairStatus" json:"status,omitempty"` + Status types.ClobPairStatus `protobuf:"varint,5,opt,name=status,proto3,enum=dydxprotocol.indexer.protocol.v1.ClobPairStatus" json:"status,omitempty"` // `10^Exponent` gives the number of QuoteQuantums traded per BaseQuantum // per Subtick. // Defined in clob.clob_pair @@ -1693,11 +1693,11 @@ func (m *PerpetualMarketCreateEventV1) GetMarketId() uint32 { return 0 } -func (m *PerpetualMarketCreateEventV1) GetStatus() v1.ClobPairStatus { +func (m *PerpetualMarketCreateEventV1) GetStatus() types.ClobPairStatus { if m != nil { return m.Status } - return v1.ClobPairStatus_CLOB_PAIR_STATUS_UNSPECIFIED + return types.ClobPairStatus_CLOB_PAIR_STATUS_UNSPECIFIED } func (m *PerpetualMarketCreateEventV1) GetQuantumConversionExponent() int32 { @@ -1832,7 +1832,7 @@ type UpdateClobPairEventV1 struct { // Defined in clob.clob_pair ClobPairId uint32 `protobuf:"varint,1,opt,name=clob_pair_id,json=clobPairId,proto3" json:"clob_pair_id,omitempty"` // Status of the CLOB - Status v1.ClobPairStatus `protobuf:"varint,2,opt,name=status,proto3,enum=dydxprotocol.indexer.protocol.v1.ClobPairStatus" json:"status,omitempty"` + Status types.ClobPairStatus `protobuf:"varint,2,opt,name=status,proto3,enum=dydxprotocol.indexer.protocol.v1.ClobPairStatus" json:"status,omitempty"` // `10^Exponent` gives the number of QuoteQuantums traded per BaseQuantum // per Subtick. // Defined in clob.clob_pair @@ -1888,11 +1888,11 @@ func (m *UpdateClobPairEventV1) GetClobPairId() uint32 { return 0 } -func (m *UpdateClobPairEventV1) GetStatus() v1.ClobPairStatus { +func (m *UpdateClobPairEventV1) GetStatus() types.ClobPairStatus { if m != nil { return m.Status } - return v1.ClobPairStatus_CLOB_PAIR_STATUS_UNSPECIFIED + return types.ClobPairStatus_CLOB_PAIR_STATUS_UNSPECIFIED } func (m *UpdateClobPairEventV1) GetQuantumConversionExponent() int32 { @@ -5213,7 +5213,7 @@ func (m *SourceOfFunds) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &v1.IndexerSubaccountId{} + v := &types.IndexerSubaccountId{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5331,7 +5331,7 @@ func (m *TransferEventV1) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.SenderSubaccountId == nil { - m.SenderSubaccountId = &v1.IndexerSubaccountId{} + m.SenderSubaccountId = &types.IndexerSubaccountId{} } if err := m.SenderSubaccountId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -5367,7 +5367,7 @@ func (m *TransferEventV1) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.RecipientSubaccountId == nil { - m.RecipientSubaccountId = &v1.IndexerSubaccountId{} + m.RecipientSubaccountId = &types.IndexerSubaccountId{} } if err := m.RecipientSubaccountId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -5595,7 +5595,7 @@ func (m *OrderFillEventV1) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &v1.IndexerOrder{} + v := &types.IndexerOrder{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -6207,7 +6207,7 @@ func (m *SubaccountUpdateEventV1) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.SubaccountId == nil { - m.SubaccountId = &v1.IndexerSubaccountId{} + m.SubaccountId = &types.IndexerSubaccountId{} } if err := m.SubaccountId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -6242,7 +6242,7 @@ func (m *SubaccountUpdateEventV1) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.UpdatedPerpetualPositions = append(m.UpdatedPerpetualPositions, &v1.IndexerPerpetualPosition{}) + m.UpdatedPerpetualPositions = append(m.UpdatedPerpetualPositions, &types.IndexerPerpetualPosition{}) if err := m.UpdatedPerpetualPositions[len(m.UpdatedPerpetualPositions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -6276,7 +6276,7 @@ func (m *SubaccountUpdateEventV1) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.UpdatedAssetPositions = append(m.UpdatedAssetPositions, &v1.IndexerAssetPosition{}) + m.UpdatedAssetPositions = append(m.UpdatedAssetPositions, &types.IndexerAssetPosition{}) if err := m.UpdatedAssetPositions[len(m.UpdatedAssetPositions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -6586,7 +6586,7 @@ func (m *StatefulOrderEventV1_StatefulOrderPlacementV1) Unmarshal(dAtA []byte) e return io.ErrUnexpectedEOF } if m.Order == nil { - m.Order = &v1.IndexerOrder{} + m.Order = &types.IndexerOrder{} } if err := m.Order.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -6672,7 +6672,7 @@ func (m *StatefulOrderEventV1_StatefulOrderRemovalV1) Unmarshal(dAtA []byte) err return io.ErrUnexpectedEOF } if m.RemovedOrderId == nil { - m.RemovedOrderId = &v1.IndexerOrderId{} + m.RemovedOrderId = &types.IndexerOrderId{} } if err := m.RemovedOrderId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -6692,7 +6692,7 @@ func (m *StatefulOrderEventV1_StatefulOrderRemovalV1) Unmarshal(dAtA []byte) err } b := dAtA[iNdEx] iNdEx++ - m.Reason |= shared.OrderRemovalReason(b&0x7F) << shift + m.Reason |= types1.OrderRemovalReason(b&0x7F) << shift if b < 0x80 { break } @@ -6777,7 +6777,7 @@ func (m *StatefulOrderEventV1_ConditionalOrderPlacementV1) Unmarshal(dAtA []byte return io.ErrUnexpectedEOF } if m.Order == nil { - m.Order = &v1.IndexerOrder{} + m.Order = &types.IndexerOrder{} } if err := m.Order.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -6863,7 +6863,7 @@ func (m *StatefulOrderEventV1_ConditionalOrderTriggeredV1) Unmarshal(dAtA []byte return io.ErrUnexpectedEOF } if m.TriggeredOrderId == nil { - m.TriggeredOrderId = &v1.IndexerOrderId{} + m.TriggeredOrderId = &types.IndexerOrderId{} } if err := m.TriggeredOrderId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -6949,7 +6949,7 @@ func (m *StatefulOrderEventV1_LongTermOrderPlacementV1) Unmarshal(dAtA []byte) e return io.ErrUnexpectedEOF } if m.Order == nil { - m.Order = &v1.IndexerOrder{} + m.Order = &types.IndexerOrder{} } if err := m.Order.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -7269,7 +7269,7 @@ func (m *PerpetualMarketCreateEventV1) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Status |= v1.ClobPairStatus(b&0x7F) << shift + m.Status |= types.ClobPairStatus(b&0x7F) << shift if b < 0x80 { break } @@ -7614,7 +7614,7 @@ func (m *UpdateClobPairEventV1) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Status |= v1.ClobPairStatus(b&0x7F) << shift + m.Status |= types.ClobPairStatus(b&0x7F) << shift if b < 0x80 { break } diff --git a/protocol/indexer/events/perpetual_market_create_test.go b/protocol/indexer/events/perpetual_market_create_test.go index 7d217f2647..75461321f2 100644 --- a/protocol/indexer/events/perpetual_market_create_test.go +++ b/protocol/indexer/events/perpetual_market_create_test.go @@ -3,7 +3,7 @@ package events import ( "testing" - v1 "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" + v1types "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1/types" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" "github.com/stretchr/testify/require" @@ -27,7 +27,7 @@ func TestNewPerpetualMarketCreateEvent_Success(t *testing.T) { ClobPairId: 0, Ticker: "BTC", MarketId: 0, - Status: v1.ClobPairStatus_CLOB_PAIR_STATUS_ACTIVE, + Status: v1types.ClobPairStatus_CLOB_PAIR_STATUS_ACTIVE, QuantumConversionExponent: -8, AtomicResolution: 8, SubticksPerTick: 5, diff --git a/protocol/indexer/events/stateful_order.go b/protocol/indexer/events/stateful_order.go index d6f8ee6663..f1a0d029db 100644 --- a/protocol/indexer/events/stateful_order.go +++ b/protocol/indexer/events/stateful_order.go @@ -1,8 +1,8 @@ package events import ( - "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" - "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + v1 "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" + sharedtypes "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" ) @@ -22,7 +22,7 @@ func NewLongTermOrderPlacementEvent( func NewStatefulOrderRemovalEvent( removedOrderId clobtypes.OrderId, - reason shared.OrderRemovalReason, + reason sharedtypes.OrderRemovalReason, ) *StatefulOrderEventV1 { orderId := v1.OrderIdToIndexerOrderId(removedOrderId) orderRemoval := StatefulOrderEventV1_StatefulOrderRemovalV1{ diff --git a/protocol/indexer/events/stateful_order_test.go b/protocol/indexer/events/stateful_order_test.go index 9f83db0087..4a19d48a74 100644 --- a/protocol/indexer/events/stateful_order_test.go +++ b/protocol/indexer/events/stateful_order_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/dydxprotocol/v4-chain/protocol/indexer/events" - "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" - "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + v1 "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" + sharedtypes "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" "github.com/stretchr/testify/require" ) @@ -15,7 +15,7 @@ var ( indexerOrder = v1.OrderToIndexerOrder(order) orderId = constants.OrderId_Alice_Num0_ClientId0_Clob0 indexerOrderId = v1.OrderIdToIndexerOrderId(orderId) - reason = shared.OrderRemovalReason_ORDER_REMOVAL_REASON_REPLACED + reason = sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_REPLACED ) func TestLongTermOrderPlacementEvent_Success(t *testing.T) { diff --git a/protocol/indexer/off_chain_updates/off_chain_updates.go b/protocol/indexer/off_chain_updates/off_chain_updates.go index 0d9dd1b8ae..3c1a6754d2 100644 --- a/protocol/indexer/off_chain_updates/off_chain_updates.go +++ b/protocol/indexer/off_chain_updates/off_chain_updates.go @@ -8,8 +8,10 @@ import ( "github.com/cometbft/cometbft/libs/log" "github.com/dydxprotocol/v4-chain/protocol/indexer/common" "github.com/dydxprotocol/v4-chain/protocol/indexer/msgsender" + ocutypes "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates/types" v1 "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + sharedtypes "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" ) @@ -96,8 +98,8 @@ func CreateOrderUpdateMessage( func MustCreateOrderRemoveMessageWithReason( logger log.Logger, orderId clobtypes.OrderId, - reason shared.OrderRemovalReason, - removalStatus OrderRemoveV1_OrderRemovalStatus, + reason sharedtypes.OrderRemovalReason, + removalStatus ocutypes.OrderRemoveV1_OrderRemovalStatus, ) msgsender.Message { msg, ok := CreateOrderRemoveMessageWithReason(logger, orderId, reason, removalStatus) if !ok { @@ -111,8 +113,8 @@ func MustCreateOrderRemoveMessageWithReason( func CreateOrderRemoveMessageWithReason( logger log.Logger, orderId clobtypes.OrderId, - reason shared.OrderRemovalReason, - removalStatus OrderRemoveV1_OrderRemovalStatus, + reason sharedtypes.OrderRemovalReason, + removalStatus ocutypes.OrderRemoveV1_OrderRemovalStatus, ) (message msgsender.Message, success bool) { errMessage := "Error creating off-chain update message for removing order." errDetails := fmt.Sprintf( @@ -142,7 +144,7 @@ func MustCreateOrderRemoveMessage(logger log.Logger, orderId clobtypes.OrderId, orderStatus clobtypes.OrderStatus, orderError error, - removalStatus OrderRemoveV1_OrderRemovalStatus, + removalStatus ocutypes.OrderRemoveV1_OrderRemovalStatus, ) msgsender.Message { msg, ok := CreateOrderRemoveMessage(logger, orderId, orderStatus, orderError, removalStatus) if !ok { @@ -158,7 +160,7 @@ func CreateOrderRemoveMessage( orderId clobtypes.OrderId, orderStatus clobtypes.OrderStatus, orderError error, - removalStatus OrderRemoveV1_OrderRemovalStatus, + removalStatus ocutypes.OrderRemoveV1_OrderRemovalStatus, ) (message msgsender.Message, success bool) { errDetails := fmt.Sprintf( "OrderId: %+v, Removal status %d", @@ -191,10 +193,10 @@ func CreateOrderRemoveMessageWithDefaultReason( orderId clobtypes.OrderId, orderStatus clobtypes.OrderStatus, orderError error, - removalStatus OrderRemoveV1_OrderRemovalStatus, - defaultRemovalReason shared.OrderRemovalReason, + removalStatus ocutypes.OrderRemoveV1_OrderRemovalStatus, + defaultRemovalReason sharedtypes.OrderRemovalReason, ) (message msgsender.Message, success bool) { - if defaultRemovalReason == shared.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED { + if defaultRemovalReason == sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED { panic( fmt.Errorf( "Invalid parameter: " + @@ -230,12 +232,12 @@ func newOrderPlaceMessage( order clobtypes.Order, ) ([]byte, error) { indexerOrder := v1.OrderToIndexerOrder(order) - update := OffChainUpdateV1{ - UpdateMessage: &OffChainUpdateV1_OrderPlace{ - &OrderPlaceV1{ + update := ocutypes.OffChainUpdateV1{ + UpdateMessage: &ocutypes.OffChainUpdateV1_OrderPlace{ + OrderPlace: &ocutypes.OrderPlaceV1{ Order: &indexerOrder, // Protocol will always send best effort opened messages to indexer. - PlacementStatus: OrderPlaceV1_ORDER_PLACEMENT_STATUS_BEST_EFFORT_OPENED, + PlacementStatus: ocutypes.OrderPlaceV1_ORDER_PLACEMENT_STATUS_BEST_EFFORT_OPENED, }, }, } @@ -247,13 +249,13 @@ func newOrderPlaceMessage( // The `OrderRemove` struct is instantiated with the given orderId, reason and status parameters. func newOrderRemoveMessage( orderId clobtypes.OrderId, - reason shared.OrderRemovalReason, - status OrderRemoveV1_OrderRemovalStatus, + reason sharedtypes.OrderRemovalReason, + status ocutypes.OrderRemoveV1_OrderRemovalStatus, ) ([]byte, error) { indexerOrderId := v1.OrderIdToIndexerOrderId(orderId) - update := OffChainUpdateV1{ - UpdateMessage: &OffChainUpdateV1_OrderRemove{ - &OrderRemoveV1{ + update := ocutypes.OffChainUpdateV1{ + UpdateMessage: &ocutypes.OffChainUpdateV1_OrderRemove{ + OrderRemove: &ocutypes.OrderRemoveV1{ RemovedOrderId: &indexerOrderId, Reason: reason, RemovalStatus: status, @@ -271,9 +273,9 @@ func newOrderUpdateMessage( totalFilled satypes.BaseQuantums, ) ([]byte, error) { indexerOrderId := v1.OrderIdToIndexerOrderId(orderId) - update := OffChainUpdateV1{ - UpdateMessage: &OffChainUpdateV1_OrderUpdate{ - &OrderUpdateV1{ + update := ocutypes.OffChainUpdateV1{ + UpdateMessage: &ocutypes.OffChainUpdateV1_OrderUpdate{ + OrderUpdate: &ocutypes.OrderUpdateV1{ OrderId: &indexerOrderId, TotalFilledQuantums: totalFilled.ToUint64(), }, @@ -283,7 +285,7 @@ func newOrderUpdateMessage( } func marshalOffchainUpdate( - offChainUpdate OffChainUpdateV1, + offChainUpdate ocutypes.OffChainUpdateV1, marshaler common.Marshaler, ) ([]byte, error) { updateBytes, err := marshaler.Marshal(&offChainUpdate) diff --git a/protocol/indexer/off_chain_updates/off_chain_updates_test.go b/protocol/indexer/off_chain_updates/off_chain_updates_test.go index 8fcfe240f5..f2eca69771 100644 --- a/protocol/indexer/off_chain_updates/off_chain_updates_test.go +++ b/protocol/indexer/off_chain_updates/off_chain_updates_test.go @@ -9,8 +9,9 @@ import ( "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/gogoproto/proto" "github.com/dydxprotocol/v4-chain/protocol/indexer/msgsender" + ocutypes "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates/types" v1 "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" - "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + sharedtypes "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/mocks" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" @@ -26,37 +27,37 @@ var ( totalFilledAmount = satypes.BaseQuantums(5) orderStatus = clobtypes.Undercollateralized orderError error = nil - reason = shared.OrderRemovalReason_ORDER_REMOVAL_REASON_UNDERCOLLATERALIZED - status = OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED - defaultRemovalReason = shared.OrderRemovalReason_ORDER_REMOVAL_REASON_INTERNAL_ERROR - offchainUpdateOrderPlace = OffChainUpdateV1{ - UpdateMessage: &OffChainUpdateV1_OrderPlace{ - &OrderPlaceV1{ + reason = sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_UNDERCOLLATERALIZED + status = ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED + defaultRemovalReason = sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_INTERNAL_ERROR + offchainUpdateOrderPlace = ocutypes.OffChainUpdateV1{ + UpdateMessage: &ocutypes.OffChainUpdateV1_OrderPlace{ + OrderPlace: &ocutypes.OrderPlaceV1{ Order: &indexerOrder, - PlacementStatus: OrderPlaceV1_ORDER_PLACEMENT_STATUS_BEST_EFFORT_OPENED, + PlacementStatus: ocutypes.OrderPlaceV1_ORDER_PLACEMENT_STATUS_BEST_EFFORT_OPENED, }, }, } - offchainUpdateOrderUpdate = OffChainUpdateV1{ - UpdateMessage: &OffChainUpdateV1_OrderUpdate{ - &OrderUpdateV1{ + offchainUpdateOrderUpdate = ocutypes.OffChainUpdateV1{ + UpdateMessage: &ocutypes.OffChainUpdateV1_OrderUpdate{ + OrderUpdate: &ocutypes.OrderUpdateV1{ OrderId: &indexerOrder.OrderId, TotalFilledQuantums: totalFilledAmount.ToUint64(), }, }, } - offchainUpdateOrderRemove = OffChainUpdateV1{ - UpdateMessage: &OffChainUpdateV1_OrderRemove{ - &OrderRemoveV1{ + offchainUpdateOrderRemove = ocutypes.OffChainUpdateV1{ + UpdateMessage: &ocutypes.OffChainUpdateV1_OrderRemove{ + OrderRemove: &ocutypes.OrderRemoveV1{ RemovedOrderId: &indexerOrder.OrderId, Reason: reason, RemovalStatus: status, }, }, } - offchainUpdateOrderRemoveWithDefaultRemovalReason = OffChainUpdateV1{ - UpdateMessage: &OffChainUpdateV1_OrderRemove{ - &OrderRemoveV1{ + offchainUpdateOrderRemoveWithDefaultRemovalReason = ocutypes.OffChainUpdateV1{ + UpdateMessage: &ocutypes.OffChainUpdateV1_OrderRemove{ + OrderRemove: &ocutypes.OrderRemoveV1{ RemovedOrderId: &indexerOrder.OrderId, Reason: defaultRemovalReason, RemovalStatus: status, @@ -170,7 +171,7 @@ func TestCreateOrderRemoveMessageWithDefaultReason_InvalidDefault(t *testing.T) clobtypes.Success, orderError, status, - shared.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED, + sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED, ) }, ) @@ -203,7 +204,7 @@ func TestNewOrderPlaceMessage(t *testing.T) { err, "Encoding OffchainUpdateV1 proto into bytes should not result in an error.", ) - actualUpdate := &OffChainUpdateV1{} + actualUpdate := &ocutypes.OffChainUpdateV1{} err = proto.Unmarshal(actualUpdateBytes, actualUpdate) require.NoError( t, @@ -225,7 +226,7 @@ func TestNewOrderUpdateMessage(t *testing.T) { err, "Encoding OffchainUpdateV1 proto into bytes should not result in an error.", ) - actualUpdate := &OffChainUpdateV1{} + actualUpdate := &ocutypes.OffChainUpdateV1{} err = proto.Unmarshal(actualUpdateBytes, actualUpdate) require.NoError( t, @@ -247,7 +248,7 @@ func TestNewOrderRemoveMessage(t *testing.T) { err, "Encoding OffchainUpdateV1 proto into bytes should not result in an error.", ) - actualUpdate := &OffChainUpdateV1{} + actualUpdate := &ocutypes.OffChainUpdateV1{} err = proto.Unmarshal(actualUpdateBytes, actualUpdate) require.NoError( t, diff --git a/protocol/indexer/off_chain_updates/off_chain_updates.pb.go b/protocol/indexer/off_chain_updates/types/off_chain_updates.pb.go similarity index 87% rename from protocol/indexer/off_chain_updates/off_chain_updates.pb.go rename to protocol/indexer/off_chain_updates/types/off_chain_updates.pb.go index 91edbecf6b..b2dddf6dd2 100644 --- a/protocol/indexer/off_chain_updates/off_chain_updates.pb.go +++ b/protocol/indexer/off_chain_updates/types/off_chain_updates.pb.go @@ -1,13 +1,13 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto -package off_chain_updates +package types import ( fmt "fmt" proto "github.com/cosmos/gogoproto/proto" - v1 "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" - shared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + types "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1/types" + types1 "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" io "io" math "math" math_bits "math/bits" @@ -120,7 +120,7 @@ func (OrderRemoveV1_OrderRemovalStatus) EnumDescriptor() ([]byte, []int) { // OrderPlace messages contain the order placed/replaced. type OrderPlaceV1 struct { - Order *v1.IndexerOrder `protobuf:"bytes,1,opt,name=order,proto3" json:"order,omitempty"` + Order *types.IndexerOrder `protobuf:"bytes,1,opt,name=order,proto3" json:"order,omitempty"` PlacementStatus OrderPlaceV1_OrderPlacementStatus `protobuf:"varint,2,opt,name=placement_status,json=placementStatus,proto3,enum=dydxprotocol.indexer.off_chain_updates.OrderPlaceV1_OrderPlacementStatus" json:"placement_status,omitempty"` } @@ -157,7 +157,7 @@ func (m *OrderPlaceV1) XXX_DiscardUnknown() { var xxx_messageInfo_OrderPlaceV1 proto.InternalMessageInfo -func (m *OrderPlaceV1) GetOrder() *v1.IndexerOrder { +func (m *OrderPlaceV1) GetOrder() *types.IndexerOrder { if m != nil { return m.Order } @@ -174,8 +174,8 @@ func (m *OrderPlaceV1) GetPlacementStatus() OrderPlaceV1_OrderPlacementStatus { // OrderRemove messages contain the id of the order removed, the reason for the // removal and the resulting status from the removal. type OrderRemoveV1 struct { - RemovedOrderId *v1.IndexerOrderId `protobuf:"bytes,1,opt,name=removed_order_id,json=removedOrderId,proto3" json:"removed_order_id,omitempty"` - Reason shared.OrderRemovalReason `protobuf:"varint,2,opt,name=reason,proto3,enum=dydxprotocol.indexer.shared.OrderRemovalReason" json:"reason,omitempty"` + RemovedOrderId *types.IndexerOrderId `protobuf:"bytes,1,opt,name=removed_order_id,json=removedOrderId,proto3" json:"removed_order_id,omitempty"` + Reason types1.OrderRemovalReason `protobuf:"varint,2,opt,name=reason,proto3,enum=dydxprotocol.indexer.shared.OrderRemovalReason" json:"reason,omitempty"` RemovalStatus OrderRemoveV1_OrderRemovalStatus `protobuf:"varint,3,opt,name=removal_status,json=removalStatus,proto3,enum=dydxprotocol.indexer.off_chain_updates.OrderRemoveV1_OrderRemovalStatus" json:"removal_status,omitempty"` } @@ -212,18 +212,18 @@ func (m *OrderRemoveV1) XXX_DiscardUnknown() { var xxx_messageInfo_OrderRemoveV1 proto.InternalMessageInfo -func (m *OrderRemoveV1) GetRemovedOrderId() *v1.IndexerOrderId { +func (m *OrderRemoveV1) GetRemovedOrderId() *types.IndexerOrderId { if m != nil { return m.RemovedOrderId } return nil } -func (m *OrderRemoveV1) GetReason() shared.OrderRemovalReason { +func (m *OrderRemoveV1) GetReason() types1.OrderRemovalReason { if m != nil { return m.Reason } - return shared.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED + return types1.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED } func (m *OrderRemoveV1) GetRemovalStatus() OrderRemoveV1_OrderRemovalStatus { @@ -236,8 +236,8 @@ func (m *OrderRemoveV1) GetRemovalStatus() OrderRemoveV1_OrderRemovalStatus { // OrderUpdate messages contain the id of the order being updated, and the // updated total filled quantums of the order. type OrderUpdateV1 struct { - OrderId *v1.IndexerOrderId `protobuf:"bytes,1,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"` - TotalFilledQuantums uint64 `protobuf:"varint,2,opt,name=total_filled_quantums,json=totalFilledQuantums,proto3" json:"total_filled_quantums,omitempty"` + OrderId *types.IndexerOrderId `protobuf:"bytes,1,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"` + TotalFilledQuantums uint64 `protobuf:"varint,2,opt,name=total_filled_quantums,json=totalFilledQuantums,proto3" json:"total_filled_quantums,omitempty"` } func (m *OrderUpdateV1) Reset() { *m = OrderUpdateV1{} } @@ -273,7 +273,7 @@ func (m *OrderUpdateV1) XXX_DiscardUnknown() { var xxx_messageInfo_OrderUpdateV1 proto.InternalMessageInfo -func (m *OrderUpdateV1) GetOrderId() *v1.IndexerOrderId { +func (m *OrderUpdateV1) GetOrderId() *types.IndexerOrderId { if m != nil { return m.OrderId } @@ -403,46 +403,47 @@ func init() { } var fileDescriptor_a3058c1b66f59e98 = []byte{ - // 623 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xd1, 0x6e, 0xd3, 0x3c, - 0x18, 0x4d, 0xba, 0xff, 0x1f, 0xc8, 0xdb, 0x4a, 0x64, 0x40, 0x9a, 0x86, 0x08, 0x23, 0x42, 0xd3, - 0x10, 0x5a, 0xb2, 0x96, 0x71, 0x8b, 0xd4, 0xa5, 0x29, 0x8b, 0xe8, 0x9a, 0xe2, 0x76, 0x43, 0xaa, - 0x84, 0xac, 0xb4, 0x71, 0xd7, 0x4a, 0x69, 0x5d, 0x92, 0xb4, 0x1a, 0x6f, 0xb1, 0x17, 0xe1, 0x92, - 0x77, 0xe0, 0x72, 0x37, 0x48, 0xdc, 0x20, 0xa1, 0xf6, 0x45, 0x50, 0x6c, 0x37, 0x6b, 0xd7, 0x4c, - 0xa3, 0xe3, 0xf2, 0xfb, 0x72, 0xbe, 0xe3, 0xe3, 0x73, 0x3e, 0xb7, 0xe0, 0xad, 0xf7, 0xc5, 0x3b, - 0x1f, 0x04, 0x34, 0xa2, 0x2d, 0xea, 0x1b, 0xdd, 0xbe, 0x47, 0xce, 0x49, 0x60, 0xd0, 0x76, 0x1b, - 0xb7, 0x3a, 0x6e, 0xb7, 0x8f, 0x87, 0x03, 0xcf, 0x8d, 0x48, 0xb8, 0xd8, 0xd1, 0xd9, 0x10, 0xdc, - 0x99, 0x9d, 0xd7, 0xc5, 0xbc, 0xbe, 0x80, 0xde, 0xda, 0x4f, 0x3d, 0x27, 0xec, 0xb8, 0x01, 0xf1, - 0x8c, 0x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0xc1, 0x23, 0x09, - 0x01, 0x9a, 0xd4, 0xb0, 0x01, 0xd6, 0x39, 0x31, 0x5f, 0x41, 0x26, 0x6c, 0x2d, 0xff, 0xe6, 0x4e, - 0xfb, 0x71, 0x24, 0x21, 0xae, 0x92, 0x37, 0xae, 0xb8, 0x39, 0x9a, 0xed, 0xde, 0xb2, 0xdc, 0x53, - 0x07, 0x12, 0x6e, 0xde, 0x38, 0x54, 0x40, 0x96, 0xe3, 0x70, 0x8f, 0x84, 0xa1, 0x7b, 0x46, 0x0e, - 0x3f, 0x7d, 0x1f, 0xab, 0xf2, 0xe5, 0x58, 0x95, 0x7f, 0x8f, 0x55, 0xf9, 0x62, 0xa2, 0x4a, 0x97, - 0x13, 0x55, 0xfa, 0x39, 0x51, 0xa5, 0x86, 0x79, 0xd6, 0x8d, 0x3a, 0xc3, 0xa6, 0xde, 0xa2, 0x3d, - 0x63, 0xee, 0x47, 0x75, 0x74, 0xb0, 0xc7, 0x8e, 0x34, 0x6e, 0xff, 0x03, 0x68, 0xae, 0x32, 0xcc, - 0xeb, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdf, 0xd9, 0x86, 0x42, 0x31, 0x06, 0x00, 0x00, + // 626 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xc1, 0x6e, 0xda, 0x4a, + 0x14, 0xb5, 0xc9, 0x7b, 0x69, 0x35, 0x49, 0xa8, 0x35, 0x6d, 0xa5, 0x28, 0x55, 0xdd, 0xd4, 0xaa, + 0xa2, 0x54, 0x55, 0xec, 0x40, 0xd3, 0x6d, 0x25, 0x02, 0xa6, 0xb1, 0x4a, 0x30, 0x1d, 0x48, 0x2a, + 0xb1, 0x19, 0x19, 0x7b, 0x08, 0x48, 0x86, 0xa1, 0xb6, 0x41, 0xc9, 0x5f, 0xe4, 0x47, 0xba, 0xec, + 0x3f, 0x74, 0x99, 0x4d, 0xa5, 0x6e, 0x2a, 0x55, 0xf0, 0x23, 0x95, 0x67, 0x06, 0x07, 0x82, 0xa3, + 0x86, 0x74, 0x79, 0xaf, 0xcf, 0x3d, 0x73, 0xe6, 0x9c, 0x3b, 0x00, 0xde, 0x7b, 0x17, 0xde, 0xf9, + 0x20, 0xa0, 0x11, 0x75, 0xa9, 0x6f, 0x74, 0xfb, 0x1e, 0x39, 0x27, 0x81, 0x41, 0xdb, 0x6d, 0xec, + 0x76, 0x9c, 0x6e, 0x1f, 0x0f, 0x07, 0x9e, 0x13, 0x91, 0x70, 0xb1, 0xa3, 0xb3, 0x21, 0xb8, 0x33, + 0x3b, 0xaf, 0x8b, 0x79, 0x7d, 0x01, 0xbd, 0xb5, 0x9f, 0x7a, 0x4e, 0xd8, 0x71, 0x02, 0xe2, 0x19, + 0x01, 0xe9, 0xd1, 0x91, 0xe3, 0xe3, 0x80, 0x38, 0x21, 0xed, 0x73, 0xe6, 0xad, 0x37, 0xa9, 0x13, + 0x49, 0x63, 0x94, 0x33, 0x5c, 0x9f, 0xb6, 0x38, 0x58, 0xfb, 0x95, 0x01, 0xeb, 0x76, 0xe0, 0x91, + 0xa0, 0xe6, 0x3b, 0x2e, 0x39, 0xcd, 0xc1, 0x12, 0xf8, 0x9f, 0xc6, 0xf5, 0xa6, 0xbc, 0x2d, 0xef, + 0xae, 0xe5, 0x75, 0x3d, 0x55, 0x67, 0xd2, 0x18, 0xe5, 0x74, 0x8b, 0xf7, 0x18, 0x0b, 0xe2, 0xc3, + 0x30, 0x02, 0xca, 0x20, 0x26, 0xec, 0x91, 0x7e, 0x84, 0xc3, 0xc8, 0x89, 0x86, 0xe1, 0x66, 0x66, + 0x5b, 0xde, 0xcd, 0xe6, 0x2d, 0xfd, 0x6e, 0x17, 0xd7, 0x67, 0x55, 0xcd, 0x14, 0x31, 0x63, 0x9d, + 0x11, 0xa2, 0x47, 0x83, 0xf9, 0x86, 0x76, 0x29, 0x83, 0x27, 0x69, 0x48, 0x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ff, 0xff, 0x0c, 0x93, 0x06, 0x17, 0x37, 0x06, + 0x00, 0x00, } func (m *OrderPlaceV1) Marshal() (dAtA []byte, err error) { @@ -841,7 +842,7 @@ func (m *OrderPlaceV1) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Order == nil { - m.Order = &v1.IndexerOrder{} + m.Order = &types.IndexerOrder{} } if err := m.Order.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -946,7 +947,7 @@ func (m *OrderRemoveV1) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.RemovedOrderId == nil { - m.RemovedOrderId = &v1.IndexerOrderId{} + m.RemovedOrderId = &types.IndexerOrderId{} } if err := m.RemovedOrderId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -966,7 +967,7 @@ func (m *OrderRemoveV1) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Reason |= shared.OrderRemovalReason(b&0x7F) << shift + m.Reason |= types1.OrderRemovalReason(b&0x7F) << shift if b < 0x80 { break } @@ -1070,7 +1071,7 @@ func (m *OrderUpdateV1) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.OrderId == nil { - m.OrderId = &v1.IndexerOrderId{} + m.OrderId = &types.IndexerOrderId{} } if err := m.OrderId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/protocol/indexer/protocol/v1/clob.pb.go b/protocol/indexer/protocol/v1/types/clob.pb.go similarity index 86% rename from protocol/indexer/protocol/v1/clob.pb.go rename to protocol/indexer/protocol/v1/types/clob.pb.go index 1c4958743c..610d20b977 100644 --- a/protocol/indexer/protocol/v1/clob.pb.go +++ b/protocol/indexer/protocol/v1/types/clob.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: dydxprotocol/indexer/protocol/v1/clob.proto -package v1 +package types import ( encoding_binary "encoding/binary" @@ -487,59 +487,60 @@ func init() { } var fileDescriptor_fac8923e70f7ca3c = []byte{ - // 830 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x4d, 0x73, 0xdb, 0x54, - 0x14, 0xb5, 0x1c, 0x37, 0x71, 0xae, 0x3f, 0x10, 0x8f, 0x32, 0x15, 0x49, 0xeb, 0xb8, 0x9e, 0x01, - 0x32, 0x30, 0xd8, 0xa4, 0x85, 0x05, 0x0c, 0x2c, 0x6c, 0x45, 0x6e, 0xdf, 0x44, 0x91, 0x8c, 0xf4, - 0x02, 0x93, 0x2e, 0x78, 0xc8, 0xd2, 0x8b, 0xfb, 0xa6, 0xb2, 0x5e, 0x90, 0xe5, 0x4c, 0xbd, 0xe3, - 0x27, 0xf0, 0xb3, 0xba, 0xec, 0xb0, 0x60, 0x58, 0x31, 0x4c, 0xf2, 0x27, 0x58, 0x32, 0x4f, 0x12, - 0xaa, 0x1d, 0x77, 0x08, 0xd9, 0xe9, 0x9e, 0x7b, 0xee, 0x99, 0x7b, 0xce, 0x95, 0x2d, 0xf8, 0x34, - 0x58, 0x04, 0x2f, 0xcf, 0x63, 0x91, 0x08, 0x5f, 0x84, 0x3d, 0x1e, 0x05, 0xec, 0x25, 0x8b, 0x7b, - 0x05, 0x70, 0x71, 0xd0, 0xf3, 0x43, 0x31, 0xee, 0xa6, 0x00, 0x6a, 0x2f, 0x93, 0xbb, 0x39, 0xb9, - 0x5b, 0x00, 0x17, 0x07, 0x3b, 0x07, 0x37, 0xca, 0xcd, 0xe6, 0x63, 0xcf, 0xf7, 0xc5, 0x3c, 0x4a, - 0xb2, 0xc1, 0x9d, 0xbb, 0x13, 0x31, 0x11, 0xe9, 0x63, 0x4f, 0x3e, 0x65, 0x68, 0xe7, 0x37, 0x05, - 0x9a, 0x38, 0x1b, 0xb7, 0xe3, 0x80, 0xc5, 0x38, 0x40, 0x3f, 0x41, 0xe3, 0xcd, 0x30, 0xe5, 0x81, - 0xa6, 0x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 0x45, 0xa2, 0x15, 0xf4, 0x10, 0x1e, 0xac, 0xf5, 0xb1, 0x85, 0x09, 0xee, 0x9b, 0xf8, - 0x19, 0xb6, 0x9e, 0xa8, 0x77, 0xd0, 0x87, 0xf0, 0x70, 0x8d, 0x32, 0xc4, 0x56, 0xdf, 0xa4, 0xae, - 0x41, 0x88, 0x69, 0x1c, 0x1b, 0x16, 0x51, 0x37, 0x07, 0x3f, 0xbc, 0xba, 0x6c, 0x29, 0xaf, 0x2f, - 0x5b, 0xca, 0x5f, 0x97, 0x2d, 0xe5, 0xd7, 0xab, 0x56, 0xe9, 0xf5, 0x55, 0xab, 0xf4, 0xc7, 0x55, - 0xab, 0xf4, 0xec, 0xdb, 0x09, 0x4f, 0x9e, 0xcf, 0xc7, 0x5d, 0x5f, 0x4c, 0x7b, 0x2b, 0x9f, 0x85, - 0x8b, 0x2f, 0x3e, 0xf3, 0x9f, 0x7b, 0x3c, 0xea, 0xfd, 0xd7, 0x87, 0x62, 0xbc, 0x99, 0x16, 0x8f, - 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x08, 0xc4, 0xc7, 0xa2, 0x06, 0x00, 0x00, + // 833 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xdf, 0x6f, 0xdb, 0x54, + 0x14, 0x8e, 0xd3, 0xac, 0x4d, 0x4f, 0x7e, 0x60, 0x2e, 0x43, 0x33, 0xed, 0x96, 0x66, 0x91, 0x80, + 0x0a, 0x44, 0x42, 0x37, 0x78, 0x00, 0xf1, 0x92, 0xb8, 0xce, 0x76, 0x55, 0xd7, 0x0e, 0xf6, 0x2d, + 0x52, 0x27, 0xc1, 0xc5, 0xb1, 0x6f, 0xb3, 0xab, 0x39, 0xbe, 0xc5, 0x71, 0xaa, 0xe5, 0x8d, 0x3f, + 0x81, 0x3f, 0x6b, 0x8f, 0x13, 0x0f, 0x88, 0x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 0xe2, 0xab, 0x2f, 0xfc, 0xe7, 0x1e, 0x8f, 0x7a, 0xff, 0xfb, 0xa3, 0x90, 0xef, 0xcd, 0x6c, 0xbc, + 0x99, 0x42, 0x8f, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x2d, 0xd9, 0x1f, 0x8a, 0xa8, 0x06, 0x00, + 0x00, } func (m *IndexerOrderId) Marshal() (dAtA []byte, err error) { diff --git a/protocol/indexer/protocol/v1/subaccount.pb.go b/protocol/indexer/protocol/v1/types/subaccount.pb.go similarity index 90% rename from protocol/indexer/protocol/v1/subaccount.pb.go rename to protocol/indexer/protocol/v1/types/subaccount.pb.go index ff506ebe8b..47569ed8e7 100644 --- a/protocol/indexer/protocol/v1/subaccount.pb.go +++ b/protocol/indexer/protocol/v1/types/subaccount.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: dydxprotocol/indexer/protocol/v1/subaccount.proto -package v1 +package types import ( fmt "fmt" @@ -209,33 +209,33 @@ func init() { } var fileDescriptor_4c5845963309ad8f = []byte{ - // 407 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x93, 0x3f, 0xef, 0xd2, 0x40, - 0x1c, 0xc6, 0x5b, 0x7f, 0x7f, 0xfc, 0x79, 0x82, 0x26, 0xb5, 0x31, 0x85, 0xa1, 0x20, 0x13, 0x0b, - 0x6d, 0x88, 0xae, 0x26, 0xc2, 0x64, 0x37, 0x52, 0x06, 0x13, 0x13, 0x43, 0xae, 0xbd, 0xb3, 0x5c, - 0xd2, 0xde, 0x95, 0xfb, 0x83, 0xe0, 0xee, 0xee, 0x1b, 0x71, 0xf3, 0x45, 0x30, 0x12, 0x27, 0xe3, - 0x40, 0x0c, 0xbc, 0x11, 0xc3, 0x5d, 0x29, 0x9a, 0x38, 0x38, 0x10, 0xb7, 0x7b, 0x3e, 0xf9, 0x7e, - 0x9f, 0x27, 0x79, 0xbe, 0x39, 0x30, 0x44, 0x6b, 0xb4, 0x2a, 0x39, 0x93, 0x2c, 0x65, 0x79, 0x48, - 0x28, 0xc2, 0x2b, 0xcc, 0xc3, 0x1a, 0x2c, 0x87, 0xa1, 0x50, 0x09, 0x4c, 0x53, 0xa6, 0xa8, 0x0c, - 0x34, 0x76, 0xba, 0xbf, 0xaf, 0x04, 0xd5, 0x4a, 0x50, 0x83, 0xe5, 0xb0, 0xdd, 0x4a, 0x99, 0x28, - 0x98, 0x98, 0x69, 0x16, 0x1a, 0x61, 0x06, 0xda, 0x6e, 0xc6, 0x32, 0x66, 0xf8, 0xf1, 0x65, 0x68, - 0xef, 0x1d, 0x78, 0x12, 0x19, 0x9f, 0x69, 0x9d, 0x16, 0x21, 0x27, 0x00, 0x37, 0xec, 0x03, 0xc5, - 0xdc, 0xb3, 0xbb, 0x76, 0xff, 0xc1, 0xd8, 0xfb, 0xf6, 0x75, 0xe0, 0x56, 0x6e, 0x23, 0x84, 0x38, - 0x16, 0x62, 0x2a, 0x39, 0xa1, 0x59, 0x6c, 0xc6, 0x9c, 0xa7, 0xe0, 0x96, 0xaa, 0x22, 0xc1, 0xdc, - 0xbb, 0xd7, 0xb5, 0xfb, 0xcd, 0xb8, 0x52, 0xbd, 0x4f, 0x57, 0xc0, 0xab, 0xfc, 0x27, 0x98, 0x97, - 0x58, 0x2a, 0x98, 0x4f, 0x98, 0x20, 0x92, 0x30, 0xea, 0x3c, 0x03, 0x8d, 0xf2, 0x04, 0x67, 0x04, - 0xe9, 0xac, 0x66, 0xfc, 0xb0, 0x66, 0x11, 0x72, 0x10, 0xb8, 0x5b, 0x28, 0x48, 0xa5, 0x2a, 0x84, - 0x76, 0x6e, 0x8c, 0x5f, 0x6f, 0x76, 0x1d, 0xeb, 0xc7, 0xae, 0xf3, 0x2a, 0x23, 0x72, 0xae, 0x92, - 0x20, 0x65, 0x45, 0xf8, 0x47, 0x93, 0xcb, 0x17, 0x83, 0x74, 0x0e, 0x09, 0x3d, 0x57, 0x89, 0xe4, - 0xba, 0xc4, 0x22, 0x98, 0x62, 0x4e, 0x60, 0x4e, 0x3e, 0xc2, 0x24, 0xc7, 0x11, 0x95, 0x71, 0xed, - 0xec, 0x14, 0xa0, 0xf9, 0x5e, 0x51, 0x44, 0x68, 0x36, 0xd3, 0xa5, 0x7a, 0x57, 0x17, 0x8e, 0x6a, - 0x54, 0xf6, 0xba, 0x0a, 0x67, 0x01, 0x1e, 0x9f, 0xe2, 0x4a, 0xb8, 0x2e, 0x30, 0x95, 0xde, 0xf5, - 0x85, 0x03, 0x1f, 0x55, 0x01, 0x13, 0xe3, 0xdf, 0xfb, 0x62, 0x03, 0xb7, 0xba, 0xc3, 0x48, 0x08, - 0x2c, 0xeb, 0x1b, 0xb4, 0xc0, 0x1d, 0x3c, 0x82, 0x73, 0xff, 0xf7, 0xb5, 0xfe, 0x6f, 0xdd, 0xbb, - 0xe0, 0xe6, 0xdc, 0xf9, 0x75, 0x6c, 0xc4, 0xf8, 0xcd, 0x66, 0xef, 0xdb, 0xdb, 0xbd, 0x6f, 0xff, - 0xdc, 0xfb, 0xf6, 0xe7, 0x83, 0x6f, 0x6d, 0x0f, 0xbe, 0xf5, 0xfd, 0xe0, 0x5b, 0x6f, 0x5f, 0xfe, - 0x7b, 0xf6, 0x5f, 0xfe, 0x54, 0x72, 0xab, 0xc5, 0xf3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7e, - 0xd9, 0xb3, 0xdc, 0x7e, 0x03, 0x00, 0x00, + // 408 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x93, 0xcf, 0xae, 0xd2, 0x40, + 0x18, 0xc5, 0x5b, 0xef, 0x1f, 0xaf, 0x23, 0x68, 0x52, 0x1b, 0xd3, 0xcb, 0xa2, 0x20, 0x2b, 0x36, + 0xb4, 0x21, 0xfa, 0x00, 0x82,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e, 0xa3, 0x84, 0x03, 0x00, 0x00, } func (m *IndexerSubaccountId) Marshal() (dAtA []byte, err error) { diff --git a/protocol/indexer/protocol/v1/v1_mappers.go b/protocol/indexer/protocol/v1/v1_mappers.go index b404d3435c..bf04b5d1cc 100644 --- a/protocol/indexer/protocol/v1/v1_mappers.go +++ b/protocol/indexer/protocol/v1/v1_mappers.go @@ -4,14 +4,15 @@ import ( "fmt" "github.com/dydxprotocol/v4-chain/protocol/dtypes" + v1types "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1/types" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" ) func SubaccountIdToIndexerSubaccountId( subaccountId satypes.SubaccountId, -) IndexerSubaccountId { - return IndexerSubaccountId{ +) v1types.IndexerSubaccountId { + return v1types.IndexerSubaccountId{ Owner: subaccountId.Owner, Number: subaccountId.Number, } @@ -20,8 +21,8 @@ func SubaccountIdToIndexerSubaccountId( func PerpetualPositionToIndexerPerpetualPosition( perpetualPosition *satypes.PerpetualPosition, fundingPayment dtypes.SerializableInt, -) *IndexerPerpetualPosition { - return &IndexerPerpetualPosition{ +) *v1types.IndexerPerpetualPosition { + return &v1types.IndexerPerpetualPosition{ PerpetualId: perpetualPosition.PerpetualId, Quantums: perpetualPosition.Quantums, FundingIndex: perpetualPosition.FundingIndex, @@ -32,11 +33,11 @@ func PerpetualPositionToIndexerPerpetualPosition( func PerpetualPositionsToIndexerPerpetualPositions( perpetualPositions []*satypes.PerpetualPosition, fundingPayments map[uint32]dtypes.SerializableInt, -) []*IndexerPerpetualPosition { +) []*v1types.IndexerPerpetualPosition { if perpetualPositions == nil { return nil } - indexerPerpetualPositions := make([]*IndexerPerpetualPosition, 0, len(perpetualPositions)) + indexerPerpetualPositions := make([]*v1types.IndexerPerpetualPosition, 0, len(perpetualPositions)) for _, perpetualPosition := range perpetualPositions { // Retrieve funding payment for this perpetual position (0 by default). fundingPayment, exists := fundingPayments[perpetualPosition.PerpetualId] @@ -56,8 +57,8 @@ func PerpetualPositionsToIndexerPerpetualPositions( func AssetPositionToIndexerAssetPosition( assetPosition *satypes.AssetPosition, -) *IndexerAssetPosition { - return &IndexerAssetPosition{ +) *v1types.IndexerAssetPosition { + return &v1types.IndexerAssetPosition{ AssetId: assetPosition.AssetId, Quantums: assetPosition.Quantums, Index: assetPosition.Index, @@ -66,11 +67,11 @@ func AssetPositionToIndexerAssetPosition( func AssetPositionsToIndexerAssetPositions( assetPositions []*satypes.AssetPosition, -) []*IndexerAssetPosition { +) []*v1types.IndexerAssetPosition { if assetPositions == nil { return nil } - indexerAssetPositions := make([]*IndexerAssetPosition, 0, len(assetPositions)) + indexerAssetPositions := make([]*v1types.IndexerAssetPosition, 0, len(assetPositions)) for _, assetPosition := range assetPositions { indexerAssetPositions = append( indexerAssetPositions, @@ -82,8 +83,8 @@ func AssetPositionsToIndexerAssetPositions( func OrderIdToIndexerOrderId( orderId clobtypes.OrderId, -) IndexerOrderId { - return IndexerOrderId{ +) v1types.IndexerOrderId { + return v1types.IndexerOrderId{ SubaccountId: SubaccountIdToIndexerSubaccountId(orderId.SubaccountId), ClientId: orderId.ClientId, OrderFlags: orderId.OrderFlags, @@ -93,35 +94,35 @@ func OrderIdToIndexerOrderId( func OrderSideToIndexerOrderSide( orderSide clobtypes.Order_Side, -) IndexerOrder_Side { - return IndexerOrder_Side(orderSide) +) v1types.IndexerOrder_Side { + return v1types.IndexerOrder_Side(orderSide) } func OrderTimeInForceToIndexerOrderTimeInForce( orderTimeInForce clobtypes.Order_TimeInForce, -) IndexerOrder_TimeInForce { - return IndexerOrder_TimeInForce(orderTimeInForce) +) v1types.IndexerOrder_TimeInForce { + return v1types.IndexerOrder_TimeInForce(orderTimeInForce) } func OrderConditionTypeToIndexerOrderConditionType( orderConditionType clobtypes.Order_ConditionType, -) IndexerOrder_ConditionType { - return IndexerOrder_ConditionType(orderConditionType) +) v1types.IndexerOrder_ConditionType { + return v1types.IndexerOrder_ConditionType(orderConditionType) } func OrderToIndexerOrder( order clobtypes.Order, -) IndexerOrder { +) v1types.IndexerOrder { switch goodTil := order.GoodTilOneof.(type) { case *clobtypes.Order_GoodTilBlock: return orderToIndexerOrder_GoodTilBlock( order, - IndexerOrder_GoodTilBlock{GoodTilBlock: goodTil.GoodTilBlock}, + v1types.IndexerOrder_GoodTilBlock{GoodTilBlock: goodTil.GoodTilBlock}, ) case *clobtypes.Order_GoodTilBlockTime: return orderToIndexerOrder_GoodTilBlockTime( order, - IndexerOrder_GoodTilBlockTime{GoodTilBlockTime: goodTil.GoodTilBlockTime}, + v1types.IndexerOrder_GoodTilBlockTime{GoodTilBlockTime: goodTil.GoodTilBlockTime}, ) default: panic(fmt.Errorf("Unexpected GoodTilOneof in Order: %+v", order)) @@ -130,9 +131,9 @@ func OrderToIndexerOrder( func orderToIndexerOrder_GoodTilBlock( order clobtypes.Order, - goodTilBlock IndexerOrder_GoodTilBlock, -) IndexerOrder { - return IndexerOrder{ + goodTilBlock v1types.IndexerOrder_GoodTilBlock, +) v1types.IndexerOrder { + return v1types.IndexerOrder{ OrderId: OrderIdToIndexerOrderId(order.OrderId), Side: OrderSideToIndexerOrderSide(order.Side), Quantums: order.Quantums, @@ -148,9 +149,9 @@ func orderToIndexerOrder_GoodTilBlock( func orderToIndexerOrder_GoodTilBlockTime( order clobtypes.Order, - goodTilBlockTime IndexerOrder_GoodTilBlockTime, -) IndexerOrder { - return IndexerOrder{ + goodTilBlockTime v1types.IndexerOrder_GoodTilBlockTime, +) v1types.IndexerOrder { + return v1types.IndexerOrder{ OrderId: OrderIdToIndexerOrderId(order.OrderId), Side: OrderSideToIndexerOrderSide(order.Side), Quantums: order.Quantums, @@ -164,20 +165,20 @@ func orderToIndexerOrder_GoodTilBlockTime( } } -func ConvertToClobPairStatus(status clobtypes.ClobPair_Status) ClobPairStatus { +func ConvertToClobPairStatus(status clobtypes.ClobPair_Status) v1types.ClobPairStatus { switch status { case clobtypes.ClobPair_STATUS_ACTIVE: - return ClobPairStatus_CLOB_PAIR_STATUS_ACTIVE + return v1types.ClobPairStatus_CLOB_PAIR_STATUS_ACTIVE case clobtypes.ClobPair_STATUS_PAUSED: - return ClobPairStatus_CLOB_PAIR_STATUS_PAUSED + return v1types.ClobPairStatus_CLOB_PAIR_STATUS_PAUSED case clobtypes.ClobPair_STATUS_CANCEL_ONLY: - return ClobPairStatus_CLOB_PAIR_STATUS_CANCEL_ONLY + return v1types.ClobPairStatus_CLOB_PAIR_STATUS_CANCEL_ONLY case clobtypes.ClobPair_STATUS_POST_ONLY: - return ClobPairStatus_CLOB_PAIR_STATUS_POST_ONLY + return v1types.ClobPairStatus_CLOB_PAIR_STATUS_POST_ONLY case clobtypes.ClobPair_STATUS_INITIALIZING: - return ClobPairStatus_CLOB_PAIR_STATUS_INITIALIZING + return v1types.ClobPairStatus_CLOB_PAIR_STATUS_INITIALIZING case clobtypes.ClobPair_STATUS_FINAL_SETTLEMENT: - return ClobPairStatus_CLOB_PAIR_STATUS_FINAL_SETTLEMENT + return v1types.ClobPairStatus_CLOB_PAIR_STATUS_FINAL_SETTLEMENT default: panic( fmt.Sprintf( diff --git a/protocol/indexer/protocol/v1/v1_mappers_test.go b/protocol/indexer/protocol/v1/v1_mappers_test.go index af79807302..e94fd0f885 100644 --- a/protocol/indexer/protocol/v1/v1_mappers_test.go +++ b/protocol/indexer/protocol/v1/v1_mappers_test.go @@ -6,6 +6,7 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/dtypes" v1 "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" + v1types "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1/types" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" @@ -14,7 +15,7 @@ import ( func TestSubaccountIdToIndexerSubaccountId(t *testing.T) { subaccountId := constants.Alice_Num1 - expectedSubaccountId := v1.IndexerSubaccountId{ + expectedSubaccountId := v1types.IndexerSubaccountId{ Owner: subaccountId.Owner, Number: subaccountId.Number, } @@ -31,7 +32,7 @@ func TestPerpetualPositionToIndexerPerpetualPosition(t *testing.T) { fundingPayments := map[uint32]dtypes.SerializableInt{ position.PerpetualId: dtypes.NewInt(100), } - expectedPerpetualPosition := &v1.IndexerPerpetualPosition{ + expectedPerpetualPosition := &v1types.IndexerPerpetualPosition{ PerpetualId: position.PerpetualId, Quantums: position.Quantums, FundingIndex: position.FundingIndex, @@ -58,14 +59,14 @@ func TestPerpetualPositionsToIndexerPerpetualPositions(t *testing.T) { fundingPayments map[uint32]dtypes.SerializableInt // Expectations - expectedPerpetualPositions []*v1.IndexerPerpetualPosition + expectedPerpetualPositions []*v1types.IndexerPerpetualPosition }{ "Maps slice of PerpetualPosition to slice of IndexerPerpetualPosition with no funding payments": { positions: []*satypes.PerpetualPosition{ position, position2, }, - expectedPerpetualPositions: []*v1.IndexerPerpetualPosition{ + expectedPerpetualPositions: []*v1types.IndexerPerpetualPosition{ { PerpetualId: position.PerpetualId, Quantums: position.Quantums, @@ -89,7 +90,7 @@ func TestPerpetualPositionsToIndexerPerpetualPositions(t *testing.T) { position.PerpetualId: dtypes.NewInt(100), position2.PerpetualId: dtypes.NewInt(-100), }, - expectedPerpetualPositions: []*v1.IndexerPerpetualPosition{ + expectedPerpetualPositions: []*v1types.IndexerPerpetualPosition{ { PerpetualId: position.PerpetualId, Quantums: position.Quantums, @@ -106,7 +107,7 @@ func TestPerpetualPositionsToIndexerPerpetualPositions(t *testing.T) { }, "Maps empty slice to empty slice": { positions: []*satypes.PerpetualPosition{}, - expectedPerpetualPositions: []*v1.IndexerPerpetualPosition{}, + expectedPerpetualPositions: []*v1types.IndexerPerpetualPosition{}, }, "Maps nil to nil slice": { positions: nil, @@ -129,7 +130,7 @@ func TestPerpetualPositionsToIndexerPerpetualPositions(t *testing.T) { func TestAssetPositionToIndexerAssetPosition(t *testing.T) { position := &constants.Long_Asset_1BTC - expectedAssetPosition := &v1.IndexerAssetPosition{ + expectedAssetPosition := &v1types.IndexerAssetPosition{ AssetId: position.AssetId, Quantums: position.Quantums, Index: position.Index, @@ -151,14 +152,14 @@ func TestAssetPositionsToIndexerAssetPositions(t *testing.T) { positions []*satypes.AssetPosition // Expectations - expectedAssetPositions []*v1.IndexerAssetPosition + expectedAssetPositions []*v1types.IndexerAssetPosition }{ "Maps slice of AssetPosition to slice of IndexerAssetPosition": { positions: []*satypes.AssetPosition{ position, position2, }, - expectedAssetPositions: []*v1.IndexerAssetPosition{ + expectedAssetPositions: []*v1types.IndexerAssetPosition{ { AssetId: position.AssetId, Quantums: position.Quantums, @@ -173,7 +174,7 @@ func TestAssetPositionsToIndexerAssetPositions(t *testing.T) { }, "Maps empty slice to empty slice": { positions: []*satypes.AssetPosition{}, - expectedAssetPositions: []*v1.IndexerAssetPosition{}, + expectedAssetPositions: []*v1types.IndexerAssetPosition{}, }, "Maps nil to nil slice": { positions: nil, @@ -193,8 +194,8 @@ func TestAssetPositionsToIndexerAssetPositions(t *testing.T) { func TestOrderIdToIndexerOrderId(t *testing.T) { orderId := constants.LongTermOrderId_Alice_Num1_ClientId3_Clob1 - expectedOrderId := v1.IndexerOrderId{ - SubaccountId: v1.IndexerSubaccountId{ + expectedOrderId := v1types.IndexerOrderId{ + SubaccountId: v1types.IndexerSubaccountId{ Owner: orderId.SubaccountId.Owner, Number: orderId.SubaccountId.Number, }, @@ -216,17 +217,17 @@ func TestOrderSideToIndexerOrderSide(t *testing.T) { side clobtypes.Order_Side // Expectations - expectedSide v1.IndexerOrder_Side + expectedSide v1types.IndexerOrder_Side }{} // Iterate through all the values for Order_Side to create test cases. for name, value := range clobtypes.Order_Side_value { testName := fmt.Sprintf("Converts Order_Side %s to IndexerOrderV1_Side", name) tests[testName] = struct { side clobtypes.Order_Side - expectedSide v1.IndexerOrder_Side + expectedSide v1types.IndexerOrder_Side }{ side: clobtypes.Order_Side(value), - expectedSide: v1.IndexerOrder_Side(v1.IndexerOrder_Side_value[name]), + expectedSide: v1types.IndexerOrder_Side(v1types.IndexerOrder_Side_value[name]), } } for name, tc := range tests { @@ -246,17 +247,17 @@ func TestOrderTimeInForceToIndexerOrderTimeInForce(t *testing.T) { timeInForce clobtypes.Order_TimeInForce // Expectations - expectedTimeInForce v1.IndexerOrder_TimeInForce + expectedTimeInForce v1types.IndexerOrder_TimeInForce }{} // Iterate through all the values for Order_TimeInForce to create test cases. for name, value := range clobtypes.Order_TimeInForce_value { testName := fmt.Sprintf("Converts Order_TimeInForce %s to IndexerOrderV1_TimeInForce", name) tests[testName] = struct { timeInForce clobtypes.Order_TimeInForce - expectedTimeInForce v1.IndexerOrder_TimeInForce + expectedTimeInForce v1types.IndexerOrder_TimeInForce }{ timeInForce: clobtypes.Order_TimeInForce(value), - expectedTimeInForce: v1.IndexerOrder_TimeInForce(v1.IndexerOrder_TimeInForce_value[name]), + expectedTimeInForce: v1types.IndexerOrder_TimeInForce(v1types.IndexerOrder_TimeInForce_value[name]), } } for name, tc := range tests { @@ -276,17 +277,17 @@ func TestOrderConditionTypeToIndexerOrderConditionType(t *testing.T) { conditionType clobtypes.Order_ConditionType // Expectations - expectedConditionType v1.IndexerOrder_ConditionType + expectedConditionType v1types.IndexerOrder_ConditionType }{} // Iterate through all the values for Order_ConditionType to create test cases. for name, value := range clobtypes.Order_ConditionType_value { testName := fmt.Sprintf("Converts Order_ConditionType %s to IndexerOrderV1_ConditionType", name) tests[testName] = struct { conditionType clobtypes.Order_ConditionType - expectedConditionType v1.IndexerOrder_ConditionType + expectedConditionType v1types.IndexerOrder_ConditionType }{ conditionType: clobtypes.Order_ConditionType(value), - expectedConditionType: v1.IndexerOrder_ConditionType(v1.IndexerOrder_ConditionType_value[name]), + expectedConditionType: v1types.IndexerOrder_ConditionType(v1types.IndexerOrder_ConditionType_value[name]), } } for name, tc := range tests { @@ -309,13 +310,13 @@ func TestOrderToIndexerOrderV1(t *testing.T) { order clobtypes.Order // Expectations - expectedOrder v1.IndexerOrder + expectedOrder v1types.IndexerOrder }{ "Maps short term order to IndexerOrderV1": { order: shortTermOrder, - expectedOrder: v1.IndexerOrder{ - OrderId: v1.IndexerOrderId{ - SubaccountId: v1.IndexerSubaccountId{ + expectedOrder: v1types.IndexerOrder{ + OrderId: v1types.IndexerOrderId{ + SubaccountId: v1types.IndexerSubaccountId{ Owner: shortTermOrder.OrderId.SubaccountId.Owner, Number: shortTermOrder.OrderId.SubaccountId.Number, }, @@ -326,7 +327,7 @@ func TestOrderToIndexerOrderV1(t *testing.T) { Side: v1.OrderSideToIndexerOrderSide(shortTermOrder.Side), Quantums: shortTermOrder.Quantums, Subticks: shortTermOrder.Subticks, - GoodTilOneof: &v1.IndexerOrder_GoodTilBlock{ + GoodTilOneof: &v1types.IndexerOrder_GoodTilBlock{ GoodTilBlock: shortTermOrder.GoodTilOneof.(*clobtypes.Order_GoodTilBlock).GoodTilBlock, }, TimeInForce: v1.OrderTimeInForceToIndexerOrderTimeInForce(shortTermOrder.TimeInForce), @@ -338,9 +339,9 @@ func TestOrderToIndexerOrderV1(t *testing.T) { }, "Maps stateful order to IndexerOrderV1": { order: statefulOrder, - expectedOrder: v1.IndexerOrder{ - OrderId: v1.IndexerOrderId{ - SubaccountId: v1.IndexerSubaccountId{ + expectedOrder: v1types.IndexerOrder{ + OrderId: v1types.IndexerOrderId{ + SubaccountId: v1types.IndexerSubaccountId{ Owner: statefulOrder.OrderId.SubaccountId.Owner, Number: statefulOrder.OrderId.SubaccountId.Number, }, @@ -351,7 +352,7 @@ func TestOrderToIndexerOrderV1(t *testing.T) { Side: v1.OrderSideToIndexerOrderSide(statefulOrder.Side), Quantums: statefulOrder.Quantums, Subticks: statefulOrder.Subticks, - GoodTilOneof: &v1.IndexerOrder_GoodTilBlockTime{ + GoodTilOneof: &v1types.IndexerOrder_GoodTilBlockTime{ GoodTilBlockTime: statefulOrder.GoodTilOneof.(*clobtypes.Order_GoodTilBlockTime).GoodTilBlockTime, }, TimeInForce: v1.OrderTimeInForceToIndexerOrderTimeInForce(statefulOrder.TimeInForce), @@ -385,7 +386,7 @@ func TestOrderToIndexerOrder_Panic(t *testing.T) { func TestConvertToClobPairStatus(t *testing.T) { type convertToClobPairStatusTestCase struct { status clobtypes.ClobPair_Status - expectedStatus v1.ClobPairStatus + expectedStatus v1types.ClobPairStatus expectedPanic string } @@ -395,7 +396,7 @@ func TestConvertToClobPairStatus(t *testing.T) { testName := fmt.Sprintf("Converts ClobPair_Status %s to v1.ClobPairStatus", name) testCase := convertToClobPairStatusTestCase{ status: clobtypes.ClobPair_Status(value), - expectedStatus: v1.ClobPairStatus(clobtypes.ClobPair_Status_value[name]), + expectedStatus: v1types.ClobPairStatus(clobtypes.ClobPair_Status_value[name]), } if value == int32(clobtypes.ClobPair_STATUS_UNSPECIFIED) { testCase.expectedPanic = fmt.Sprintf( diff --git a/protocol/indexer/shared/order_removal_reason.go b/protocol/indexer/shared/order_removal_reason.go index 30d5be544f..c307984fa4 100644 --- a/protocol/indexer/shared/order_removal_reason.go +++ b/protocol/indexer/shared/order_removal_reason.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + sharedtypes "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" ) @@ -12,21 +13,21 @@ import ( // a bulk of order removals and generate offchain updates for each order removal. func ConvertOrderRemovalReasonToIndexerOrderRemovalReason( removalReason clobtypes.OrderRemoval_RemovalReason, -) OrderRemovalReason { - var reason OrderRemovalReason +) sharedtypes.OrderRemovalReason { + var reason sharedtypes.OrderRemovalReason switch removalReason { case clobtypes.OrderRemoval_REMOVAL_REASON_UNDERCOLLATERALIZED: - reason = OrderRemovalReason_ORDER_REMOVAL_REASON_UNDERCOLLATERALIZED + reason = sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_UNDERCOLLATERALIZED case clobtypes.OrderRemoval_REMOVAL_REASON_INVALID_REDUCE_ONLY: - reason = OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE + reason = sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE case clobtypes.OrderRemoval_REMOVAL_REASON_POST_ONLY_WOULD_CROSS_MAKER_ORDER: - reason = OrderRemovalReason_ORDER_REMOVAL_REASON_POST_ONLY_WOULD_CROSS_MAKER_ORDER + reason = sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_POST_ONLY_WOULD_CROSS_MAKER_ORDER case clobtypes.OrderRemoval_REMOVAL_REASON_INVALID_SELF_TRADE: - reason = OrderRemovalReason_ORDER_REMOVAL_REASON_SELF_TRADE_ERROR + reason = sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_SELF_TRADE_ERROR case clobtypes.OrderRemoval_REMOVAL_REASON_CONDITIONAL_FOK_COULD_NOT_BE_FULLY_FILLED: - reason = OrderRemovalReason_ORDER_REMOVAL_REASON_FOK_ORDER_COULD_NOT_BE_FULLY_FULLED + reason = sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_FOK_ORDER_COULD_NOT_BE_FULLY_FULLED case clobtypes.OrderRemoval_REMOVAL_REASON_CONDITIONAL_IOC_WOULD_REST_ON_BOOK: - reason = OrderRemovalReason_ORDER_REMOVAL_REASON_IMMEDIATE_OR_CANCEL_WOULD_REST_ON_BOOK + reason = sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_IMMEDIATE_OR_CANCEL_WOULD_REST_ON_BOOK default: panic("ConvertOrderRemovalReasonToIndexerOrderRemovalReason: unspecified removal reason not allowed") } @@ -38,25 +39,25 @@ func ConvertOrderRemovalReasonToIndexerOrderRemovalReason( func GetOrderRemovalReason( orderStatus clobtypes.OrderStatus, orderError error, -) (OrderRemovalReason, error) { +) (sharedtypes.OrderRemovalReason, error) { switch { case errors.Is(orderError, clobtypes.ErrPostOnlyWouldCrossMakerOrder): - return OrderRemovalReason_ORDER_REMOVAL_REASON_POST_ONLY_WOULD_CROSS_MAKER_ORDER, nil + return sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_POST_ONLY_WOULD_CROSS_MAKER_ORDER, nil case errors.Is(orderError, clobtypes.ErrFokOrderCouldNotBeFullyFilled): - return OrderRemovalReason_ORDER_REMOVAL_REASON_FOK_ORDER_COULD_NOT_BE_FULLY_FULLED, nil + return sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_FOK_ORDER_COULD_NOT_BE_FULLY_FULLED, nil case errors.Is(orderError, clobtypes.ErrOrderWouldExceedMaxOpenOrdersEquityTierLimit): - return OrderRemovalReason_ORDER_REMOVAL_REASON_EQUITY_TIER, nil + return sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_EQUITY_TIER, nil } switch orderStatus { case clobtypes.Undercollateralized: - return OrderRemovalReason_ORDER_REMOVAL_REASON_UNDERCOLLATERALIZED, nil + return sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_UNDERCOLLATERALIZED, nil case clobtypes.InternalError: - return OrderRemovalReason_ORDER_REMOVAL_REASON_INTERNAL_ERROR, nil + return sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_INTERNAL_ERROR, nil case clobtypes.ImmediateOrCancelWouldRestOnBook: - return OrderRemovalReason_ORDER_REMOVAL_REASON_IMMEDIATE_OR_CANCEL_WOULD_REST_ON_BOOK, nil + return sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_IMMEDIATE_OR_CANCEL_WOULD_REST_ON_BOOK, nil case clobtypes.ReduceOnlyResized: - return OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE, nil + return sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE, nil default: return 0, fmt.Errorf("unrecognized order status %d and error \"%w\"", orderStatus, orderError) } diff --git a/protocol/indexer/shared/order_removal_reason_test.go b/protocol/indexer/shared/order_removal_reason_test.go index 4ad0ca2f3c..785b453257 100644 --- a/protocol/indexer/shared/order_removal_reason_test.go +++ b/protocol/indexer/shared/order_removal_reason_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + sharedtypes "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" "github.com/stretchr/testify/require" ) @@ -16,32 +17,32 @@ func TestGetOrderRemovalReason_Success(t *testing.T) { orderError error // Expectations - expectedReason shared.OrderRemovalReason + expectedReason sharedtypes.OrderRemovalReason expectedErr error }{ "Gets order removal reason for order status Undercollateralized": { orderStatus: clobtypes.Undercollateralized, - expectedReason: shared.OrderRemovalReason_ORDER_REMOVAL_REASON_UNDERCOLLATERALIZED, + expectedReason: sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_UNDERCOLLATERALIZED, expectedErr: nil, }, "Gets order removal reason for order status InternalError": { orderStatus: clobtypes.InternalError, - expectedReason: shared.OrderRemovalReason_ORDER_REMOVAL_REASON_INTERNAL_ERROR, + expectedReason: sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_INTERNAL_ERROR, expectedErr: nil, }, "Gets order removal reason for order status ImmediateOrCancelWouldRestOnBook": { orderStatus: clobtypes.ImmediateOrCancelWouldRestOnBook, - expectedReason: shared.OrderRemovalReason_ORDER_REMOVAL_REASON_IMMEDIATE_OR_CANCEL_WOULD_REST_ON_BOOK, + expectedReason: sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_IMMEDIATE_OR_CANCEL_WOULD_REST_ON_BOOK, expectedErr: nil, }, "Gets order removal reason for order error ErrFokOrderCouldNotBeFullyFilled": { orderError: clobtypes.ErrFokOrderCouldNotBeFullyFilled, - expectedReason: shared.OrderRemovalReason_ORDER_REMOVAL_REASON_FOK_ORDER_COULD_NOT_BE_FULLY_FULLED, + expectedReason: sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_FOK_ORDER_COULD_NOT_BE_FULLY_FULLED, expectedErr: nil, }, "Gets order removal reason for order error ErrPostOnlyWouldCrossMakerOrder": { orderError: clobtypes.ErrPostOnlyWouldCrossMakerOrder, - expectedReason: shared.OrderRemovalReason_ORDER_REMOVAL_REASON_POST_ONLY_WOULD_CROSS_MAKER_ORDER, + expectedReason: sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_POST_ONLY_WOULD_CROSS_MAKER_ORDER, expectedErr: nil, }, "Returns error for order status Success": { diff --git a/protocol/indexer/shared/removal_reason.pb.go b/protocol/indexer/shared/types/removal_reason.pb.go similarity index 68% rename from protocol/indexer/shared/removal_reason.pb.go rename to protocol/indexer/shared/types/removal_reason.pb.go index 480302a924..c76598861b 100644 --- a/protocol/indexer/shared/removal_reason.pb.go +++ b/protocol/indexer/shared/types/removal_reason.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: dydxprotocol/indexer/shared/removal_reason.proto -package shared +package types import ( fmt "fmt" @@ -125,34 +125,35 @@ func init() { } var fileDescriptor_0d5eea5cab8c58ba = []byte{ - // 461 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xcd, 0x6e, 0xd3, 0x40, - 0x14, 0x85, 0x13, 0xa0, 0x05, 0x86, 0x1f, 0x8d, 0x66, 0x0b, 0x58, 0x2d, 0xb4, 0xb4, 0xfc, 0x25, - 0x48, 0x20, 0x54, 0x01, 0x12, 0x9a, 0x78, 0xae, 0xa5, 0x51, 0xc6, 0x9e, 0x70, 0x3d, 0x86, 0x26, - 0x9b, 0xab, 0x34, 0xb6, 0x48, 0xa4, 0x36, 0x46, 0x6e, 0xa9, 0xca, 0x5b, 0xf0, 0x2e, 0xbc, 0x04, - 0xcb, 0x2e, 0x59, 0xa2, 0xe4, 0x45, 0x10, 0x76, 0x40, 0x54, 0xb2, 0x37, 0xde, 0xf8, 0x7c, 0xe7, - 0x9e, 0x99, 0x33, 0x97, 0x3d,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1d, 0x00, 0x00, 0xff, 0xff, 0x80, 0x93, 0x47, 0x03, 0x61, 0x03, 0x00, 0x00, + // 467 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xdf, 0x6e, 0xd3, 0x30, + 0x14, 0xc6, 0x5b, 0x60, 0x03, 0xcc, 0x1f, 0x59, 0xbe, 0x05, 0xa2, 0x0d, 0x36, 0x36, 0xfe, 0xb5, + 0x48, 0x20, 0x84, 0x00, 0x81, 0xdc, 0xf8, 0x44, 0xb2, 0xea, 0xc4, 0xe5, 0xc4, 0x81, 0xb6, 0x37, + 0x56, 0xd7, 0x44, 0xb4, 0xd2, 0xd6, 0x4c, 0x69, 0x99, 0xb6, 0xb7, 0xe0, 0x5d, 0x78, 0x09, 0x2e, + 0x77, 0xc9, 0x25, 0x6a, 0x5f, 0x04, 0x91, 0x14, 0xc4, 0x24, 0xe7, 0x26, 0x37, 0xf9, 0x7e, 0xdf, + 0xf9, 0xec, 0xcf, 0x87, 0x3c, 0x4f, 0xcf, 0xd2, 0xd3, 0xe3, 0x22, 0x5f, 0xe4, 0xe3, 0xfc, 0xb0, + 0x3d, 0x9d, 0xa5, 0xd9, 0x69, 0x56, 0xb4, 0xe7, 0x93, 0x51, 0x91, 0xa5, 0xed, 0x22, 0x3b, 0xca, + 0x4f, 0x46, 0x87, 0xb6, 0xc8, 0x46, 0xf3, 0x7c, 0xd6, 0x2a, 0x65, 0xec, 0xce, 0xff, 0x44, 0x6b, + 0x4d, 0xb4, 0x2a, 0xe2, 0xf1, 0xf7, 0x0d, 0xc2, 0x74, 0x91, 0x66, 0x05, 0x56, 0x28, 0x96, 0x24, + 0xdb, 0x21, 0x5b, 0x1a, 0x05, 0xa0, 0x45, 0x08, 0xf5, 0x27, 0xae, 0x2c, 0x02, 0x8f, 0x75, 0x64, + 0x93, 0x28, 0xee, 0x81, 0x2f, 0x03, 0x09, 0x82, 0x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0x8d, 0x6d, + 0x4f, 0x71, 0x1f, 0x04, 0xbd, 0xc1, 0x76, 0xc9, 0xb6, 0x3b, 0x77, 0x15, 0x50, 0x96, 0x01, 0x6f, + 0xd6, 0xbe, 0x26, 0xf8, 0x98, 0x48, 0x33, 0xb0, 0x46, 0x02, 0xd2, 0x5b, 0xb5, 0x65, 0x05, 0xf2, + 0x4f, 0xa5, 0x31, 0x18, 0xa3, 0x20, 0x84, 0xc8, 0xd0, 0xdb, 0x9d, 0xfe, 0x8f, 0xa5, 0xd7, 0x3c, + 0x5f, 0x7a, 0xcd, 0x5f, 0x4b, 0xaf, 0xf9, 0x6d, 0xe5, 0x35, 0xce, 0x57, 0x5e, 0xe3, 0xe7, 0xca, + 0x6b, 0x0c, 0xdf, 0x7f, 0x99, 0x2e, 0x26, 0x5f, 0x0f, 0x5a, 0xe3, 0xfc, 0xa8, 0x7d, 0x61, 0x53, + 0x4e, 0x5e, 0x3e, 0x1b, 0x4f, 0x46, 0xd3, 0x59, 0xbb, 0x6e, 0x77, 0x16, 0x67, 0xc7, 0xd9, 0xfc, + 0x60, 0xb3, 0xfc, 0xfd, 0xe2, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x25, 0xb4, 0x79, 0x62, 0x67, + 0x03, 0x00, 0x00, } diff --git a/protocol/mocks/ClobKeeper.go b/protocol/mocks/ClobKeeper.go index 942e3b3182..ba2a9e6f27 100644 --- a/protocol/mocks/ClobKeeper.go +++ b/protocol/mocks/ClobKeeper.go @@ -489,6 +489,11 @@ func (_m *ClobKeeper) InitializeEquityTierLimit(ctx types.Context, config clobty return r0 } +// InitializeNewGrpcStreams provides a mock function with given fields: ctx +func (_m *ClobKeeper) InitializeNewGrpcStreams(ctx types.Context) { + _m.Called(ctx) +} + // IsLiquidatable provides a mock function with given fields: ctx, subaccountId func (_m *ClobKeeper) IsLiquidatable(ctx types.Context, subaccountId subaccountstypes.SubaccountId) (bool, error) { ret := _m.Called(ctx, subaccountId) diff --git a/protocol/mocks/MemClob.go b/protocol/mocks/MemClob.go index fe1c624734..ffd1830df7 100644 --- a/protocol/mocks/MemClob.go +++ b/protocol/mocks/MemClob.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.26.1. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package mocks @@ -25,10 +25,6 @@ func (_m *MemClob) CancelOrder(ctx types.Context, msgCancelOrder *clobtypes.MsgC ret := _m.Called(ctx, msgCancelOrder) var r0 *clobtypes.OffchainUpdates - var r1 error - if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MsgCancelOrder) (*clobtypes.OffchainUpdates, error)); ok { - return rf(ctx, msgCancelOrder) - } if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MsgCancelOrder) *clobtypes.OffchainUpdates); ok { r0 = rf(ctx, msgCancelOrder) } else { @@ -37,6 +33,7 @@ func (_m *MemClob) CancelOrder(ctx types.Context, msgCancelOrder *clobtypes.MsgC } } + var r1 error if rf, ok := ret.Get(1).(func(types.Context, *clobtypes.MsgCancelOrder) error); ok { r1 = rf(ctx, msgCancelOrder) } else { @@ -70,10 +67,6 @@ func (_m *MemClob) DeleverageSubaccount(ctx types.Context, subaccountId subaccou ret := _m.Called(ctx, subaccountId, perpetualId, deltaQuantums, isFinalSettlement) var r0 *big.Int - var r1 error - if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, uint32, *big.Int, bool) (*big.Int, error)); ok { - return rf(ctx, subaccountId, perpetualId, deltaQuantums, isFinalSettlement) - } if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, uint32, *big.Int, bool) *big.Int); ok { r0 = rf(ctx, subaccountId, perpetualId, deltaQuantums, isFinalSettlement) } else { @@ -82,6 +75,7 @@ func (_m *MemClob) DeleverageSubaccount(ctx types.Context, subaccountId subaccou } } + var r1 error if rf, ok := ret.Get(1).(func(types.Context, subaccountstypes.SubaccountId, uint32, *big.Int, bool) error); ok { r1 = rf(ctx, subaccountId, perpetualId, deltaQuantums, isFinalSettlement) } else { @@ -96,16 +90,13 @@ func (_m *MemClob) GetCancelOrder(ctx types.Context, orderId clobtypes.OrderId) ret := _m.Called(ctx, orderId) var r0 uint32 - var r1 bool - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) (uint32, bool)); ok { - return rf(ctx, orderId) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) uint32); ok { r0 = rf(ctx, orderId) } else { r0 = ret.Get(0).(uint32) } + var r1 bool if rf, ok := ret.Get(1).(func(types.Context, clobtypes.OrderId) bool); ok { r1 = rf(ctx, orderId) } else { @@ -120,30 +111,27 @@ func (_m *MemClob) GetMidPrice(ctx types.Context, clobPairId clobtypes.ClobPairI ret := _m.Called(ctx, clobPairId) var r0 clobtypes.Subticks - var r1 clobtypes.Order - var r2 clobtypes.Order - var r3 bool - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPairId) (clobtypes.Subticks, clobtypes.Order, clobtypes.Order, bool)); ok { - return rf(ctx, clobPairId) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPairId) clobtypes.Subticks); ok { r0 = rf(ctx, clobPairId) } else { r0 = ret.Get(0).(clobtypes.Subticks) } + var r1 clobtypes.Order if rf, ok := ret.Get(1).(func(types.Context, clobtypes.ClobPairId) clobtypes.Order); ok { r1 = rf(ctx, clobPairId) } else { r1 = ret.Get(1).(clobtypes.Order) } + var r2 clobtypes.Order if rf, ok := ret.Get(2).(func(types.Context, clobtypes.ClobPairId) clobtypes.Order); ok { r2 = rf(ctx, clobPairId) } else { r2 = ret.Get(2).(clobtypes.Order) } + var r3 bool if rf, ok := ret.Get(3).(func(types.Context, clobtypes.ClobPairId) bool); ok { r3 = rf(ctx, clobPairId) } else { @@ -153,6 +141,22 @@ func (_m *MemClob) GetMidPrice(ctx types.Context, clobPairId clobtypes.ClobPairI return r0, r1, r2, r3 } +// GetOffchainUpdatesForOrderbookSnapshot provides a mock function with given fields: ctx, clobPairId +func (_m *MemClob) GetOffchainUpdatesForOrderbookSnapshot(ctx types.Context, clobPairId clobtypes.ClobPairId) *clobtypes.OffchainUpdates { + ret := _m.Called(ctx, clobPairId) + + var r0 *clobtypes.OffchainUpdates + if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPairId) *clobtypes.OffchainUpdates); ok { + r0 = rf(ctx, clobPairId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*clobtypes.OffchainUpdates) + } + } + + return r0 +} + // GetOperationsRaw provides a mock function with given fields: ctx func (_m *MemClob) GetOperationsRaw(ctx types.Context) []clobtypes.OperationRaw { ret := _m.Called(ctx) @@ -174,10 +178,6 @@ func (_m *MemClob) GetOperationsToReplay(ctx types.Context) ([]clobtypes.Interna ret := _m.Called(ctx) var r0 []clobtypes.InternalOperation - var r1 map[clobtypes.OrderHash][]byte - if rf, ok := ret.Get(0).(func(types.Context) ([]clobtypes.InternalOperation, map[clobtypes.OrderHash][]byte)); ok { - return rf(ctx) - } if rf, ok := ret.Get(0).(func(types.Context) []clobtypes.InternalOperation); ok { r0 = rf(ctx) } else { @@ -186,6 +186,7 @@ func (_m *MemClob) GetOperationsToReplay(ctx types.Context) ([]clobtypes.Interna } } + var r1 map[clobtypes.OrderHash][]byte if rf, ok := ret.Get(1).(func(types.Context) map[clobtypes.OrderHash][]byte); ok { r1 = rf(ctx) } else { @@ -202,16 +203,13 @@ func (_m *MemClob) GetOrder(ctx types.Context, orderId clobtypes.OrderId) (clobt ret := _m.Called(ctx, orderId) var r0 clobtypes.Order - var r1 bool - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) (clobtypes.Order, bool)); ok { - return rf(ctx, orderId) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) clobtypes.Order); ok { r0 = rf(ctx, orderId) } else { r0 = ret.Get(0).(clobtypes.Order) } + var r1 bool if rf, ok := ret.Get(1).(func(types.Context, clobtypes.OrderId) bool); ok { r1 = rf(ctx, orderId) } else { @@ -240,16 +238,13 @@ func (_m *MemClob) GetOrderRemainingAmount(ctx types.Context, order clobtypes.Or ret := _m.Called(ctx, order) var r0 subaccountstypes.BaseQuantums - var r1 bool - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.Order) (subaccountstypes.BaseQuantums, bool)); ok { - return rf(ctx, order) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.Order) subaccountstypes.BaseQuantums); ok { r0 = rf(ctx, order) } else { r0 = ret.Get(0).(subaccountstypes.BaseQuantums) } + var r1 bool if rf, ok := ret.Get(1).(func(types.Context, clobtypes.Order) bool); ok { r1 = rf(ctx, order) } else { @@ -264,16 +259,13 @@ func (_m *MemClob) GetPricePremium(ctx types.Context, clobPair clobtypes.ClobPai ret := _m.Called(ctx, clobPair, params) var r0 int32 - var r1 error - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPair, perpetualstypes.GetPricePremiumParams) (int32, error)); ok { - return rf(ctx, clobPair, params) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPair, perpetualstypes.GetPricePremiumParams) int32); ok { r0 = rf(ctx, clobPair, params) } else { r0 = ret.Get(0).(int32) } + var r1 error if rf, ok := ret.Get(1).(func(types.Context, clobtypes.ClobPair, perpetualstypes.GetPricePremiumParams) error); ok { r1 = rf(ctx, clobPair, params) } else { @@ -288,10 +280,6 @@ func (_m *MemClob) GetSubaccountOrders(ctx types.Context, clobPairId clobtypes.C ret := _m.Called(ctx, clobPairId, subaccountId, side) var r0 []clobtypes.Order - var r1 error - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPairId, subaccountstypes.SubaccountId, clobtypes.Order_Side) ([]clobtypes.Order, error)); ok { - return rf(ctx, clobPairId, subaccountId, side) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPairId, subaccountstypes.SubaccountId, clobtypes.Order_Side) []clobtypes.Order); ok { r0 = rf(ctx, clobPairId, subaccountId, side) } else { @@ -300,6 +288,7 @@ func (_m *MemClob) GetSubaccountOrders(ctx types.Context, clobPairId clobtypes.C } } + var r1 error if rf, ok := ret.Get(1).(func(types.Context, clobtypes.ClobPairId, subaccountstypes.SubaccountId, clobtypes.Order_Side) error); ok { r1 = rf(ctx, clobPairId, subaccountId, side) } else { @@ -314,24 +303,20 @@ func (_m *MemClob) PlaceOrder(ctx types.Context, order clobtypes.Order) (subacco ret := _m.Called(ctx, order) var r0 subaccountstypes.BaseQuantums - var r1 clobtypes.OrderStatus - var r2 *clobtypes.OffchainUpdates - var r3 error - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.Order) (subaccountstypes.BaseQuantums, clobtypes.OrderStatus, *clobtypes.OffchainUpdates, error)); ok { - return rf(ctx, order) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.Order) subaccountstypes.BaseQuantums); ok { r0 = rf(ctx, order) } else { r0 = ret.Get(0).(subaccountstypes.BaseQuantums) } + var r1 clobtypes.OrderStatus if rf, ok := ret.Get(1).(func(types.Context, clobtypes.Order) clobtypes.OrderStatus); ok { r1 = rf(ctx, order) } else { r1 = ret.Get(1).(clobtypes.OrderStatus) } + var r2 *clobtypes.OffchainUpdates if rf, ok := ret.Get(2).(func(types.Context, clobtypes.Order) *clobtypes.OffchainUpdates); ok { r2 = rf(ctx, order) } else { @@ -340,6 +325,7 @@ func (_m *MemClob) PlaceOrder(ctx types.Context, order clobtypes.Order) (subacco } } + var r3 error if rf, ok := ret.Get(3).(func(types.Context, clobtypes.Order) error); ok { r3 = rf(ctx, order) } else { @@ -354,24 +340,20 @@ func (_m *MemClob) PlacePerpetualLiquidation(ctx types.Context, liquidationOrder ret := _m.Called(ctx, liquidationOrder) var r0 subaccountstypes.BaseQuantums - var r1 clobtypes.OrderStatus - var r2 *clobtypes.OffchainUpdates - var r3 error - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.LiquidationOrder) (subaccountstypes.BaseQuantums, clobtypes.OrderStatus, *clobtypes.OffchainUpdates, error)); ok { - return rf(ctx, liquidationOrder) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.LiquidationOrder) subaccountstypes.BaseQuantums); ok { r0 = rf(ctx, liquidationOrder) } else { r0 = ret.Get(0).(subaccountstypes.BaseQuantums) } + var r1 clobtypes.OrderStatus if rf, ok := ret.Get(1).(func(types.Context, clobtypes.LiquidationOrder) clobtypes.OrderStatus); ok { r1 = rf(ctx, liquidationOrder) } else { r1 = ret.Get(1).(clobtypes.OrderStatus) } + var r2 *clobtypes.OffchainUpdates if rf, ok := ret.Get(2).(func(types.Context, clobtypes.LiquidationOrder) *clobtypes.OffchainUpdates); ok { r2 = rf(ctx, liquidationOrder) } else { @@ -380,6 +362,7 @@ func (_m *MemClob) PlacePerpetualLiquidation(ctx types.Context, liquidationOrder } } + var r3 error if rf, ok := ret.Get(3).(func(types.Context, clobtypes.LiquidationOrder) error); ok { r3 = rf(ctx, liquidationOrder) } else { diff --git a/protocol/mocks/MemClobKeeper.go b/protocol/mocks/MemClobKeeper.go index 5139e4b877..32c78c5663 100644 --- a/protocol/mocks/MemClobKeeper.go +++ b/protocol/mocks/MemClobKeeper.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.26.1. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package mocks @@ -29,16 +29,13 @@ func (_m *MemClobKeeper) AddOrderToOrderbookCollatCheck(ctx types.Context, clobP ret := _m.Called(ctx, clobPairId, subaccountOpenOrders) var r0 bool - var r1 map[subaccountstypes.SubaccountId]subaccountstypes.UpdateResult - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPairId, map[subaccountstypes.SubaccountId][]clobtypes.PendingOpenOrder) (bool, map[subaccountstypes.SubaccountId]subaccountstypes.UpdateResult)); ok { - return rf(ctx, clobPairId, subaccountOpenOrders) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPairId, map[subaccountstypes.SubaccountId][]clobtypes.PendingOpenOrder) bool); ok { r0 = rf(ctx, clobPairId, subaccountOpenOrders) } else { r0 = ret.Get(0).(bool) } + var r1 map[subaccountstypes.SubaccountId]subaccountstypes.UpdateResult if rf, ok := ret.Get(1).(func(types.Context, clobtypes.ClobPairId, map[subaccountstypes.SubaccountId][]clobtypes.PendingOpenOrder) map[subaccountstypes.SubaccountId]subaccountstypes.UpdateResult); ok { r1 = rf(ctx, clobPairId, subaccountOpenOrders) } else { @@ -55,24 +52,20 @@ func (_m *MemClobKeeper) AddPreexistingStatefulOrder(ctx types.Context, order *c ret := _m.Called(ctx, order, memclob) var r0 subaccountstypes.BaseQuantums - var r1 clobtypes.OrderStatus - var r2 *clobtypes.OffchainUpdates - var r3 error - if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.Order, clobtypes.MemClob) (subaccountstypes.BaseQuantums, clobtypes.OrderStatus, *clobtypes.OffchainUpdates, error)); ok { - return rf(ctx, order, memclob) - } if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.Order, clobtypes.MemClob) subaccountstypes.BaseQuantums); ok { r0 = rf(ctx, order, memclob) } else { r0 = ret.Get(0).(subaccountstypes.BaseQuantums) } + var r1 clobtypes.OrderStatus if rf, ok := ret.Get(1).(func(types.Context, *clobtypes.Order, clobtypes.MemClob) clobtypes.OrderStatus); ok { r1 = rf(ctx, order, memclob) } else { r1 = ret.Get(1).(clobtypes.OrderStatus) } + var r2 *clobtypes.OffchainUpdates if rf, ok := ret.Get(2).(func(types.Context, *clobtypes.Order, clobtypes.MemClob) *clobtypes.OffchainUpdates); ok { r2 = rf(ctx, order, memclob) } else { @@ -81,6 +74,7 @@ func (_m *MemClobKeeper) AddPreexistingStatefulOrder(ctx types.Context, order *c } } + var r3 error if rf, ok := ret.Get(3).(func(types.Context, *clobtypes.Order, clobtypes.MemClob) error); ok { r3 = rf(ctx, order, memclob) } else { @@ -95,23 +89,20 @@ func (_m *MemClobKeeper) CanDeleverageSubaccount(ctx types.Context, subaccountId ret := _m.Called(ctx, subaccountId, perpetualId) var r0 bool - var r1 bool - var r2 error - if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, uint32) (bool, bool, error)); ok { - return rf(ctx, subaccountId, perpetualId) - } if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, uint32) bool); ok { r0 = rf(ctx, subaccountId, perpetualId) } else { r0 = ret.Get(0).(bool) } + var r1 bool if rf, ok := ret.Get(1).(func(types.Context, subaccountstypes.SubaccountId, uint32) bool); ok { r1 = rf(ctx, subaccountId, perpetualId) } else { r1 = ret.Get(1).(bool) } + var r2 error if rf, ok := ret.Get(2).(func(types.Context, subaccountstypes.SubaccountId, uint32) error); ok { r2 = rf(ctx, subaccountId, perpetualId) } else { @@ -156,16 +147,13 @@ func (_m *MemClobKeeper) GetLongTermOrderPlacement(ctx types.Context, orderId cl ret := _m.Called(ctx, orderId) var r0 clobtypes.LongTermOrderPlacement - var r1 bool - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) (clobtypes.LongTermOrderPlacement, bool)); ok { - return rf(ctx, orderId) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) clobtypes.LongTermOrderPlacement); ok { r0 = rf(ctx, orderId) } else { r0 = ret.Get(0).(clobtypes.LongTermOrderPlacement) } + var r1 bool if rf, ok := ret.Get(1).(func(types.Context, clobtypes.OrderId) bool); ok { r1 = rf(ctx, orderId) } else { @@ -180,23 +168,20 @@ func (_m *MemClobKeeper) GetOrderFillAmount(ctx types.Context, orderId clobtypes ret := _m.Called(ctx, orderId) var r0 bool - var r1 subaccountstypes.BaseQuantums - var r2 uint32 - if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) (bool, subaccountstypes.BaseQuantums, uint32)); ok { - return rf(ctx, orderId) - } if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) bool); ok { r0 = rf(ctx, orderId) } else { r0 = ret.Get(0).(bool) } + var r1 subaccountstypes.BaseQuantums if rf, ok := ret.Get(1).(func(types.Context, clobtypes.OrderId) subaccountstypes.BaseQuantums); ok { r1 = rf(ctx, orderId) } else { r1 = ret.Get(1).(subaccountstypes.BaseQuantums) } + var r2 uint32 if rf, ok := ret.Get(2).(func(types.Context, clobtypes.OrderId) uint32); ok { r2 = rf(ctx, orderId) } else { @@ -227,16 +212,13 @@ func (_m *MemClobKeeper) IsLiquidatable(ctx types.Context, subaccountId subaccou ret := _m.Called(ctx, subaccountId) var r0 bool - var r1 error - if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId) (bool, error)); ok { - return rf(ctx, subaccountId) - } if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId) bool); ok { r0 = rf(ctx, subaccountId) } else { r0 = ret.Get(0).(bool) } + var r1 error if rf, ok := ret.Get(1).(func(types.Context, subaccountstypes.SubaccountId) error); ok { r1 = rf(ctx, subaccountId) } else { @@ -272,10 +254,6 @@ func (_m *MemClobKeeper) OffsetSubaccountPerpetualPosition(ctx types.Context, li ret := _m.Called(ctx, liquidatedSubaccountId, perpetualId, deltaQuantumsTotal, isFinalSettlement) var r0 []clobtypes.MatchPerpetualDeleveraging_Fill - var r1 *big.Int - if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, uint32, *big.Int, bool) ([]clobtypes.MatchPerpetualDeleveraging_Fill, *big.Int)); ok { - return rf(ctx, liquidatedSubaccountId, perpetualId, deltaQuantumsTotal, isFinalSettlement) - } if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, uint32, *big.Int, bool) []clobtypes.MatchPerpetualDeleveraging_Fill); ok { r0 = rf(ctx, liquidatedSubaccountId, perpetualId, deltaQuantumsTotal, isFinalSettlement) } else { @@ -284,6 +262,7 @@ func (_m *MemClobKeeper) OffsetSubaccountPerpetualPosition(ctx types.Context, li } } + var r1 *big.Int if rf, ok := ret.Get(1).(func(types.Context, subaccountstypes.SubaccountId, uint32, *big.Int, bool) *big.Int); ok { r1 = rf(ctx, liquidatedSubaccountId, perpetualId, deltaQuantumsTotal, isFinalSettlement) } else { @@ -300,31 +279,27 @@ func (_m *MemClobKeeper) ProcessSingleMatch(ctx types.Context, matchWithOrders * ret := _m.Called(ctx, matchWithOrders) var r0 bool - var r1 subaccountstypes.UpdateResult - var r2 subaccountstypes.UpdateResult - var r3 *clobtypes.OffchainUpdates - var r4 error - if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MatchWithOrders) (bool, subaccountstypes.UpdateResult, subaccountstypes.UpdateResult, *clobtypes.OffchainUpdates, error)); ok { - return rf(ctx, matchWithOrders) - } if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MatchWithOrders) bool); ok { r0 = rf(ctx, matchWithOrders) } else { r0 = ret.Get(0).(bool) } + var r1 subaccountstypes.UpdateResult if rf, ok := ret.Get(1).(func(types.Context, *clobtypes.MatchWithOrders) subaccountstypes.UpdateResult); ok { r1 = rf(ctx, matchWithOrders) } else { r1 = ret.Get(1).(subaccountstypes.UpdateResult) } + var r2 subaccountstypes.UpdateResult if rf, ok := ret.Get(2).(func(types.Context, *clobtypes.MatchWithOrders) subaccountstypes.UpdateResult); ok { r2 = rf(ctx, matchWithOrders) } else { r2 = ret.Get(2).(subaccountstypes.UpdateResult) } + var r3 *clobtypes.OffchainUpdates if rf, ok := ret.Get(3).(func(types.Context, *clobtypes.MatchWithOrders) *clobtypes.OffchainUpdates); ok { r3 = rf(ctx, matchWithOrders) } else { @@ -333,6 +308,7 @@ func (_m *MemClobKeeper) ProcessSingleMatch(ctx types.Context, matchWithOrders * } } + var r4 error if rf, ok := ret.Get(4).(func(types.Context, *clobtypes.MatchWithOrders) error); ok { r4 = rf(ctx, matchWithOrders) } else { @@ -347,24 +323,20 @@ func (_m *MemClobKeeper) ReplayPlaceOrder(ctx types.Context, msg *clobtypes.MsgP ret := _m.Called(ctx, msg) var r0 subaccountstypes.BaseQuantums - var r1 clobtypes.OrderStatus - var r2 *clobtypes.OffchainUpdates - var r3 error - if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MsgPlaceOrder) (subaccountstypes.BaseQuantums, clobtypes.OrderStatus, *clobtypes.OffchainUpdates, error)); ok { - return rf(ctx, msg) - } if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MsgPlaceOrder) subaccountstypes.BaseQuantums); ok { r0 = rf(ctx, msg) } else { r0 = ret.Get(0).(subaccountstypes.BaseQuantums) } + var r1 clobtypes.OrderStatus if rf, ok := ret.Get(1).(func(types.Context, *clobtypes.MsgPlaceOrder) clobtypes.OrderStatus); ok { r1 = rf(ctx, msg) } else { r1 = ret.Get(1).(clobtypes.OrderStatus) } + var r2 *clobtypes.OffchainUpdates if rf, ok := ret.Get(2).(func(types.Context, *clobtypes.MsgPlaceOrder) *clobtypes.OffchainUpdates); ok { r2 = rf(ctx, msg) } else { @@ -373,6 +345,7 @@ func (_m *MemClobKeeper) ReplayPlaceOrder(ctx types.Context, msg *clobtypes.MsgP } } + var r3 error if rf, ok := ret.Get(3).(func(types.Context, *clobtypes.MsgPlaceOrder) error); ok { r3 = rf(ctx, msg) } else { diff --git a/protocol/mocks/QueryClient.go b/protocol/mocks/QueryClient.go index 995b2ea62c..6c3f3d18c6 100644 --- a/protocol/mocks/QueryClient.go +++ b/protocol/mocks/QueryClient.go @@ -660,6 +660,36 @@ func (_m *QueryClient) PreviousBlockInfo(ctx context.Context, in *types.QueryPre return r0, r1 } +// StreamOrderbookUpdates provides a mock function with given fields: ctx, in, opts +func (_m *QueryClient) StreamOrderbookUpdates(ctx context.Context, in *clobtypes.StreamOrderbookUpdatesRequest, opts ...grpc.CallOption) (clobtypes.Query_StreamOrderbookUpdatesClient, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 clobtypes.Query_StreamOrderbookUpdatesClient + if rf, ok := ret.Get(0).(func(context.Context, *clobtypes.StreamOrderbookUpdatesRequest, ...grpc.CallOption) clobtypes.Query_StreamOrderbookUpdatesClient); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(clobtypes.Query_StreamOrderbookUpdatesClient) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *clobtypes.StreamOrderbookUpdatesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // Subaccount provides a mock function with given fields: ctx, in, opts func (_m *QueryClient) Subaccount(ctx context.Context, in *subaccountstypes.QueryGetSubaccountRequest, opts ...grpc.CallOption) (*subaccountstypes.QuerySubaccountResponse, error) { _va := make([]interface{}, len(opts)) diff --git a/protocol/streaming/grpc/grpc_streaming_manager.go b/protocol/streaming/grpc/grpc_streaming_manager.go new file mode 100644 index 0000000000..95ae0a984e --- /dev/null +++ b/protocol/streaming/grpc/grpc_streaming_manager.go @@ -0,0 +1,159 @@ +package grpc + +import ( + "sync" + + "github.com/cosmos/gogoproto/proto" + ocutypes "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates/types" + "github.com/dydxprotocol/v4-chain/protocol/lib" + "github.com/dydxprotocol/v4-chain/protocol/streaming/grpc/types" + clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" +) + +var _ types.GrpcStreamingManager = (*GrpcStreamingManagerImpl)(nil) + +// GrpcStreamingManagerImpl is an implementation for managing gRPC streaming subscriptions. +type GrpcStreamingManagerImpl struct { + sync.Mutex + + // orderbookSubscriptions maps subscription IDs to their respective orderbook subscriptions. + orderbookSubscriptions map[uint32]*OrderbookSubscription + nextSubscriptionId uint32 +} + +// OrderbookSubscription represents a active subscription to the orderbook updates stream. +type OrderbookSubscription struct { + // Initialize the subscription with orderbook snapshots. + initialize sync.Once + + // Clob pair ids to subscribe to. + clobPairIds []uint32 + + // Stream + srv clobtypes.Query_StreamOrderbookUpdatesServer +} + +func NewGrpcStreamingManager() *GrpcStreamingManagerImpl { + return &GrpcStreamingManagerImpl{ + orderbookSubscriptions: make(map[uint32]*OrderbookSubscription), + } +} + +func (sm *GrpcStreamingManagerImpl) Enabled() bool { + return true +} + +// Subscribe subscribes to the orderbook updates stream. +func (sm *GrpcStreamingManagerImpl) Subscribe( + req clobtypes.StreamOrderbookUpdatesRequest, + srv clobtypes.Query_StreamOrderbookUpdatesServer, +) ( + err error, +) { + clobPairIds := req.GetClobPairId() + + // Perform some basic validation on the request. + if len(clobPairIds) == 0 { + return clobtypes.ErrInvalidGrpcStreamingRequest + } + + subscription := &OrderbookSubscription{ + clobPairIds: clobPairIds, + srv: srv, + } + + sm.Lock() + defer sm.Unlock() + + sm.orderbookSubscriptions[sm.nextSubscriptionId] = subscription + sm.nextSubscriptionId++ + + return nil +} + +// SendOrderbookUpdates groups updates by their clob pair ids and +// sends messages to the subscribers. +func (sm *GrpcStreamingManagerImpl) SendOrderbookUpdates( + offchainUpdates *clobtypes.OffchainUpdates, + snapshot bool, +) { + // Group updates by clob pair id. + updates := make(map[uint32]*clobtypes.OffchainUpdates) + for _, message := range offchainUpdates.Messages { + clobPairId := message.OrderId.ClobPairId + if _, ok := updates[clobPairId]; !ok { + updates[clobPairId] = clobtypes.NewOffchainUpdates() + } + updates[clobPairId].Messages = append(updates[clobPairId].Messages, message) + } + + // Unmarshal messages to v1 updates. + v1updates := make(map[uint32][]ocutypes.OffChainUpdateV1) + for clobPairId, update := range updates { + v1update, err := GetOffchainUpdatesV1(update) + if err != nil { + panic(err) + } + v1updates[clobPairId] = v1update + } + + sm.Lock() + defer sm.Unlock() + + // Send updates to subscribers. + idsToRemove := make([]uint32, 0) + for id, subscription := range sm.orderbookSubscriptions { + for _, clobPairId := range subscription.clobPairIds { + if updates, ok := v1updates[clobPairId]; ok { + if err := subscription.srv.Send( + &clobtypes.StreamOrderbookUpdatesResponse{ + Updates: updates, + Snapshot: snapshot, + }, + ); err != nil { + idsToRemove = append(idsToRemove, id) + break + } + } + } + } + + // Clean up subscriptions that have been closed. + // If a Send update has failed for any clob pair id, the whole subscription will be removed. + for _, id := range idsToRemove { + delete(sm.orderbookSubscriptions, id) + } +} + +// GetUninitializedClobPairIds returns the clob pair ids that have not been initialized. +func (sm *GrpcStreamingManagerImpl) GetUninitializedClobPairIds() []uint32 { + sm.Lock() + defer sm.Unlock() + + clobPairIds := make(map[uint32]bool) + for _, subscription := range sm.orderbookSubscriptions { + subscription.initialize.Do( + func() { + for _, clobPairId := range subscription.clobPairIds { + clobPairIds[clobPairId] = true + } + }, + ) + } + + return lib.GetSortedKeys[lib.Sortable[uint32]](clobPairIds) +} + +// GetOffchainUpdatesV1 unmarshals messages in offchain updates to OffchainUpdateV1. +func GetOffchainUpdatesV1(offchainUpdates *clobtypes.OffchainUpdates) ([]ocutypes.OffChainUpdateV1, error) { + v1updates := make([]ocutypes.OffChainUpdateV1, 0) + for _, message := range offchainUpdates.Messages { + var update ocutypes.OffChainUpdateV1 + err := proto.Unmarshal(message.Message.Value, &update) + if err != nil { + return nil, err + } + v1updates = append(v1updates, update) + } + return v1updates, nil +} diff --git a/protocol/streaming/grpc/noop_streaming_manager.go b/protocol/streaming/grpc/noop_streaming_manager.go new file mode 100644 index 0000000000..f8cc229772 --- /dev/null +++ b/protocol/streaming/grpc/noop_streaming_manager.go @@ -0,0 +1,37 @@ +package grpc + +import ( + "github.com/dydxprotocol/v4-chain/protocol/streaming/grpc/types" + clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" +) + +var _ types.GrpcStreamingManager = (*NoopGrpcStreamingManager)(nil) + +type NoopGrpcStreamingManager struct{} + +func NewNoopGrpcStreamingManager() *NoopGrpcStreamingManager { + return &NoopGrpcStreamingManager{} +} + +func (sm *NoopGrpcStreamingManager) Enabled() bool { + return false +} + +func (sm *NoopGrpcStreamingManager) Subscribe( + req clobtypes.StreamOrderbookUpdatesRequest, + srv clobtypes.Query_StreamOrderbookUpdatesServer, +) ( + err error, +) { + return clobtypes.ErrGrpcStreamingManagerNotEnabled +} + +func (sm *NoopGrpcStreamingManager) SendOrderbookUpdates( + updates *clobtypes.OffchainUpdates, + snapshot bool, +) { +} + +func (sm *NoopGrpcStreamingManager) GetUninitializedClobPairIds() []uint32 { + return []uint32{} +} diff --git a/protocol/streaming/grpc/types/manager.go b/protocol/streaming/grpc/types/manager.go new file mode 100644 index 0000000000..0027358e79 --- /dev/null +++ b/protocol/streaming/grpc/types/manager.go @@ -0,0 +1,22 @@ +package types + +import ( + clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" +) + +type GrpcStreamingManager interface { + Enabled() bool + + // L3+ Orderbook updates. + Subscribe( + req clobtypes.StreamOrderbookUpdatesRequest, + srv clobtypes.Query_StreamOrderbookUpdatesServer, + ) ( + err error, + ) + GetUninitializedClobPairIds() []uint32 + SendOrderbookUpdates( + offchainUpdates *clobtypes.OffchainUpdates, + snapshot bool, + ) +} diff --git a/protocol/testutil/keeper/clob.go b/protocol/testutil/keeper/clob.go index b6aed9ce9c..ed32bd120c 100644 --- a/protocol/testutil/keeper/clob.go +++ b/protocol/testutil/keeper/clob.go @@ -3,20 +3,6 @@ package keeper import ( "testing" - "github.com/dydxprotocol/v4-chain/protocol/lib" - - indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" - "github.com/dydxprotocol/v4-chain/protocol/mocks" - clobtest "github.com/dydxprotocol/v4-chain/protocol/testutil/clob" - delaymsgmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/delaymsg/types" - "github.com/stretchr/testify/require" - - "github.com/dydxprotocol/v4-chain/protocol/x/clob/flags" - "github.com/dydxprotocol/v4-chain/protocol/x/clob/rate_limit" - - "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" - "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" - db "github.com/cometbft/cometbft-db" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -24,10 +10,20 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" liquidationtypes "github.com/dydxprotocol/v4-chain/protocol/daemons/server/types/liquidations" + indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" + "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" + "github.com/dydxprotocol/v4-chain/protocol/lib" + "github.com/dydxprotocol/v4-chain/protocol/mocks" + streaming "github.com/dydxprotocol/v4-chain/protocol/streaming/grpc" + clobtest "github.com/dydxprotocol/v4-chain/protocol/testutil/clob" + "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" asskeeper "github.com/dydxprotocol/v4-chain/protocol/x/assets/keeper" blocktimekeeper "github.com/dydxprotocol/v4-chain/protocol/x/blocktime/keeper" + "github.com/dydxprotocol/v4-chain/protocol/x/clob/flags" "github.com/dydxprotocol/v4-chain/protocol/x/clob/keeper" + "github.com/dydxprotocol/v4-chain/protocol/x/clob/rate_limit" "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" + delaymsgmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/delaymsg/types" feetierskeeper "github.com/dydxprotocol/v4-chain/protocol/x/feetiers/keeper" perpkeeper "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/keeper" priceskeeper "github.com/dydxprotocol/v4-chain/protocol/x/prices/keeper" @@ -35,6 +31,7 @@ import ( statskeeper "github.com/dydxprotocol/v4-chain/protocol/x/stats/keeper" subkeeper "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/keeper" satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" + "github.com/stretchr/testify/require" ) type ClobKeepersTestContext struct { @@ -214,6 +211,7 @@ func createClobKeeper( statsKeeper, rewardsKeeper, indexerEventManager, + streaming.NewNoopGrpcStreamingManager(), constants.TestEncodingCfg.TxConfig.TxDecoder(), flags.GetDefaultClobFlags(), rate_limit.NewNoOpRateLimiter[*types.MsgPlaceOrder](), diff --git a/protocol/testutil/memclob/offchain_updates.go b/protocol/testutil/memclob/offchain_updates.go index 22fbc6b7e6..7b32e76ba8 100644 --- a/protocol/testutil/memclob/offchain_updates.go +++ b/protocol/testutil/memclob/offchain_updates.go @@ -6,7 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dydxprotocol/v4-chain/protocol/indexer/msgsender" "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates" - indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + ocutypes "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates/types" + indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" "github.com/stretchr/testify/require" "gopkg.in/typ.v4/slices" @@ -28,7 +29,7 @@ func RequireCancelOrderMessage(t *testing.T, ctx sdk.Context, message *msgsender ctx.Logger(), orderId, indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_USER_CANCELED, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ) require.Equal(t, *message, expectedMessage) } diff --git a/protocol/x/clob/abci.go b/protocol/x/clob/abci.go index b65caa1899..5c2a5a7ce3 100644 --- a/protocol/x/clob/abci.go +++ b/protocol/x/clob/abci.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" - indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/lib" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" "github.com/dydxprotocol/v4-chain/protocol/x/clob/keeper" @@ -226,6 +226,9 @@ func PrepareCheckState( ctx.BlockHeight(), ) + // Initialize new GRPC streams with orderbook snapshots, if any. + keeper.InitializeNewGrpcStreams(ctx) + // Set per-orderbook gauges. keeper.MemClob.SetMemclobGauges(ctx) } diff --git a/protocol/x/clob/abci_test.go b/protocol/x/clob/abci_test.go index 8f962a1ee5..e05ccd7076 100644 --- a/protocol/x/clob/abci_test.go +++ b/protocol/x/clob/abci_test.go @@ -14,7 +14,7 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/daemons/liquidation/api" indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" - indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" testapp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" clobtest "github.com/dydxprotocol/v4-chain/protocol/testutil/clob" prices "github.com/dydxprotocol/v4-chain/protocol/x/prices/types" diff --git a/protocol/x/clob/keeper/clob_pair_test.go b/protocol/x/clob/keeper/clob_pair_test.go index 3005f4346f..f5164ca09b 100644 --- a/protocol/x/clob/keeper/clob_pair_test.go +++ b/protocol/x/clob/keeper/clob_pair_test.go @@ -7,7 +7,7 @@ import ( indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" - indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/lib" "github.com/cosmos/cosmos-sdk/codec" diff --git a/protocol/x/clob/keeper/final_settlement.go b/protocol/x/clob/keeper/final_settlement.go index 4e1468ff73..7246cc0d2f 100644 --- a/protocol/x/clob/keeper/final_settlement.go +++ b/protocol/x/clob/keeper/final_settlement.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" - indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" ) diff --git a/protocol/x/clob/keeper/grpc_stream_orderbook.go b/protocol/x/clob/keeper/grpc_stream_orderbook.go new file mode 100644 index 0000000000..710a6ceec6 --- /dev/null +++ b/protocol/x/clob/keeper/grpc_stream_orderbook.go @@ -0,0 +1,20 @@ +package keeper + +import ( + "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" +) + +func (k Keeper) StreamOrderbookUpdates( + req *types.StreamOrderbookUpdatesRequest, + stream types.Query_StreamOrderbookUpdatesServer, +) error { + err := k.GetGrpcStreamingManager().Subscribe(*req, stream) + if err != nil { + return err + } + + // Keep this scope alive because once this scope exits - the stream is closed + ctx := stream.Context() + <-ctx.Done() + return nil +} diff --git a/protocol/x/clob/keeper/keeper.go b/protocol/x/clob/keeper/keeper.go index ac4f3e959b..bb02c92867 100644 --- a/protocol/x/clob/keeper/keeper.go +++ b/protocol/x/clob/keeper/keeper.go @@ -8,6 +8,7 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" "github.com/dydxprotocol/v4-chain/protocol/lib" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" + streamingtypes "github.com/dydxprotocol/v4-chain/protocol/streaming/grpc/types" "github.com/dydxprotocol/v4-chain/protocol/x/clob/rate_limit" "github.com/cometbft/cometbft/libs/log" @@ -43,6 +44,7 @@ type ( statsKeeper types.StatsKeeper rewardsKeeper types.RewardsKeeper indexerEventManager indexer_manager.IndexerEventManager + streamingManager streamingtypes.GrpcStreamingManager memStoreInitialized *atomic.Bool @@ -83,6 +85,7 @@ func NewKeeper( statsKeeper types.StatsKeeper, rewardsKeeper types.RewardsKeeper, indexerEventManager indexer_manager.IndexerEventManager, + grpcStreamingManager streamingtypes.GrpcStreamingManager, txDecoder sdk.TxDecoder, clobFlags flags.ClobFlags, placeOrderRateLimiter rate_limit.RateLimiter[*types.MsgPlaceOrder], @@ -107,6 +110,7 @@ func NewKeeper( statsKeeper: statsKeeper, rewardsKeeper: rewardsKeeper, indexerEventManager: indexerEventManager, + streamingManager: grpcStreamingManager, memStoreInitialized: &atomic.Bool{}, txDecoder: txDecoder, mevTelemetryConfig: MevTelemetryConfig{ @@ -136,6 +140,10 @@ func (k Keeper) GetIndexerEventManager() indexer_manager.IndexerEventManager { return k.indexerEventManager } +func (k Keeper) GetGrpcStreamingManager() streamingtypes.GrpcStreamingManager { + return k.streamingManager +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With( sdklog.ModuleKey, "x/clob", @@ -210,3 +218,22 @@ func (k Keeper) InitMemStore(ctx sdk.Context) { func (k *Keeper) SetAnteHandler(anteHandler sdk.AnteHandler) { k.antehandler = anteHandler } + +// InitializeNewGrpcStreams initializes new gRPC streams for all uninitialized clob pairs +// by sending the corresponding orderbook snapshots. +func (k Keeper) InitializeNewGrpcStreams(ctx sdk.Context) { + streamingManager := k.GetGrpcStreamingManager() + allUpdates := types.NewOffchainUpdates() + + uninitializedClobPairIds := streamingManager.GetUninitializedClobPairIds() + for _, clobPairId := range uninitializedClobPairIds { + update := k.MemClob.GetOffchainUpdatesForOrderbookSnapshot( + ctx, + types.ClobPairId(clobPairId), + ) + + allUpdates.Append(update) + } + + streamingManager.SendOrderbookUpdates(allUpdates, true) +} diff --git a/protocol/x/clob/keeper/msg_server_cancel_orders.go b/protocol/x/clob/keeper/msg_server_cancel_orders.go index 0e98d57884..abb9e3a932 100644 --- a/protocol/x/clob/keeper/msg_server_cancel_orders.go +++ b/protocol/x/clob/keeper/msg_server_cancel_orders.go @@ -10,7 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" - indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/lib" errorlib "github.com/dydxprotocol/v4-chain/protocol/lib/error" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" diff --git a/protocol/x/clob/keeper/msg_server_cancel_orders_test.go b/protocol/x/clob/keeper/msg_server_cancel_orders_test.go index dbfa6e7f77..8343929b15 100644 --- a/protocol/x/clob/keeper/msg_server_cancel_orders_test.go +++ b/protocol/x/clob/keeper/msg_server_cancel_orders_test.go @@ -9,7 +9,7 @@ import ( indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" - indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/lib" "github.com/dydxprotocol/v4-chain/protocol/mocks" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" diff --git a/protocol/x/clob/keeper/orders.go b/protocol/x/clob/keeper/orders.go index df9c243e0f..0ae4ab9cd4 100644 --- a/protocol/x/clob/keeper/orders.go +++ b/protocol/x/clob/keeper/orders.go @@ -14,7 +14,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dydxprotocol/v4-chain/protocol/indexer/msgsender" "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates" - indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + ocutypes "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates/types" + indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/lib" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" @@ -485,7 +486,7 @@ func (k Keeper) PlaceStatefulOrdersFromLastBlock( order.OrderId, orderStatus, err, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_INTERNAL_ERROR, ); success { existingOffchainUpdates.AddRemoveMessage(order.OrderId, message) @@ -1269,6 +1270,8 @@ func (k Keeper) SendOffchainMessages( } k.GetIndexerEventManager().SendOffchainData(update) } + + k.GetGrpcStreamingManager().SendOrderbookUpdates(offchainUpdates, false) } // getPessimisticCollateralCheckPrice returns the price in subticks we should use for collateralization checks. diff --git a/protocol/x/clob/memclob/memclob.go b/protocol/x/clob/memclob/memclob.go index e68f156e00..f02fba7f74 100644 --- a/protocol/x/clob/memclob/memclob.go +++ b/protocol/x/clob/memclob/memclob.go @@ -14,7 +14,9 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates" + ocutypes "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates/types" indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + indexersharedtypes "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/lib" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" @@ -125,8 +127,8 @@ func (m *MemClobPriceTimePriority) CancelOrder( if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( m.clobKeeper.Logger(ctx), orderIdToCancel, - indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_USER_CANCELED, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + indexersharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_USER_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ); success { offchainUpdates.AddRemoveMessage(orderIdToCancel, message) } @@ -447,8 +449,8 @@ func (m *MemClobPriceTimePriority) PlaceOrder( if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( m.clobKeeper.Logger(ctx), orderId, - indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_REPLACED, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + indexersharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_REPLACED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ); success { offchainUpdates.AddRemoveMessage(orderId, message) } @@ -499,7 +501,7 @@ func (m *MemClobPriceTimePriority) PlaceOrder( order.OrderId, takerOrderStatus.OrderStatus, err, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ); success { offchainUpdates.AddRemoveMessage(order.OrderId, message) } @@ -521,7 +523,7 @@ func (m *MemClobPriceTimePriority) PlaceOrder( order.OrderId, takerOrderStatus.OrderStatus, nil, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ); success { offchainUpdates.AddRemoveMessage(order.OrderId, message) } @@ -568,7 +570,7 @@ func (m *MemClobPriceTimePriority) PlaceOrder( order.OrderId, orderStatus, nil, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ); success { offchainUpdates.AddRemoveMessage(order.OrderId, message) } @@ -603,7 +605,7 @@ func (m *MemClobPriceTimePriority) PlaceOrder( order.OrderId, addOrderOrderStatus, nil, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ); success { offchainUpdates.AddRemoveMessage(order.OrderId, message) } @@ -775,7 +777,7 @@ func (m *MemClobPriceTimePriority) matchOrder( branchedContext.Logger(), makerOrderId, reason, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ); success { offchainUpdates.AddRemoveMessage(makerOrderId, message) } @@ -1090,8 +1092,8 @@ func (m *MemClobPriceTimePriority) GenerateOffchainUpdatesForReplayPlaceOrder( orderId, orderStatus, err, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, - indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_INTERNAL_ERROR, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + indexersharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_INTERNAL_ERROR, ); success { existingOffchainUpdates.AddRemoveMessage(orderId, message) } @@ -1240,8 +1242,8 @@ func (m *MemClobPriceTimePriority) PurgeInvalidMemclobState( if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( m.clobKeeper.Logger(ctx), statefulOrderId, - indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_EXPIRED, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_CANCELED, + indexersharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_EXPIRED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_CANCELED, ); success { existingOffchainUpdates.AddRemoveMessage(statefulOrderId, message) } @@ -1259,8 +1261,8 @@ func (m *MemClobPriceTimePriority) PurgeInvalidMemclobState( if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( m.clobKeeper.Logger(ctx), shortTermOrderId, - indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_EXPIRED, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_CANCELED, + indexersharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_EXPIRED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_CANCELED, ); success { existingOffchainUpdates.AddRemoveMessage(shortTermOrderId, message) } @@ -2072,8 +2074,8 @@ func (m *MemClobPriceTimePriority) maybeCancelReduceOnlyOrders( if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( m.clobKeeper.Logger(ctx), orderId, - indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + indexersharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ); success { offchainUpdates.AddRemoveMessage(orderId, message) } diff --git a/protocol/x/clob/memclob/memclob_grpc_streaming.go b/protocol/x/clob/memclob/memclob_grpc_streaming.go new file mode 100644 index 0000000000..6cc8844bc5 --- /dev/null +++ b/protocol/x/clob/memclob/memclob_grpc_streaming.go @@ -0,0 +1,88 @@ +package memclob + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates" + "github.com/dydxprotocol/v4-chain/protocol/lib" + "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" +) + +// GetOffchainUpdatesForOrderbookSnapshot returns the offchain updates for the orderbook snapshot. +// This is used by the gRPC streaming server to send the orderbook snapshot to the client. +func (m *MemClobPriceTimePriority) GetOffchainUpdatesForOrderbookSnapshot( + ctx sdk.Context, + clobPairId types.ClobPairId, +) (offchainUpdates *types.OffchainUpdates) { + offchainUpdates = types.NewOffchainUpdates() + + if orderbook, exists := m.openOrders.orderbooksMap[clobPairId]; exists { + // Generate the offchain updates for buy orders. + // Updates are sorted in descending order of price. + buyPriceLevels := lib.GetSortedKeys[lib.Sortable[types.Subticks]](orderbook.Bids) + for i := len(buyPriceLevels) - 1; i >= 0; i-- { + subticks := buyPriceLevels[i] + level := orderbook.Bids[subticks] + + // For each price level, generate offchain updates for each order in the level. + level.LevelOrders.Front.Each( + func(order types.ClobOrder) { + offchainUpdates.Append( + m.GetOffchainUpdatesForOrder(ctx, order.Order), + ) + }, + ) + } + + // Generate the offchain updates for sell orders. + // Updates are sorted in ascending order of price. + sellPriceLevels := lib.GetSortedKeys[lib.Sortable[types.Subticks]](orderbook.Asks) + for i := 0; i < len(sellPriceLevels); i++ { + subticks := sellPriceLevels[i] + level := orderbook.Asks[subticks] + + // For each price level, generate offchain updates for each order in the level. + level.LevelOrders.Front.Each( + func(order types.ClobOrder) { + offchainUpdates.Append( + m.GetOffchainUpdatesForOrder(ctx, order.Order), + ) + }, + ) + } + } + + return offchainUpdates +} + +// GetOffchainUpdatesForOrder returns a place order offchain message and +// a update order offchain message used to construct an order for +// the orderbook snapshot grpc stream. +func (m *MemClobPriceTimePriority) GetOffchainUpdatesForOrder( + ctx sdk.Context, + order types.Order, +) (offchainUpdates *types.OffchainUpdates) { + offchainUpdates = types.NewOffchainUpdates() + orderId := order.OrderId + + // Generate a order place message. + if message, success := off_chain_updates.CreateOrderPlaceMessage( + m.clobKeeper.Logger(ctx), + order, + ); success { + offchainUpdates.AddPlaceMessage(orderId, message) + } + + // Get the current fill amount of the order. + fillAmount := m.GetOrderFilledAmount(ctx, orderId) + + // Generate an update message updating the total filled amount of order. + if message, success := off_chain_updates.CreateOrderUpdateMessage( + m.clobKeeper.Logger(ctx), + orderId, + fillAmount, + ); success { + offchainUpdates.AddUpdateMessage(orderId, message) + } + + return offchainUpdates +} diff --git a/protocol/x/clob/memclob/memclob_grpc_streaming_test.go b/protocol/x/clob/memclob/memclob_grpc_streaming_test.go new file mode 100644 index 0000000000..586c120d4d --- /dev/null +++ b/protocol/x/clob/memclob/memclob_grpc_streaming_test.go @@ -0,0 +1,99 @@ +package memclob + +import ( + "testing" + + "github.com/dydxprotocol/v4-chain/protocol/mocks" + "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" + sdktest "github.com/dydxprotocol/v4-chain/protocol/testutil/sdk" + "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" + satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func TestGetOffchainUpdatesForOrderbookSnapshot_Buy(t *testing.T) { + ctx, _, _ := sdktest.NewSdkContextWithMultistore() + + clobKeeper := &mocks.MemClobKeeper{} + clobKeeper.On( + "GetOrderFillAmount", + mock.Anything, + mock.Anything, + ).Return(false, satypes.BaseQuantums(0), uint32(0)) + clobKeeper.On( + "Logger", + mock.Anything, + ).Return(ctx.Logger()) + + memclob := NewMemClobPriceTimePriority(false) + memclob.SetClobKeeper(clobKeeper) + + memclob.CreateOrderbook(ctx, constants.ClobPair_Btc) + + orders := []types.Order{ + constants.Order_Alice_Num0_Id1_Clob0_Buy15_Price10_GTB18_PO, + constants.Order_Alice_Num0_Id0_Clob0_Buy10_Price10_GTB16, + constants.Order_Bob_Num0_Id12_Clob0_Buy5_Price40_GTB20, + } + + for _, order := range orders { + memclob.mustAddOrderToOrderbook(ctx, order, false) + } + + offchainUpdates := memclob.GetOffchainUpdatesForOrderbookSnapshot( + ctx, + constants.ClobPair_Btc.GetClobPairId(), + ) + + expected := types.NewOffchainUpdates() + // Buy orders are in descending order. + expected.Append(memclob.GetOffchainUpdatesForOrder(ctx, orders[2])) + expected.Append(memclob.GetOffchainUpdatesForOrder(ctx, orders[0])) + expected.Append(memclob.GetOffchainUpdatesForOrder(ctx, orders[1])) + + require.Equal(t, expected, offchainUpdates) +} + +func TestGetOffchainUpdatesForOrderbookSnapshot_Sell(t *testing.T) { + ctx, _, _ := sdktest.NewSdkContextWithMultistore() + + clobKeeper := &mocks.MemClobKeeper{} + clobKeeper.On( + "GetOrderFillAmount", + mock.Anything, + mock.Anything, + ).Return(false, satypes.BaseQuantums(0), uint32(0)) + clobKeeper.On( + "Logger", + mock.Anything, + ).Return(ctx.Logger()) + + memclob := NewMemClobPriceTimePriority(false) + memclob.SetClobKeeper(clobKeeper) + + memclob.CreateOrderbook(ctx, constants.ClobPair_Btc) + + orders := []types.Order{ + constants.Order_Bob_Num0_Id12_Clob0_Sell20_Price35_GTB32, + constants.Order_Alice_Num0_Id0_Clob0_Sell5_Price10_GTB20, + constants.Order_Alice_Num0_Id1_Clob0_Sell15_Price10_GTB18_PO, + } + + for _, order := range orders { + memclob.mustAddOrderToOrderbook(ctx, order, false) + } + + offchainUpdates := memclob.GetOffchainUpdatesForOrderbookSnapshot( + ctx, + constants.ClobPair_Btc.GetClobPairId(), + ) + + expected := types.NewOffchainUpdates() + // Sell orders are in ascending order. + expected.Append(memclob.GetOffchainUpdatesForOrder(ctx, orders[1])) + expected.Append(memclob.GetOffchainUpdatesForOrder(ctx, orders[2])) + expected.Append(memclob.GetOffchainUpdatesForOrder(ctx, orders[0])) + + require.Equal(t, expected, offchainUpdates) +} diff --git a/protocol/x/clob/memclob/memclob_test_util.go b/protocol/x/clob/memclob/memclob_test_util.go index d7ec628914..fc17af0019 100644 --- a/protocol/x/clob/memclob/memclob_test_util.go +++ b/protocol/x/clob/memclob/memclob_test_util.go @@ -11,7 +11,8 @@ import ( mapset "github.com/deckarep/golang-set/v2" "github.com/dydxprotocol/v4-chain/protocol/indexer/msgsender" "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates" - indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared" + ocutypes "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates/types" + indexershared "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" "github.com/dydxprotocol/v4-chain/protocol/lib" testutil_memclob "github.com/dydxprotocol/v4-chain/protocol/testutil/memclob" "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" @@ -1327,7 +1328,7 @@ func assertPlaceOrderOffchainMessages( noopLogger, order.OrderId, indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_REPLACED, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ) expectedOffchainMessages = append( expectedOffchainMessages, @@ -1356,7 +1357,7 @@ func assertPlaceOrderOffchainMessages( noopLogger, orderId, indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ) // If the reduce-only order was seen before updates, add it to the set so we don't try to check // for it later. @@ -1385,7 +1386,7 @@ func assertPlaceOrderOffchainMessages( noopLogger, matchOrder.OrderId, indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_UNDERCOLLATERALIZED, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ) expectedOffchainMessages = append( @@ -1443,7 +1444,7 @@ func assertPlaceOrderOffchainMessages( noopLogger, orderId, indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ) expectedOffchainMessages = append( expectedOffchainMessages, @@ -1476,7 +1477,7 @@ func assertPlaceOrderOffchainMessages( order.OrderId, expectedOrderStatus, expectedErr, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ) expectedOffchainMessages = append( expectedOffchainMessages, @@ -1540,7 +1541,7 @@ func getExpectedPlacePerpetualLiquidationOffchainMessages( noopLogger, order.OrderId, indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_SELF_TRADE_ERROR, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ) expectedOffchainMessages = append( @@ -1555,7 +1556,7 @@ func getExpectedPlacePerpetualLiquidationOffchainMessages( noopLogger, order.OrderId, indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_UNDERCOLLATERALIZED, - off_chain_updates.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, ) expectedOffchainMessages = append( diff --git a/protocol/x/clob/types/clob_keeper.go b/protocol/x/clob/types/clob_keeper.go index 64b002844d..c31b741155 100644 --- a/protocol/x/clob/types/clob_keeper.go +++ b/protocol/x/clob/types/clob_keeper.go @@ -127,4 +127,5 @@ type ClobKeeper interface { clobPair ClobPair, ) error UpdateLiquidationsConfig(ctx sdk.Context, config LiquidationsConfig) error + InitializeNewGrpcStreams(ctx sdk.Context) } diff --git a/protocol/x/clob/types/errors.go b/protocol/x/clob/types/errors.go index 1c5f09b920..78e13cbea2 100644 --- a/protocol/x/clob/types/errors.go +++ b/protocol/x/clob/types/errors.go @@ -512,4 +512,16 @@ var ( 10001, "Subaccount cannot open more orders due to equity tier limit.", ) + + // GrpcStreamingManager errors. + ErrGrpcStreamingManagerNotEnabled = errorsmod.Register( + ModuleName, + 11000, + "GrpcStreamingManager is not enabled", + ) + ErrInvalidGrpcStreamingRequest = errorsmod.Register( + ModuleName, + 11001, + "Invalid gRPC streaming request", + ) ) diff --git a/protocol/x/clob/types/memclob.go b/protocol/x/clob/types/memclob.go index a90aa4f68c..2a0539b884 100644 --- a/protocol/x/clob/types/memclob.go +++ b/protocol/x/clob/types/memclob.go @@ -137,4 +137,8 @@ type MemClob interface { bestAsk Order, exists bool, ) + GetOffchainUpdatesForOrderbookSnapshot( + ctx sdk.Context, + clobPairId ClobPairId, + ) (offchainUpdates *OffchainUpdates) } diff --git a/protocol/x/clob/types/query.pb.go b/protocol/x/clob/types/query.pb.go index 78f490f800..7f48a50310 100644 --- a/protocol/x/clob/types/query.pb.go +++ b/protocol/x/clob/types/query.pb.go @@ -11,6 +11,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + types "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -653,6 +654,112 @@ func (m *QueryLiquidationsConfigurationResponse) GetLiquidationsConfig() Liquida return LiquidationsConfig{} } +// StreamOrderbookUpdatesRequest is a request message for the +// StreamOrderbookUpdates method. +type StreamOrderbookUpdatesRequest struct { + // Clob pair ids to stream orderbook updates for. + ClobPairId []uint32 `protobuf:"varint,1,rep,packed,name=clob_pair_id,json=clobPairId,proto3" json:"clob_pair_id,omitempty"` +} + +func (m *StreamOrderbookUpdatesRequest) Reset() { *m = StreamOrderbookUpdatesRequest{} } +func (m *StreamOrderbookUpdatesRequest) String() string { return proto.CompactTextString(m) } +func (*StreamOrderbookUpdatesRequest) ProtoMessage() {} +func (*StreamOrderbookUpdatesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3365c195b25c5bc0, []int{12} +} +func (m *StreamOrderbookUpdatesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StreamOrderbookUpdatesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StreamOrderbookUpdatesRequest.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 *StreamOrderbookUpdatesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StreamOrderbookUpdatesRequest.Merge(m, src) +} +func (m *StreamOrderbookUpdatesRequest) XXX_Size() int { + return m.Size() +} +func (m *StreamOrderbookUpdatesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StreamOrderbookUpdatesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StreamOrderbookUpdatesRequest proto.InternalMessageInfo + +func (m *StreamOrderbookUpdatesRequest) GetClobPairId() []uint32 { + if m != nil { + return m.ClobPairId + } + return nil +} + +// StreamOrderbookUpdatesResponse is a response message for the +// StreamOrderbookUpdates method. +type StreamOrderbookUpdatesResponse struct { + // Orderbook updates for the clob pair. + Updates []types.OffChainUpdateV1 `protobuf:"bytes,1,rep,name=updates,proto3" json:"updates"` + // Snapshot indicates if the response is from a snapshot of the orderbook. + // This is true for the initial response and false for all subsequent updates. + // Note that if the snapshot is true, then all previous entries should be + // discarded and the orderbook should be resynced. + Snapshot bool `protobuf:"varint,2,opt,name=snapshot,proto3" json:"snapshot,omitempty"` +} + +func (m *StreamOrderbookUpdatesResponse) Reset() { *m = StreamOrderbookUpdatesResponse{} } +func (m *StreamOrderbookUpdatesResponse) String() string { return proto.CompactTextString(m) } +func (*StreamOrderbookUpdatesResponse) ProtoMessage() {} +func (*StreamOrderbookUpdatesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3365c195b25c5bc0, []int{13} +} +func (m *StreamOrderbookUpdatesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StreamOrderbookUpdatesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StreamOrderbookUpdatesResponse.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 *StreamOrderbookUpdatesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_StreamOrderbookUpdatesResponse.Merge(m, src) +} +func (m *StreamOrderbookUpdatesResponse) XXX_Size() int { + return m.Size() +} +func (m *StreamOrderbookUpdatesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_StreamOrderbookUpdatesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_StreamOrderbookUpdatesResponse proto.InternalMessageInfo + +func (m *StreamOrderbookUpdatesResponse) GetUpdates() []types.OffChainUpdateV1 { + if m != nil { + return m.Updates + } + return nil +} + +func (m *StreamOrderbookUpdatesResponse) GetSnapshot() bool { + if m != nil { + return m.Snapshot + } + return false +} + func init() { proto.RegisterType((*QueryGetClobPairRequest)(nil), "dydxprotocol.clob.QueryGetClobPairRequest") proto.RegisterType((*QueryClobPairResponse)(nil), "dydxprotocol.clob.QueryClobPairResponse") @@ -667,72 +774,82 @@ func init() { proto.RegisterType((*QueryBlockRateLimitConfigurationResponse)(nil), "dydxprotocol.clob.QueryBlockRateLimitConfigurationResponse") proto.RegisterType((*QueryLiquidationsConfigurationRequest)(nil), "dydxprotocol.clob.QueryLiquidationsConfigurationRequest") proto.RegisterType((*QueryLiquidationsConfigurationResponse)(nil), "dydxprotocol.clob.QueryLiquidationsConfigurationResponse") + proto.RegisterType((*StreamOrderbookUpdatesRequest)(nil), "dydxprotocol.clob.StreamOrderbookUpdatesRequest") + proto.RegisterType((*StreamOrderbookUpdatesResponse)(nil), "dydxprotocol.clob.StreamOrderbookUpdatesResponse") } func init() { proto.RegisterFile("dydxprotocol/clob/query.proto", fileDescriptor_3365c195b25c5bc0) } var fileDescriptor_3365c195b25c5bc0 = []byte{ - // 946 bytes of a gzipped FileDescriptorProto + // 1073 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcf, 0x6f, 0xdc, 0x44, - 0x14, 0xce, 0x6c, 0x4a, 0x09, 0x53, 0x40, 0x30, 0x69, 0xda, 0x65, 0x93, 0x6e, 0xb6, 0x86, 0x24, - 0x9b, 0x54, 0x78, 0x68, 0x5a, 0x21, 0x48, 0x11, 0x52, 0x12, 0x41, 0x84, 0xd4, 0xa0, 0xc5, 0xaa, - 0x8a, 0x04, 0x95, 0xac, 0x59, 0x7b, 0x70, 0x46, 0x1d, 0x7b, 0x36, 0xf6, 0xd8, 0x6a, 0x84, 0xb8, - 0x70, 0xe0, 0x02, 0x07, 0x24, 0x0e, 0x1c, 0x38, 0x72, 0xe6, 0x4f, 0x40, 0xc0, 0xad, 0xc7, 0x4a, - 0x5c, 0x38, 0x20, 0x84, 0x12, 0xce, 0xfc, 0x0d, 0x95, 0xc7, 0xb3, 0x5b, 0x6f, 0xfc, 0x63, 0x93, - 0xbd, 0xec, 0xda, 0x33, 0xdf, 0x7b, 0xfe, 0xbe, 0xf7, 0xde, 0x7c, 0x36, 0xbc, 0xe6, 0x1e, 0xb9, - 0x8f, 0x06, 0xa1, 0x90, 0xc2, 0x11, 0x1c, 0x3b, 0x5c, 0xf4, 0xf1, 0x61, 0x4c, 0xc3, 0x23, 0x53, - 0xad, 0xa1, 0x57, 0xf3, 0xdb, 0x66, 0xba, 0xdd, 0xba, 0xec, 0x09, 0x4f, 0xa8, 0x25, 0x9c, 0x5e, - 0x65, 0xc0, 0xd6, 0x92, 0x27, 0x84, 0xc7, 0x29, 0x26, 0x03, 0x86, 0x49, 0x10, 0x08, 0x49, 0x24, - 0x13, 0x41, 0xa4, 0x77, 0x37, 0x1c, 0x11, 0xf9, 0x22, 0xc2, 0x7d, 0x12, 0xd1, 0x2c, 0x3f, 0x4e, - 0x6e, 0xf6, 0xa9, 0x24, 0x37, 0xf1, 0x80, 0x78, 0x2c, 0x50, 0x60, 0x8d, 0xc5, 0x45, 0x46, 0x7d, - 0x2e, 0x9c, 0x87, 0x76, 0x48, 0x24, 0xb5, 0x39, 0xf3, 0x99, 0xb4, 0x1d, 0x11, 0x7c, 0xc1, 0x3c, - 0x1d, 0x70, 0xbd, 0x18, 0x90, 0xfe, 0xd8, 0x03, 0xc2, 0x42, 0x0d, 0x79, 0xab, 0x08, 0xa1, 0x87, - 0x31, 0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0xac, 0x65, 0xc8, 0x6f, 0x38, 0x4e, 0x19, 0xff, 0xb1, 0x73, 0xf2, 0x47, 0xdb, 0x19, 0x92, + 0xa3, 0x82, 0xe4, 0xe2, 0x50, 0x92, 0xe9, 0xc3, 0x33, 0x2c, 0xff, 0x02, 0x70, 0x6e, 0x87, 0xc4, + 0xef, 0x31, 0x9b, 0x3c, 0x62, 0xc9, 0xef, 0x16, 0x76, 0xac, 0xc8, 0x11, 0x9b, 0xbd, 0x8a, 0x3c, + 0x86, 0x53, 0xe9, 0xc0, 0xfa, 0x01, 0xf3, 0x59, 0x48, 0x02, 0xd3, 0xc5, 0xdc, 0xda, 0x23, 0x61, + 0xbf, 0x3a, 0x79, 0xe6, 0xbb, 0xd8, 0x49, 0x46, 0x8b, 0x05, 0x3b, 0x24, 0xde, 0x49, 0xd1, 0xc6, + 0x75, 0x91, 0xa5, 0x25, 0x93, 0xc8, 0x55, 0xf4, 0x29, 0x9c, 0x8c, 0x7b, 0x60, 0xd3, 0x25, 0xb1, + 0xe9, 0x12, 0x1e, 0x50, 0x2b, 0xec, 0xab, 0xca, 0x27, 0xcf, 0x10, 0xde, 0x49, 0xe1, 0xc6, 0x44, + 0x3c, 0xf8, 0xc8, 0x74, 0x51, 0xfd, 0x0f, 0xc0, 0x46, 0xb9, 0x3c, 0xd9, 0x8c, 0x2e, 0xbc, 0x12, + 0x90, 0x30, 0x72, 0x78, 0x28, 0x5b, 0xb1, 0x3d, 0xec, 0x99, 0x05, 0x59, 0x12, 0xc0, 0x86, 0x67, + 0xef, 0x32, 0x27, 0x72, 0x49, 0x8b, 0x04, 0x49, 0xeb, 0x64, 0xdb, 0x7a, 0xd9, 0x15, 0x0c, 0x27, + 0x0a, 0x50, 0xa8, 0x01, 0x9f, 0xef, 0x0f, 0x83, 0xd9, 0x9f, 0x7f, 0xd8, 0x6b, 0xf6, 0xbb, 0x36, + 0x7a, 0x09, 0x8e, 0xb9, 0x24, 0x16, 0x15, 0x19, 0x35, 0x92, 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x07, 0xad, 0x97, 0xb1, 0x18, 0x6e, 0x98, 0xca, 0xbd, 0x0b, 0xc5, + 0x4a, 0x01, 0xf3, 0x42, 0xc0, 0x1c, 0x9a, 0xad, 0xfc, 0xb0, 0x45, 0xbf, 0x01, 0xf8, 0x4a, 0xa9, + 0x99, 0xa1, 0xbb, 0x65, 0x0c, 0x86, 0x39, 0xa5, 0xf2, 0xe6, 0x05, 0x22, 0x25, 0x73, 0x4d, 0x30, + 0x6f, 0xa2, 0x05, 0xfd, 0x4c, 0x1f, 0xc3, 0xe8, 0x0b, 0x38, 0x55, 0xec, 0x63, 0x68, 0xa5, 0x80, + 0x44, 0xa5, 0x6d, 0x2a, 0xab, 0xe7, 0x88, 0x48, 0xe9, 0xae, 0x80, 0xcd, 0xd6, 0x93, 0xe3, 0x3a, + 0x78, 0x7a, 0x5c, 0x07, 0xff, 0x1c, 0xd7, 0xc1, 0xb7, 0x27, 0xf5, 0x91, 0xa7, 0x27, 0xf5, 0x91, + 0x3f, 0x4f, 0xea, 0x23, 0x9f, 0xbc, 0xd1, 0xa5, 0x7c, 0x2f, 0x6a, 0x6b, 0x16, 0x73, 0xb3, 0x62, + 0xe2, 0x3b, 0xaf, 0x0b, 0xc3, 0xd4, 0xfb, 0x2b, 0x87, 0xa9, 0x40, 0x7e, 0xe4, 0x93, 0xb0, 0x7d, + 0x59, 0x2c, 0xdf, 0xfe, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x3b, 0xb1, 0xe8, 0xed, 0x27, 0x0d, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -759,6 +876,8 @@ type QueryClient interface { BlockRateLimitConfiguration(ctx context.Context, in *QueryBlockRateLimitConfigurationRequest, opts ...grpc.CallOption) (*QueryBlockRateLimitConfigurationResponse, error) // Queries LiquidationsConfiguration. LiquidationsConfiguration(ctx context.Context, in *QueryLiquidationsConfigurationRequest, opts ...grpc.CallOption) (*QueryLiquidationsConfigurationResponse, error) + // Streams orderbook updates. + StreamOrderbookUpdates(ctx context.Context, in *StreamOrderbookUpdatesRequest, opts ...grpc.CallOption) (Query_StreamOrderbookUpdatesClient, error) } type queryClient struct { @@ -823,6 +942,38 @@ func (c *queryClient) LiquidationsConfiguration(ctx context.Context, in *QueryLi return out, nil } +func (c *queryClient) StreamOrderbookUpdates(ctx context.Context, in *StreamOrderbookUpdatesRequest, opts ...grpc.CallOption) (Query_StreamOrderbookUpdatesClient, error) { + stream, err := c.cc.NewStream(ctx, &_Query_serviceDesc.Streams[0], "/dydxprotocol.clob.Query/StreamOrderbookUpdates", opts...) + if err != nil { + return nil, err + } + x := &queryStreamOrderbookUpdatesClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Query_StreamOrderbookUpdatesClient interface { + Recv() (*StreamOrderbookUpdatesResponse, error) + grpc.ClientStream +} + +type queryStreamOrderbookUpdatesClient struct { + grpc.ClientStream +} + +func (x *queryStreamOrderbookUpdatesClient) Recv() (*StreamOrderbookUpdatesResponse, error) { + m := new(StreamOrderbookUpdatesResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Queries a ClobPair by id. @@ -837,6 +988,8 @@ type QueryServer interface { BlockRateLimitConfiguration(context.Context, *QueryBlockRateLimitConfigurationRequest) (*QueryBlockRateLimitConfigurationResponse, error) // Queries LiquidationsConfiguration. LiquidationsConfiguration(context.Context, *QueryLiquidationsConfigurationRequest) (*QueryLiquidationsConfigurationResponse, error) + // Streams orderbook updates. + StreamOrderbookUpdates(*StreamOrderbookUpdatesRequest, Query_StreamOrderbookUpdatesServer) error } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -861,6 +1014,9 @@ func (*UnimplementedQueryServer) BlockRateLimitConfiguration(ctx context.Context func (*UnimplementedQueryServer) LiquidationsConfiguration(ctx context.Context, req *QueryLiquidationsConfigurationRequest) (*QueryLiquidationsConfigurationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method LiquidationsConfiguration not implemented") } +func (*UnimplementedQueryServer) StreamOrderbookUpdates(req *StreamOrderbookUpdatesRequest, srv Query_StreamOrderbookUpdatesServer) error { + return status.Errorf(codes.Unimplemented, "method StreamOrderbookUpdates not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -974,6 +1130,27 @@ func _Query_LiquidationsConfiguration_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +func _Query_StreamOrderbookUpdates_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(StreamOrderbookUpdatesRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(QueryServer).StreamOrderbookUpdates(m, &queryStreamOrderbookUpdatesServer{stream}) +} + +type Query_StreamOrderbookUpdatesServer interface { + Send(*StreamOrderbookUpdatesResponse) error + grpc.ServerStream +} + +type queryStreamOrderbookUpdatesServer struct { + grpc.ServerStream +} + +func (x *queryStreamOrderbookUpdatesServer) Send(m *StreamOrderbookUpdatesResponse) error { + return x.ServerStream.SendMsg(m) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "dydxprotocol.clob.Query", HandlerType: (*QueryServer)(nil), @@ -1003,7 +1180,13 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_LiquidationsConfiguration_Handler, }, }, - Streams: []grpc.StreamDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "StreamOrderbookUpdates", + Handler: _Query_StreamOrderbookUpdates_Handler, + ServerStreams: true, + }, + }, Metadata: "dydxprotocol/clob/query.proto", } @@ -1443,6 +1626,94 @@ func (m *QueryLiquidationsConfigurationResponse) MarshalToSizedBuffer(dAtA []byt return len(dAtA) - i, nil } +func (m *StreamOrderbookUpdatesRequest) 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 *StreamOrderbookUpdatesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StreamOrderbookUpdatesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ClobPairId) > 0 { + dAtA10 := make([]byte, len(m.ClobPairId)*10) + var j9 int + for _, num := range m.ClobPairId { + for num >= 1<<7 { + dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j9++ + } + dAtA10[j9] = uint8(num) + j9++ + } + i -= j9 + copy(dAtA[i:], dAtA10[:j9]) + i = encodeVarintQuery(dAtA, i, uint64(j9)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StreamOrderbookUpdatesResponse) 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 *StreamOrderbookUpdatesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StreamOrderbookUpdatesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Snapshot { + i-- + if m.Snapshot { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Updates) > 0 { + for iNdEx := len(m.Updates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Updates[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 @@ -1619,6 +1890,40 @@ func (m *QueryLiquidationsConfigurationResponse) Size() (n int) { return n } +func (m *StreamOrderbookUpdatesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ClobPairId) > 0 { + l = 0 + for _, e := range m.ClobPairId { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + return n +} + +func (m *StreamOrderbookUpdatesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Updates) > 0 { + for _, e := range m.Updates { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Snapshot { + n += 2 + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2687,6 +2992,236 @@ func (m *QueryLiquidationsConfigurationResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *StreamOrderbookUpdatesRequest) 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: StreamOrderbookUpdatesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StreamOrderbookUpdatesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ClobPairId = append(m.ClobPairId, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.ClobPairId) == 0 { + m.ClobPairId = make([]uint32, 0, elementCount) + } + for iNdEx < postIndex { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ClobPairId = append(m.ClobPairId, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ClobPairId", wireType) + } + 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 *StreamOrderbookUpdatesResponse) 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: StreamOrderbookUpdatesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StreamOrderbookUpdatesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Updates", 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.Updates = append(m.Updates, types.OffChainUpdateV1{}) + if err := m.Updates[len(m.Updates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Snapshot", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Snapshot = bool(v != 0) + 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