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..aa31787820 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,76 @@ 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; + /** + * ---Additional fields used to debug issues--- + * Block height of the updates. + */ + + blockHeight: number; + /** Exec mode of the updates. */ + + execMode: number; +} +/** + * 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; + /** + * ---Additional fields used to debug issues--- + * Block height of the updates. + */ + + block_height: number; + /** Exec mode of the updates. */ + + exec_mode: number; +} function createBaseQueryGetClobPairRequest(): QueryGetClobPairRequest { return { @@ -789,4 +860,136 @@ 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, + blockHeight: 0, + execMode: 0 + }; +} + +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); + } + + if (message.blockHeight !== 0) { + writer.uint32(24).uint32(message.blockHeight); + } + + if (message.execMode !== 0) { + writer.uint32(32).uint32(message.execMode); + } + + 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; + + case 3: + message.blockHeight = reader.uint32(); + break; + + case 4: + message.execMode = reader.uint32(); + 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; + message.blockHeight = object.blockHeight ?? 0; + message.execMode = object.execMode ?? 0; + return message; + } + }; \ No newline at end of file diff --git a/proto/dydxprotocol/clob/query.proto b/proto/dydxprotocol/clob/query.proto index 3fc37479c0..3745756894 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,31 @@ 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; + + // ---Additional fields used to debug issues--- + // Block height of the updates. + uint32 block_height = 3; + + // Exec mode of the updates. + uint32 exec_mode = 4; +} 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/app.go b/protocol/app/app.go index 1527c783fe..990235763b 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -198,6 +198,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 ( @@ -298,8 +302,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 @@ -678,6 +683,9 @@ func New( tkeys[indexer_manager.TransientStoreKey], indexerFlags.SendOffchainData, ) + + app.GrpcStreamingManager = getGrpcStreamingManagerFromOptions(appFlags, logger) + timeProvider := &timelib.TimeProviderImpl{} app.EpochsKeeper = *epochsmodulekeeper.NewKeeper( @@ -953,6 +961,7 @@ func New( logger.Info("Parsed CLOB flags", "Flags", clobFlags) memClob := clobmodulememclob.NewMemClobPriceTimePriority(app.IndexerEventManager.Enabled()) + memClob.SetGenerateOrderbookUpdates(app.GrpcStreamingManager.Enabled()) app.ClobKeeper = clobmodulekeeper.NewKeeper( appCodec, @@ -975,6 +984,7 @@ func New( app.StatsKeeper, app.RewardsKeeper, app.IndexerEventManager, + app.GrpcStreamingManager, txConfig.TxDecoder(), clobFlags, rate_limit.NewPanicRateLimiter[*clobmoduletypes.MsgPlaceOrder](), @@ -1471,6 +1481,8 @@ func (app *App) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk. // BeginBlocker application updates every begin block func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + ctx = ctx.WithExecMode(lib.ExecModeBeginBlock) + // Update the proposer address in the logger for the panic logging middleware. proposerAddr := sdk.ConsAddress(ctx.BlockHeader().ProposerAddress) middleware.Logger = ctx.Logger().With("proposer_cons_addr", proposerAddr.String()) @@ -1481,6 +1493,8 @@ func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { // EndBlocker application updates every end block func (app *App) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + ctx = ctx.WithExecMode(lib.ExecModeEndBlock) + // Reset the logger for middleware. // Note that the middleware is only used by `CheckTx` and `DeliverTx`, and not `EndBlocker`. // Panics from `EndBlocker` will not be logged by the middleware and will lead to consensus failures. @@ -1504,6 +1518,8 @@ func (app *App) Precommitter(ctx sdk.Context) { // PrepareCheckStater application updates after commit and before any check state is invoked. func (app *App) PrepareCheckStater(ctx sdk.Context) { + ctx = ctx.WithExecMode(lib.ExecModePrepareCheckState) + if err := app.ModuleManager.PrepareCheckState(ctx); err != nil { panic(err) } @@ -1737,3 +1753,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 cfca80ef2e..a2852dc347 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 ( sdk "github.com/cosmos/cosmos-sdk/types" "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" "github.com/dydxprotocol/v4-chain/protocol/lib/log" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" @@ -112,8 +114,8 @@ func CreateOrderUpdateMessage( func MustCreateOrderRemoveMessageWithReason( ctx sdk.Context, orderId clobtypes.OrderId, - reason shared.OrderRemovalReason, - removalStatus OrderRemoveV1_OrderRemovalStatus, + reason sharedtypes.OrderRemovalReason, + removalStatus ocutypes.OrderRemoveV1_OrderRemovalStatus, ) msgsender.Message { msg, ok := CreateOrderRemoveMessageWithReason(ctx, orderId, reason, removalStatus) if !ok { @@ -127,8 +129,8 @@ func MustCreateOrderRemoveMessageWithReason( func CreateOrderRemoveMessageWithReason( ctx sdk.Context, 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." @@ -167,7 +169,7 @@ func MustCreateOrderRemoveMessage( orderId clobtypes.OrderId, orderStatus clobtypes.OrderStatus, orderError error, - removalStatus OrderRemoveV1_OrderRemovalStatus, + removalStatus ocutypes.OrderRemoveV1_OrderRemovalStatus, ) msgsender.Message { msg, ok := CreateOrderRemoveMessage(ctx, orderId, orderStatus, orderError, removalStatus) if !ok { @@ -183,7 +185,7 @@ func CreateOrderRemoveMessage( orderId clobtypes.OrderId, orderStatus clobtypes.OrderStatus, orderError error, - removalStatus OrderRemoveV1_OrderRemovalStatus, + removalStatus ocutypes.OrderRemoveV1_OrderRemovalStatus, ) (message msgsender.Message, success bool) { reason, err := shared.GetOrderRemovalReason(orderStatus, orderError) if err != nil { @@ -210,10 +212,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: " + @@ -243,12 +245,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, }, }, } @@ -260,13 +262,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, @@ -284,9 +286,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(), }, @@ -296,7 +298,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 e45f730162..b1182aa9a9 100644 --- a/protocol/indexer/off_chain_updates/off_chain_updates_test.go +++ b/protocol/indexer/off_chain_updates/off_chain_updates_test.go @@ -8,8 +8,9 @@ import ( "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" "github.com/dydxprotocol/v4-chain/protocol/testutil/sdk" @@ -25,37 +26,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, @@ -179,7 +180,7 @@ func TestCreateOrderRemoveMessageWithDefaultReason_InvalidDefault(t *testing.T) clobtypes.Success, orderError, status, - shared.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED, + sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED, ) }, ) @@ -214,7 +215,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, @@ -236,7 +237,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, @@ -258,7 +259,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, 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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, 0xb8, 0x03, 0x34, 0x1b, + 0x95, 0x4c, 0x84, 0x6b, 0x95, 0x42, 0xd1, 0x3c, 0x36, 0xab, 0x0d, 0x5c, 0x6f, 0x14, 0x1a, 0x27, + 0x75, 0x7c, 0x52, 0xad, 0xd7, 0xcc, 0xa2, 0x55, 0xb6, 0xcc, 0x92, 0x22, 0xc1, 0x3d, 0xf0, 0xfa, + 0x16, 0xdc, 0xa1, 0x59, 0x6f, 0x60, 0xb3, 0x5c, 0xb6, 0x51, 0x03, 0xdb, 0x35, 0xb3, 0x6a, 0x96, + 0x14, 0x19, 0xbe, 0x04, 0xcf, 0x6f, 0x81, 0x0b, 0x48, 0x46, 0xfb, 0xb1, 0x02, 0x36, 0xb8, 0x33, + 0x71, 0x54, 0xb1, 0x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0x3b, 0xb8, 0xcf, 0x1b, 0x3c, 0x92, 0x10, + 0xa0, 0x49, 0x0d, 0x9b, 0x60, 0x9d, 0x13, 0xf3, 0x15, 0x64, 0xc2, 0xd6, 0xf2, 0xef, 0xee, 0xb5, + 0x1f, 0x47, 0x12, 0xe2, 0x2a, 0x79, 0xe3, 0x9a, 0x9b, 0xa3, 0xd9, 0xee, 0x2d, 0xcb, 0x3d, 0x75, + 0x20, 0xe1, 0xe6, 0x8d, 0x43, 0x05, 0x64, 0x39, 0x0e, 0xf7, 0x48, 0x18, 0x3a, 0x67, 0xe4, 0xd0, + 0xfd, 0x3e, 0x56, 0xe5, 0xab, 0xb1, 0x2a, 0xff, 0x1e, 0xab, 0xf2, 0xe5, 0x44, 0x95, 0xae, 0x26, + 0xaa, 0xf4, 0x73, 0xa2, 0x4a, 0x4d, 0xeb, 0xac, 0x1b, 0x75, 0x86, 0x2d, 0xdd, 0xa5, 0x3d, 0x63, + 0xee, 0x47, 0x75, 0x74, 0xb0, 0xc7, 0x8e, 0x34, 0xee, 0xf0, 0x07, 0x10, 0x5d, 0x0c, 0x48, 0xd8, + 0x5a, 0x65, 0xc8, 0xb7, 0x7f, 0x02, 0x00, 0x00, 0xff, 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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 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, 0x27, 0x84, 0xda, 0x7f, 0x82, 0x47, 0x74, 0x6d, 0xe3, + 0x25, 0xcd, 0x44, 0xd7, 0x37, 0xdf, 0xef, 0x7c, 0xe7, 0xd3, 0xf9, 0xbe, 0x73, 0x6d, 0xc3, 0xe7, + 0xc1, 0x22, 0x78, 0x79, 0x1e, 0x8b, 0x44, 0xf8, 0x22, 0xec, 0xf1, 0x28, 0x60, 0x2f, 0x59, 0xdc, + 0x2b, 0x80, 0x8b, 0x83, 0x9e, 0x1f, 0x8a, 0x71, 0x37, 0x05, 0x50, 0x7b, 0x99, 0xdc, 0xcd, 0xc9, + 0xdd, 0x02, 0xb8, 0x38, 0xd8, 0x39, 0xb8, 0x51, 0x6e, 0x36, 0x1f, 0x7b, 0xbe, 0x2f, 0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0xec, 0xc2, 0xbd, 0x35, 0x46, 0x5f, 0x27, 0xf8, 0x07, 0x23, 0xcb, 0x63, 0xad, 0x38, 0xea, 0x9f, + 0xb8, 0xc6, 0xa1, 0x5a, 0x7e, 0xab, 0xb6, 0xde, 0xb7, 0x74, 0xc3, 0xcc, 0x12, 0xdb, 0x48, 0x2d, + 0xac, 0xb5, 0x17, 0x89, 0x56, 0xd0, 0x43, 0x78, 0xb0, 0x56, 0xc7, 0x16, 0x26, 0xb8, 0x6f, 0xe2, + 0x67, 0xd8, 0x7a, 0xa2, 0xde, 0x41, 0x1f, 0xc3, 0xc3, 0x35, 0xca, 0x10, 0x5b, 0x7d, 0x93, 0xba, + 0x06, 0x21, 0xa6, 0x71, 0x6c, 0x58, 0x44, 0xdd, 0x1c, 0xfc, 0xf8, 0xea, 0xb2, 0xa5, 0xbc, 0xbe, + 0x6c, 0x29, 0x7f, 0x5f, 0xb6, 0x94, 0xdf, 0xae, 0x5a, 0xa5, 0xd7, 0x57, 0xad, 0xd2, 0x9f, 0x57, + 0xad, 0xd2, 0x33, 0x7d, 0xc2, 0x93, 0xe7, 0xf3, 0x71, 0xd7, 0x17, 0xd3, 0xde, 0xca, 0x6f, 0xe1, + 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, 0x1b, 0xbb, 0x23, 0x65, 0x67, 0x42, 0xc8, 0xb4, 0x33, 0x96, 0x49, + 0xda, 0x99, 0x32, 0x7f, 0x10, 0xdc, 0xbb, 0xf7, 0x45, 0xdc, 0xf9, 0x10, 0x2c, 0x89, 0x2b, 0xe3, + 0x82, 0x18, 0x78, 0x11, 0xc3, 0x4c, 0x29, 0x9a, 0xb8, 0x70, 0x41, 0xdc, 0xf5, 0xfc, 0xf2, 0x7d, + 0xe7, 0x34, 0xe7, 0xcb, 0x80, 0x01, 0x5a, 0xa3, 0x55, 0xc9, 0x99, 0x64, 0x29, 0xcb, 0x43, 0x42, + 0x11, 0x5e, 0x61, 0x1e, 0xd6, 0x60, 0x39, 0x08, 0x85, 0x4a, 0x60, 0x9a, 0x32, 0x45, 0x65, 0xa0, + 0xb1, 0xd3, 0xf9, 0x7d, 0x25, 0xa8, 0x56, 0x82, 0x1a, 0x2c, 0x07, 0xad, 0xfb, 0x94, 0x89, 0x82, + 0x89, 0x99, 0x66, 0xa1, 0x11, 0x66, 0xa0, 0xe5, 0x66, 0x2c, 0x63, 0x86, 0x1f, 0xbf, 0x0c, 0xed, + 0x4e, 0xc1, 0xb3, 0xc8, 0xf8, 0x4c, 0xea, 0xb4, 0x08, 0x39, 0x01, 0xb8, 0x61, 0x1f, 0x28, 0xe6, + 0x9e, 0xdd, 0xb1, 0x7b, 0x8f, 0x46, 0xde, 0xb7, 0xaf, 0x7d, 0xb7, 0x72, 0x1b, 0x22, 0xc4, 0xb1, + 0x10, 0x13, 0xc9, 0x09, 0xcd, 0x62, 0x33, 0xe6, 0x3c, 0x07, 0xb7, 0x54, 0x15, 0x09, 0xe6, 0xde, + 0x83, 0x8e, 0xdd, 0x6b, 0xc6, 0x95, 0xea, 0x7e, 0xba, 0x02, 0x5e, 0xe5, 0x3f, 0xc6, 0xbc, 0xc4, + 0x52, 0xc1, 0x7c, 0xcc, 0x04, 0x91, 0x84, 0x51, 0xe7, 0x05, 0x68, 0x94, 0x27, 0x38, 0x23, 0x48, + 0x67, 0x35, 0xe3, 0xc7, 0x35, 0x8b, 0x90, 0x83, 0xc0, 0xdd, 0x42, 0x41, 0x2a, 0x55, 0x21, 0xb4, + 0x73, 0x63, 0xf4, 0x76, 0xb3, 0x6b, 0x5b, 0x3f, 0x76, 0xed, 0xd7, 0x19, 0x91, 0x73, 0x95, 0x04, + 0x29, 0x2b, 0xc2, 0x3f, 0x9a, 0x5c, 0xbe, 0xea, 0xa7, 0x73, 0x48, 0xe8, 0xb9, 0x4a, 0x24, 0xd7, + 0x25, 0x16, 0xc1, 0x04, 0x73, 0x02, 0x73, 0xf2, 0x11, 0x26, 0x39, 0x8e, 0xa8, 0x8c, 0x6b, 0x67, + 0xa7, 0x00, 0xcd, 0xf7, 0x8a, 0x22, 0x42, 0xb3, 0x99, 0x2e, 0xd5, 0xbb, 0xba, 0x70, 0x54, 0xa3, + 0xb2, 0xd7, 0x55, 0x38, 0x0b, 0xf0, 0xf4, 0x14, 0x57, 0xc2, 0x75, 0x81, 0xa9, 0xf4, 0xae, 0x2f, + 0x1c, 0xf8, 0xa4, 0x0a, 0x18, 0x1b, 0xff, 0xee, 0x17, 0x1b, 0xb8, 0xd5, 0x1d, 0x86, 0x42, 0x60, + 0x59, 0xdf, 0xe0, 0x1e, 0xdc, 0xc1, 0x23, 0x38, 0xf7, 0xff, 0x50, 0xeb, 0xff, 0xd6, 0xbd, 0x0b, + 0x6e, 0xce, 0x9d, 0x5f, 0xc7, 0x46, 0x8c, 0xa6, 0x9b, 0xbd, 0x6f, 0x6f, 0xf7, 0xbe, 0xfd, 0x73, + 0xef, 0xdb, 0x9f, 0x0f, 0xbe, 0xb5, 0x3d, 0xf8, 0xd6, 0xf7, 0x83, 0x6f, 0xbd, 0x7b, 0xf3, 0xef, + 0xd9, 0x7f, 0x7b, 0x53, 0xfa, 0x77, 0x92, 0x5b, 0x8d, 0x5e, 0xfe, 0x0a, 0x00, 0x00, 0xff, 0xff, + 0x07, 0xb5, 0x3e, 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 25e4828f1f..f15d95f04b 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,27 +39,27 @@ func ConvertOrderRemovalReasonToIndexerOrderRemovalReason( func GetOrderRemovalReason( orderStatus clobtypes.OrderStatus, orderError error, -) (OrderRemovalReason, error) { +) (sharedtypes.OrderRemovalReason, error) { switch { case errors.Is(orderError, clobtypes.ErrReduceOnlyWouldIncreasePositionSize): - return OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE, nil + return sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE, nil 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 bb36ea89d6..697b503f0a 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,37 +17,37 @@ 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, }, "Gets order removal reason for order error ErrReduceOnlyWouldIncreasePositionSize": { orderError: clobtypes.ErrReduceOnlyWouldIncreasePositionSize, - expectedReason: shared.OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE, + expectedReason: sharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_REDUCE_ONLY_RESIZE, 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, 0x4f, 0xbf, 0xa6, 0x67, 0x9f, 0x8b, 0xfc, 0x24, 0x9f, 0xe4, 0x87, - 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 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, 0x36, 0xd8, 0x16, 0xb9, 0xeb, 0x54, 0x41, 0xbf, + 0x27, 0x11, 0x04, 0x6d, 0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x3b, 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/lib/context.go b/protocol/lib/context.go index c7f5aed1d9..15ddb33e3b 100644 --- a/protocol/lib/context.go +++ b/protocol/lib/context.go @@ -9,6 +9,13 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/lib/log" ) +// Custom exec modes +const ( + ExecModeBeginBlock = 100 + ExecModeEndBlock = 101 + ExecModePrepareCheckState = 102 +) + type TxHash string func GetTxHash(tx []byte) TxHash { diff --git a/protocol/mocks/ClobKeeper.go b/protocol/mocks/ClobKeeper.go index 2f2704b71f..6ffb5e4ffb 100644 --- a/protocol/mocks/ClobKeeper.go +++ b/protocol/mocks/ClobKeeper.go @@ -522,6 +522,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) @@ -858,6 +863,11 @@ func (_m *ClobKeeper) RemoveOrderFillAmount(ctx types.Context, orderId clobtypes _m.Called(ctx, orderId) } +// SendOrderbookUpdates provides a mock function with given fields: ctx, offchainUpdates, snapshot +func (_m *ClobKeeper) SendOrderbookUpdates(ctx types.Context, offchainUpdates *clobtypes.OffchainUpdates, snapshot bool) { + _m.Called(ctx, offchainUpdates, snapshot) +} + // SetLongTermOrderPlacement provides a mock function with given fields: ctx, order, blockHeight func (_m *ClobKeeper) SetLongTermOrderPlacement(ctx types.Context, order clobtypes.Order, blockHeight uint32) { _m.Called(ctx, order, blockHeight) diff --git a/protocol/mocks/MemClob.go b/protocol/mocks/MemClob.go index 48da388ea0..7313f46942 100644 --- a/protocol/mocks/MemClob.go +++ b/protocol/mocks/MemClob.go @@ -153,6 +153,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) @@ -259,6 +275,66 @@ func (_m *MemClob) GetOrderRemainingAmount(ctx types.Context, order clobtypes.Or return r0, r1 } +// GetOrderbookUpdatesForOrderPlacement provides a mock function with given fields: ctx, order +func (_m *MemClob) GetOrderbookUpdatesForOrderPlacement(ctx types.Context, order clobtypes.Order) *clobtypes.OffchainUpdates { + ret := _m.Called(ctx, order) + + if len(ret) == 0 { + panic("no return value specified for GetOrderbookUpdatesForOrderPlacement") + } + + var r0 *clobtypes.OffchainUpdates + if rf, ok := ret.Get(0).(func(types.Context, clobtypes.Order) *clobtypes.OffchainUpdates); ok { + r0 = rf(ctx, order) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*clobtypes.OffchainUpdates) + } + } + + return r0 +} + +// GetOrderbookUpdatesForOrderRemoval provides a mock function with given fields: ctx, orderId +func (_m *MemClob) GetOrderbookUpdatesForOrderRemoval(ctx types.Context, orderId clobtypes.OrderId) *clobtypes.OffchainUpdates { + ret := _m.Called(ctx, orderId) + + if len(ret) == 0 { + panic("no return value specified for GetOrderbookUpdatesForOrderRemoval") + } + + var r0 *clobtypes.OffchainUpdates + if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) *clobtypes.OffchainUpdates); ok { + r0 = rf(ctx, orderId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*clobtypes.OffchainUpdates) + } + } + + return r0 +} + +// GetOrderbookUpdatesForOrderUpdate provides a mock function with given fields: ctx, orderId +func (_m *MemClob) GetOrderbookUpdatesForOrderUpdate(ctx types.Context, orderId clobtypes.OrderId) *clobtypes.OffchainUpdates { + ret := _m.Called(ctx, orderId) + + if len(ret) == 0 { + panic("no return value specified for GetOrderbookUpdatesForOrderUpdate") + } + + var r0 *clobtypes.OffchainUpdates + if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) *clobtypes.OffchainUpdates); ok { + r0 = rf(ctx, orderId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*clobtypes.OffchainUpdates) + } + } + + return r0 +} + // GetPricePremium provides a mock function with given fields: ctx, clobPair, params func (_m *MemClob) GetPricePremium(ctx types.Context, clobPair clobtypes.ClobPair, params perpetualstypes.GetPricePremiumParams) (int32, error) { ret := _m.Called(ctx, clobPair, params) diff --git a/protocol/mocks/MemClobKeeper.go b/protocol/mocks/MemClobKeeper.go index 43666914f1..2952491da6 100644 --- a/protocol/mocks/MemClobKeeper.go +++ b/protocol/mocks/MemClobKeeper.go @@ -382,6 +382,11 @@ func (_m *MemClobKeeper) ReplayPlaceOrder(ctx types.Context, msg *clobtypes.MsgP return r0, r1, r2, r3 } +// SendOrderbookUpdates provides a mock function with given fields: ctx, offchainUpdates, snapshot +func (_m *MemClobKeeper) SendOrderbookUpdates(ctx types.Context, offchainUpdates *clobtypes.OffchainUpdates, snapshot bool) { + _m.Called(ctx, offchainUpdates, snapshot) +} + // SetLongTermOrderPlacement provides a mock function with given fields: ctx, order, blockHeight func (_m *MemClobKeeper) SetLongTermOrderPlacement(ctx types.Context, order clobtypes.Order, blockHeight uint32) { _m.Called(ctx, order, blockHeight) diff --git a/protocol/mocks/QueryClient.go b/protocol/mocks/QueryClient.go index 43e03db14e..bd9c3832e8 100644 --- a/protocol/mocks/QueryClient.go +++ b/protocol/mocks/QueryClient.go @@ -756,6 +756,39 @@ 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 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *clobtypes.StreamOrderbookUpdatesRequest, ...grpc.CallOption) (clobtypes.Query_StreamOrderbookUpdatesClient, error)); ok { + return rf(ctx, in, opts...) + } + 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) + } + } + + 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..7cc9beea23 --- /dev/null +++ b/protocol/streaming/grpc/grpc_streaming_manager.go @@ -0,0 +1,168 @@ +package grpc + +import ( + "sync" + + sdk "github.com/cosmos/cosmos-sdk/types" + "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, + blockHeight uint32, + execMode sdk.ExecMode, +) { + // 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 { + updatesToSend := make([]ocutypes.OffChainUpdateV1, 0) + for _, clobPairId := range subscription.clobPairIds { + if updates, ok := v1updates[clobPairId]; ok { + updatesToSend = append(updatesToSend, updates...) + } + } + + if len(updatesToSend) > 0 { + if err := subscription.srv.Send( + &clobtypes.StreamOrderbookUpdatesResponse{ + Updates: updatesToSend, + Snapshot: snapshot, + BlockHeight: blockHeight, + ExecMode: uint32(execMode), + }, + ); err != nil { + idsToRemove = append(idsToRemove, id) + } + } + } + + // 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..3de85deaec --- /dev/null +++ b/protocol/streaming/grpc/noop_streaming_manager.go @@ -0,0 +1,40 @@ +package grpc + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "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, + blockHeight uint32, + execMode sdk.ExecMode, +) { +} + +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..5d0d9f1ab4 --- /dev/null +++ b/protocol/streaming/grpc/types/manager.go @@ -0,0 +1,25 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + 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, + blockHeight uint32, + execMode sdk.ExecMode, + ) +} diff --git a/protocol/testing/e2e/gov/wind_down_market_test.go b/protocol/testing/e2e/gov/wind_down_market_test.go index ad8ba132b0..b994383b2b 100644 --- a/protocol/testing/e2e/gov/wind_down_market_test.go +++ b/protocol/testing/e2e/gov/wind_down_market_test.go @@ -13,7 +13,7 @@ import ( indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" "github.com/dydxprotocol/v4-chain/protocol/indexer/indexer_manager" "github.com/dydxprotocol/v4-chain/protocol/indexer/msgsender" - 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" testapp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" diff --git a/protocol/testutil/keeper/clob.go b/protocol/testutil/keeper/clob.go index 30db24e498..506ebe114a 100644 --- a/protocol/testutil/keeper/clob.go +++ b/protocol/testutil/keeper/clob.go @@ -14,6 +14,7 @@ import ( "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" @@ -214,6 +215,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/keeper.go b/protocol/testutil/memclob/keeper.go index 14cbe16807..1c22339c21 100644 --- a/protocol/testutil/memclob/keeper.go +++ b/protocol/testutil/memclob/keeper.go @@ -503,3 +503,10 @@ func (f *FakeMemClobKeeper) ValidateSubaccountEquityTierLimitForNewOrder(ctx sdk func (f *FakeMemClobKeeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger() } + +func (f *FakeMemClobKeeper) SendOrderbookUpdates( + ctx sdk.Context, + offchainUpdates *types.OffchainUpdates, + snapshot bool, +) { +} diff --git a/protocol/testutil/memclob/offchain_updates.go b/protocol/testutil/memclob/offchain_updates.go index dde67044a9..59dd35fc33 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, 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 51b5e246a1..da97274adf 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/log" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" @@ -166,6 +166,37 @@ func PrepareCheckState( offchainUpdates, ) + // For orders that are filled in the last block, send an orderbook update to the grpc streams. + if keeper.GetGrpcStreamingManager().Enabled() { + allUpdates := types.NewOffchainUpdates() + orderIdsToSend := make(map[types.OrderId]bool) + + // Send an update for reverted local operations. + for _, operation := range localValidatorOperationsQueue { + if match := operation.GetMatch(); match != nil { + orderIdsToSend[match.GetMatchOrders().TakerOrderId] = true + + for _, fill := range match.GetMatchOrders().Fills { + orderIdsToSend[fill.MakerOrderId] = true + } + } + } + + // Send an update for orders that were proposed. + for _, orderId := range processProposerMatchesEvents.OrderIdsFilledInLastBlock { + orderIdsToSend[orderId] = true + } + + // Send update. + for orderId := range orderIdsToSend { + if _, exists := keeper.MemClob.GetOrder(ctx, orderId); exists { + orderbookUpdate := keeper.MemClob.GetOrderbookUpdatesForOrderUpdate(ctx, orderId) + allUpdates.Append(orderbookUpdate) + } + } + keeper.SendOrderbookUpdates(ctx, allUpdates, false) + } + // 3. Place all stateful order placements included in the last block on the memclob. // Note telemetry is measured outside of the function call because `PlaceStatefulOrdersFromLastBlock` // is called within `PlaceConditionalOrdersTriggeredInLastBlock`. @@ -245,6 +276,9 @@ func PrepareCheckState( types.GetInternalOperationsQueueTextString(newLocalValidatorOperationsQueue), ) + // 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 9b84c07154..6219afdd54 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 3c182d9ba4..87c69356b7 100644 --- a/protocol/x/clob/keeper/clob_pair_test.go +++ b/protocol/x/clob/keeper/clob_pair_test.go @@ -2,13 +2,14 @@ package keeper_test import ( "fmt" - "github.com/dydxprotocol/v4-chain/protocol/app/module" "strconv" "testing" + "github.com/dydxprotocol/v4-chain/protocol/app/module" + 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" "cosmossdk.io/store/prefix" diff --git a/protocol/x/clob/keeper/final_settlement.go b/protocol/x/clob/keeper/final_settlement.go index dd0a4420e7..a553985cac 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/lib/log" "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 e79827f1f1..7d0dd63de2 100644 --- a/protocol/x/clob/keeper/keeper.go +++ b/protocol/x/clob/keeper/keeper.go @@ -14,6 +14,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" flags "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/x/clob/types" @@ -31,16 +32,18 @@ type ( UntriggeredConditionalOrders map[types.ClobPairId]*UntriggeredConditionalOrders PerpetualIdToClobPairId map[uint32][]types.ClobPairId - subaccountsKeeper types.SubaccountsKeeper - assetsKeeper types.AssetsKeeper - bankKeeper types.BankKeeper - blockTimeKeeper types.BlockTimeKeeper - feeTiersKeeper types.FeeTiersKeeper - perpetualsKeeper types.PerpetualsKeeper - pricesKeeper types.PricesKeeper - statsKeeper types.StatsKeeper - rewardsKeeper types.RewardsKeeper + subaccountsKeeper types.SubaccountsKeeper + assetsKeeper types.AssetsKeeper + bankKeeper types.BankKeeper + blockTimeKeeper types.BlockTimeKeeper + feeTiersKeeper types.FeeTiersKeeper + perpetualsKeeper types.PerpetualsKeeper + pricesKeeper types.PricesKeeper + statsKeeper types.StatsKeeper + rewardsKeeper types.RewardsKeeper + indexerEventManager indexer_manager.IndexerEventManager + streamingManager streamingtypes.GrpcStreamingManager memStoreInitialized *atomic.Bool @@ -82,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 +111,7 @@ func NewKeeper( statsKeeper: statsKeeper, rewardsKeeper: rewardsKeeper, indexerEventManager: indexerEventManager, + streamingManager: grpcStreamingManager, memStoreInitialized: &atomic.Bool{}, txDecoder: txDecoder, mevTelemetryConfig: MevTelemetryConfig{ @@ -136,6 +141,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( log.ModuleKey, "x/clob", @@ -210,3 +219,40 @@ 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) + } + + k.SendOrderbookUpdates(ctx, allUpdates, true) +} + +// SendOrderbookUpdates sends the offchain updates to the gRPC streaming manager. +func (k Keeper) SendOrderbookUpdates( + ctx sdk.Context, + offchainUpdates *types.OffchainUpdates, + snapshot bool, +) { + if len(offchainUpdates.Messages) == 0 { + return + } + + k.GetGrpcStreamingManager().SendOrderbookUpdates( + offchainUpdates, + snapshot, + lib.MustConvertIntegerToUint32(ctx.BlockHeight()), + ctx.ExecMode(), + ) +} diff --git a/protocol/x/clob/keeper/msg_server_cancel_orders.go b/protocol/x/clob/keeper/msg_server_cancel_orders.go index 343e38894b..6765da2945 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" "github.com/dydxprotocol/v4-chain/protocol/lib/log" "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 e74daa2d0c..ecbef5b8a0 100644 --- a/protocol/x/clob/keeper/msg_server_cancel_orders_test.go +++ b/protocol/x/clob/keeper/msg_server_cancel_orders_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/dydxprotocol/v4-chain/protocol/mocks" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" diff --git a/protocol/x/clob/keeper/order_state.go b/protocol/x/clob/keeper/order_state.go index 814684e141..3df48b71fe 100644 --- a/protocol/x/clob/keeper/order_state.go +++ b/protocol/x/clob/keeper/order_state.go @@ -3,6 +3,7 @@ package keeper import ( "cosmossdk.io/store/prefix" 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/lib/log" "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" @@ -258,5 +259,27 @@ func (k Keeper) PruneStateFillAmountsForShortTermOrders( blockHeight := lib.MustConvertIntegerToUint32(ctx.BlockHeight()) // Prune all fill amounts from state which have a pruneable block height of the current `blockHeight`. - k.PruneOrdersForBlockHeight(ctx, blockHeight) + prunedOrderIds := k.PruneOrdersForBlockHeight(ctx, blockHeight) + + // Send an orderbook update for each pruned order for grpc streams. + // This is needed because short term orders are pruned in PrepareCheckState using + // keeper.MemClob.openOrders.blockExpirationsForOrders, which can fall out of sync with state fill amount + // pruning when there's replacement. + // Long-term fix would be to add logic to keep them in sync. + // TODO(CT-722): add logic to keep state fill amount pruning and order pruning in sync. + if k.GetGrpcStreamingManager().Enabled() { + allUpdates := types.NewOffchainUpdates() + for _, orderId := range prunedOrderIds { + if _, exists := k.MemClob.GetOrder(ctx, orderId); exists { + if message, success := off_chain_updates.CreateOrderUpdateMessage( + ctx, + orderId, + 0, // Total filled quantums is zero because it's been pruned from state. + ); success { + allUpdates.AddUpdateMessage(orderId, message) + } + } + } + k.SendOrderbookUpdates(ctx, allUpdates, false) + } } diff --git a/protocol/x/clob/keeper/orders.go b/protocol/x/clob/keeper/orders.go index 7760263a2d..48452c76bd 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/log" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" @@ -484,7 +485,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) diff --git a/protocol/x/clob/memclob/memclob.go b/protocol/x/clob/memclob/memclob.go index 3f6679cf26..87c1d3b652 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/log" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" @@ -45,6 +47,9 @@ type MemClobPriceTimePriority struct { // ---- Fields for determining if off-chain update messages should be generated ---- generateOffchainUpdates bool + + // ---- Fields for determining if orderbook updates should be generated ---- + generateOrderbookUpdates bool } type OrderWithRemovalReason struct { @@ -56,10 +61,11 @@ func NewMemClobPriceTimePriority( generateOffchainUpdates bool, ) *MemClobPriceTimePriority { return &MemClobPriceTimePriority{ - openOrders: newMemclobOpenOrders(), - cancels: newMemclobCancels(), - operationsToPropose: *types.NewOperationsToPropose(), - generateOffchainUpdates: generateOffchainUpdates, + openOrders: newMemclobOpenOrders(), + cancels: newMemclobCancels(), + operationsToPropose: *types.NewOperationsToPropose(), + generateOffchainUpdates: generateOffchainUpdates, + generateOrderbookUpdates: false, } } @@ -71,6 +77,11 @@ func (m *MemClobPriceTimePriority) SetClobKeeper(clobKeeper types.MemClobKeeper) m.clobKeeper = clobKeeper } +// SetGenerateOffchainUpdates sets the `generateOffchainUpdates` field of the MemClob. +func (m *MemClobPriceTimePriority) SetGenerateOrderbookUpdates(generateOrderbookUpdates bool) { + m.generateOrderbookUpdates = generateOrderbookUpdates +} + // CancelOrder removes a Short-Term order by `OrderId` (if it exists) from all order-related data structures // in the memclob. This method manages only Short-Term cancellations. For stateful cancellations, see // `msg_server_cancel_orders.go`. @@ -127,8 +138,8 @@ func (m *MemClobPriceTimePriority) CancelOrder( if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( 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) } @@ -463,8 +474,8 @@ func (m *MemClobPriceTimePriority) PlaceOrder( if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( 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) } @@ -515,7 +526,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) } @@ -537,7 +548,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) } @@ -584,7 +595,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) } @@ -619,7 +630,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) } @@ -791,7 +802,7 @@ func (m *MemClobPriceTimePriority) matchOrder( branchedContext, 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) } @@ -1116,8 +1127,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) } @@ -1266,8 +1277,8 @@ func (m *MemClobPriceTimePriority) PurgeInvalidMemclobState( if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( 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) } @@ -1285,8 +1296,8 @@ func (m *MemClobPriceTimePriority) PurgeInvalidMemclobState( if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( 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) } @@ -1508,6 +1519,12 @@ func (m *MemClobPriceTimePriority) mustAddOrderToOrderbook( } m.openOrders.mustAddOrderToOrderbook(ctx, newOrder, forceToFrontOfLevel) + + if m.generateOrderbookUpdates { + // Send an orderbook update to grpc streams. + orderbookUpdate := m.GetOrderbookUpdatesForOrderPlacement(ctx, newOrder) + m.clobKeeper.SendOrderbookUpdates(ctx, orderbookUpdate, false) + } } // mustPerformTakerOrderMatching performs matching using the provided taker order while the order @@ -1942,6 +1959,12 @@ func (m *MemClobPriceTimePriority) mustRemoveOrder( !m.operationsToPropose.IsOrderPlacementInOperationsQueue(order) { m.operationsToPropose.RemoveShortTermOrderTxBytes(order) } + + if m.generateOrderbookUpdates { + // Send an orderbook update to grpc streams. + orderbookUpdate := m.GetOrderbookUpdatesForOrderRemoval(ctx, order.OrderId) + m.clobKeeper.SendOrderbookUpdates(ctx, orderbookUpdate, false) + } } // mustUpdateOrderbookStateWithMatchedMakerOrder updates the orderbook with a matched maker order. @@ -1959,6 +1982,12 @@ func (m *MemClobPriceTimePriority) mustUpdateOrderbookStateWithMatchedMakerOrder panic("Total filled size of maker order greater than the order size") } + // Send an orderbook update for the order's new total filled amount. + if m.generateOrderbookUpdates { + orderbookUpdate := m.GetOrderbookUpdatesForOrderUpdate(ctx, makerOrder.OrderId) + m.clobKeeper.SendOrderbookUpdates(ctx, orderbookUpdate, false) + } + // If the order is fully filled, remove it from the orderbook. // Note we shouldn't remove Short-Term order hashes from `ShortTermOrderTxBytes` here since // the order was matched. @@ -2099,8 +2128,8 @@ func (m *MemClobPriceTimePriority) maybeCancelReduceOnlyOrders( if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( 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..4bce8ec772 --- /dev/null +++ b/protocol/x/clob/memclob/memclob_grpc_streaming.go @@ -0,0 +1,130 @@ +package memclob + +import ( + 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" + indexersharedtypes "github.com/dydxprotocol/v4-chain/protocol/indexer/shared/types" + "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.GetOrderbookUpdatesForOrderPlacement(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.GetOrderbookUpdatesForOrderPlacement(ctx, order.Order), + ) + }, + ) + } + } + + return offchainUpdates +} + +// GetOrderbookUpdatesForOrderPlacement returns a place order offchain message and +// a update order offchain message used to add an order for +// the orderbook grpc stream. +func (m *MemClobPriceTimePriority) GetOrderbookUpdatesForOrderPlacement( + 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( + 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( + ctx, + orderId, + fillAmount, + ); success { + offchainUpdates.AddUpdateMessage(orderId, message) + } + + return offchainUpdates +} + +// GetOrderbookUpdatesForOrderRemoval returns a remove order offchain message +// used to remove an order for the orderbook grpc stream. +func (m *MemClobPriceTimePriority) GetOrderbookUpdatesForOrderRemoval( + ctx sdk.Context, + orderId types.OrderId, +) (offchainUpdates *types.OffchainUpdates) { + offchainUpdates = types.NewOffchainUpdates() + if message, success := off_chain_updates.CreateOrderRemoveMessageWithReason( + ctx, + orderId, + indexersharedtypes.OrderRemovalReason_ORDER_REMOVAL_REASON_UNSPECIFIED, + ocutypes.OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED, + ); success { + offchainUpdates.AddRemoveMessage(orderId, message) + } + return offchainUpdates +} + +// GetOrderbookUpdatesForOrderUpdate returns an update order offchain message +// used to update an order for the orderbook grpc stream. +func (m *MemClobPriceTimePriority) GetOrderbookUpdatesForOrderUpdate( + ctx sdk.Context, + orderId types.OrderId, +) (offchainUpdates *types.OffchainUpdates) { + offchainUpdates = types.NewOffchainUpdates() + + // 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( + 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..5a865b25f9 --- /dev/null +++ b/protocol/x/clob/memclob/memclob_grpc_streaming_test.go @@ -0,0 +1,93 @@ +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("SendOrderbookUpdates", mock.Anything, mock.Anything).Return() + + 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.GetOrderbookUpdatesForOrderPlacement(ctx, orders[2])) + expected.Append(memclob.GetOrderbookUpdatesForOrderPlacement(ctx, orders[0])) + expected.Append(memclob.GetOrderbookUpdatesForOrderPlacement(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("SendOrderbookUpdates", mock.Anything, mock.Anything).Return() + + 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.GetOrderbookUpdatesForOrderPlacement(ctx, orders[1])) + expected.Append(memclob.GetOrderbookUpdatesForOrderPlacement(ctx, orders[2])) + expected.Append(memclob.GetOrderbookUpdatesForOrderPlacement(ctx, orders[0])) + + require.Equal(t, expected, offchainUpdates) +} diff --git a/protocol/x/clob/memclob/memclob_purge_invalid_memclob_state_test.go b/protocol/x/clob/memclob/memclob_purge_invalid_memclob_state_test.go index 2f6e78a68e..b15df32321 100644 --- a/protocol/x/clob/memclob/memclob_purge_invalid_memclob_state_test.go +++ b/protocol/x/clob/memclob/memclob_purge_invalid_memclob_state_test.go @@ -249,10 +249,11 @@ func TestPurgeInvalidMemclobState(t *testing.T) { // Setup memclob state. ctx, _, _ := sdktest.NewSdkContextWithMultistore() ctx = ctx.WithIsCheckTx(true) - mockMemClobKeeper := &mocks.MemClobKeeper{} memclob := NewMemClobPriceTimePriority(true) + mockMemClobKeeper := &mocks.MemClobKeeper{} memclob.SetClobKeeper(mockMemClobKeeper) mockMemClobKeeper.On("Logger", mock.Anything).Return(log.NewNopLogger()).Maybe() + mockMemClobKeeper.On("SendOrderbookUpdates", mock.Anything, mock.Anything).Return().Maybe() for _, operation := range tc.placedOperations { switch operation.Operation.(type) { @@ -339,6 +340,10 @@ func TestPurgeInvalidMemclobState_PanicsWhenCalledWithDuplicateCanceledStatefulO ctx, _, _ := sdktest.NewSdkContextWithMultistore() ctx = ctx.WithIsCheckTx(true) memclob := NewMemClobPriceTimePriority(true) + mockMemClobKeeper := &mocks.MemClobKeeper{} + memclob.SetClobKeeper(mockMemClobKeeper) + mockMemClobKeeper.On("SendOrderbookUpdates", mock.Anything, mock.Anything).Return().Maybe() + canceledStatefulOrderIds := []types.OrderId{ constants.LongTermOrder_Alice_Num0_Id0_Clob0_Buy5_Price10_GTBT15.OrderId, constants.LongTermOrder_Alice_Num0_Id0_Clob0_Buy5_Price10_GTBT15.OrderId, @@ -368,6 +373,10 @@ func TestPurgeInvalidMemclobState_PanicsWhenNonStatefulOrderIsCanceled(t *testin ctx, _, _ := sdktest.NewSdkContextWithMultistore() ctx = ctx.WithIsCheckTx(true) memclob := NewMemClobPriceTimePriority(true) + mockMemClobKeeper := &mocks.MemClobKeeper{} + memclob.SetClobKeeper(mockMemClobKeeper) + mockMemClobKeeper.On("SendOrderbookUpdates", mock.Anything, mock.Anything).Return().Maybe() + shortTermOrderId := constants.Order_Alice_Num0_Id0_Clob2_Buy5_Price10_GTB15.OrderId require.PanicsWithValue( @@ -395,6 +404,10 @@ func TestPurgeInvalidMemclobState_PanicsWhenCalledWithDuplicateExpiredStatefulOr ctx = ctx.WithIsCheckTx(true) memclob := NewMemClobPriceTimePriority(true) + mockMemClobKeeper := &mocks.MemClobKeeper{} + memclob.SetClobKeeper(mockMemClobKeeper) + mockMemClobKeeper.On("SendOrderbookUpdates", mock.Anything, mock.Anything).Return().Maybe() + expiredStatefulOrderIds := []types.OrderId{ constants.LongTermOrder_Alice_Num0_Id0_Clob0_Buy5_Price10_GTBT15.OrderId, constants.LongTermOrder_Alice_Num0_Id0_Clob0_Buy5_Price10_GTBT15.OrderId, @@ -425,6 +438,10 @@ func TestPurgeInvalidMemclobState_PanicsWhenCalledWithShortTermExpiredStatefulOr ctx = ctx.WithIsCheckTx(true) memclob := NewMemClobPriceTimePriority(true) + mockMemClobKeeper := &mocks.MemClobKeeper{} + memclob.SetClobKeeper(mockMemClobKeeper) + mockMemClobKeeper.On("SendOrderbookUpdates", mock.Anything, mock.Anything).Return().Maybe() + shortTermOrderId := constants.Order_Alice_Num0_Id0_Clob2_Buy5_Price10_GTB15.OrderId require.PanicsWithValue( diff --git a/protocol/x/clob/memclob/memclob_remove_order_test.go b/protocol/x/clob/memclob/memclob_remove_order_test.go index 7d3aa4e0b9..15c1d88803 100644 --- a/protocol/x/clob/memclob/memclob_remove_order_test.go +++ b/protocol/x/clob/memclob/memclob_remove_order_test.go @@ -330,6 +330,7 @@ func TestRemoveOrderIfFilled(t *testing.T) { memClobKeeper.On("AddOrderToOrderbookCollatCheck", mock.Anything, mock.Anything, mock.Anything). Return(true, make(map[satypes.SubaccountId]satypes.UpdateResult)) memClobKeeper.On("ValidateSubaccountEquityTierLimitForNewOrder", mock.Anything, mock.Anything).Return(nil) + memClobKeeper.On("SendOrderbookUpdates", mock.Anything, mock.Anything).Return().Maybe() // Set initial fill amount to `0` for all orders. initialCall := memClobKeeper.On("GetOrderFillAmount", mock.Anything, mock.Anything). diff --git a/protocol/x/clob/memclob/memclob_test_util.go b/protocol/x/clob/memclob/memclob_test_util.go index 57c8ff1696..c06041029a 100644 --- a/protocol/x/clob/memclob/memclob_test_util.go +++ b/protocol/x/clob/memclob/memclob_test_util.go @@ -10,7 +10,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" @@ -1326,7 +1327,7 @@ func assertPlaceOrderOffchainMessages( ctx, 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, @@ -1355,7 +1356,7 @@ func assertPlaceOrderOffchainMessages( ctx, 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. @@ -1384,7 +1385,7 @@ func assertPlaceOrderOffchainMessages( ctx, 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( @@ -1442,7 +1443,7 @@ func assertPlaceOrderOffchainMessages( ctx, 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, @@ -1475,7 +1476,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, @@ -1541,7 +1542,7 @@ func getExpectedPlacePerpetualLiquidationOffchainMessages( ctx, 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( @@ -1556,7 +1557,7 @@ func getExpectedPlacePerpetualLiquidationOffchainMessages( ctx, 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 ccac1d061f..f0724251a7 100644 --- a/protocol/x/clob/types/clob_keeper.go +++ b/protocol/x/clob/types/clob_keeper.go @@ -127,4 +127,11 @@ type ClobKeeper interface { clobPair ClobPair, ) error UpdateLiquidationsConfig(ctx sdk.Context, config LiquidationsConfig) error + // Gprc streaming + InitializeNewGrpcStreams(ctx sdk.Context) + SendOrderbookUpdates( + ctx sdk.Context, + offchainUpdates *OffchainUpdates, + snapshot bool, + ) } diff --git a/protocol/x/clob/types/errors.go b/protocol/x/clob/types/errors.go index 5f2ec04f12..2d104c7479 100644 --- a/protocol/x/clob/types/errors.go +++ b/protocol/x/clob/types/errors.go @@ -513,4 +513,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/mem_clob_keeper.go b/protocol/x/clob/types/mem_clob_keeper.go index 0f265c42f4..48195776ee 100644 --- a/protocol/x/clob/types/mem_clob_keeper.go +++ b/protocol/x/clob/types/mem_clob_keeper.go @@ -111,4 +111,9 @@ type MemClobKeeper interface { Logger( ctx sdk.Context, ) log.Logger + SendOrderbookUpdates( + ctx sdk.Context, + offchainUpdates *OffchainUpdates, + snapshot bool, + ) } diff --git a/protocol/x/clob/types/memclob.go b/protocol/x/clob/types/memclob.go index d80d5b1345..3196320e39 100644 --- a/protocol/x/clob/types/memclob.go +++ b/protocol/x/clob/types/memclob.go @@ -133,4 +133,20 @@ type MemClob interface { subaccountId satypes.SubaccountId, perpetualId uint32, ) + GetOffchainUpdatesForOrderbookSnapshot( + ctx sdk.Context, + clobPairId ClobPairId, + ) (offchainUpdates *OffchainUpdates) + GetOrderbookUpdatesForOrderPlacement( + ctx sdk.Context, + order Order, + ) (offchainUpdates *OffchainUpdates) + GetOrderbookUpdatesForOrderRemoval( + ctx sdk.Context, + orderId OrderId, + ) (offchainUpdates *OffchainUpdates) + GetOrderbookUpdatesForOrderUpdate( + ctx sdk.Context, + orderId OrderId, + ) (offchainUpdates *OffchainUpdates) } diff --git a/protocol/x/clob/types/query.pb.go b/protocol/x/clob/types/query.pb.go index 78f490f800..ee500746b5 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,131 @@ 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"` + // ---Additional fields used to debug issues--- + // Block height of the updates. + BlockHeight uint32 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // Exec mode of the updates. + ExecMode uint32 `protobuf:"varint,4,opt,name=exec_mode,json=execMode,proto3" json:"exec_mode,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 (m *StreamOrderbookUpdatesResponse) GetBlockHeight() uint32 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *StreamOrderbookUpdatesResponse) GetExecMode() uint32 { + if m != nil { + return m.ExecMode + } + return 0 +} + func init() { proto.RegisterType((*QueryGetClobPairRequest)(nil), "dydxprotocol.clob.QueryGetClobPairRequest") proto.RegisterType((*QueryClobPairResponse)(nil), "dydxprotocol.clob.QueryClobPairResponse") @@ -667,72 +793,84 @@ 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 - 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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xe9, 0x44, 0x77, 0xaa, 0xaa, 0x76, - 0x06, 0x6f, 0x69, 0xbd, 0x37, 0x5d, 0xb0, 0xd6, 0xb5, 0xaa, 0x74, 0x75, 0x50, 0x1b, 0xd7, 0x7e, - 0xa7, 0xa0, 0x5f, 0x01, 0x5c, 0xac, 0x39, 0x9a, 0x68, 0xab, 0x8a, 0xc5, 0x64, 0x53, 0x69, 0xdd, - 0x99, 0x2a, 0x56, 0x0b, 0x58, 0x51, 0x02, 0x96, 0xd1, 0xb5, 0xda, 0x8f, 0x37, 0xf4, 0x3b, 0x80, - 0xaf, 0x55, 0x1e, 0x78, 0xf4, 0x4e, 0x15, 0x83, 0x49, 0x6e, 0xd2, 0x7a, 0x77, 0x8a, 0x48, 0xcd, - 0xdc, 0x54, 0xcc, 0xbb, 0x68, 0x15, 0x9f, 0xe9, 0x83, 0x6f, 0xa7, 0xf7, 0xf8, 0xb8, 0x0d, 0x9e, - 0x1c, 0xb7, 0xc1, 0xbf, 0xc7, 0x6d, 0xf0, 0xfd, 0x49, 0x7b, 0xe6, 0xc9, 0x49, 0x7b, 0xe6, 0xaf, - 0x93, 0xf6, 0xcc, 0x67, 0x6f, 0x7b, 0x4c, 0x1e, 0xc4, 0x7d, 0xd3, 0x11, 0xfe, 0x78, 0xae, 0xe4, - 0xf6, 0x9b, 0xce, 0x01, 0x61, 0x01, 0x1e, 0xad, 0x3c, 0xca, 0xf2, 0xcb, 0xa3, 0x01, 0x8d, 0xfa, - 0x17, 0xd5, 0xf2, 0xad, 0xa7, 0x01, 0x00, 0x00, 0xff, 0xff, 0x75, 0xf9, 0x20, 0xb1, 0x8a, 0x0b, - 0x00, 0x00, + // 1112 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcd, 0x4f, 0x24, 0x45, + 0x14, 0xa7, 0x00, 0x77, 0xe1, 0xb1, 0x6b, 0xb4, 0x58, 0xd8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 0x7f, 0x47, 0x30, 0x59, 0xa4, 0x5c, 0xf8, + 0x5e, 0x5e, 0xd5, 0xce, 0xa1, 0xbb, 0xe5, 0xb7, 0x2e, 0xe7, 0xac, 0xf2, 0x9a, 0x97, 0x79, 0xcd, + 0xe0, 0x8a, 0x51, 0x78, 0x07, 0xc4, 0xbf, 0x20, 0x98, 0x28, 0x90, 0x2d, 0xbc, 0x9e, 0xc7, 0xa2, + 0xb7, 0xe0, 0x96, 0xef, 0x5d, 0xca, 0x57, 0x25, 0x30, 0x27, 0x13, 0x98, 0xc6, 0x53, 0x85, 0x17, + 0x63, 0xfc, 0x1b, 0x82, 0x57, 0x72, 0xc5, 0x10, 0xdf, 0xcd, 0x63, 0xd0, 0x4b, 0x69, 0xcb, 0x6f, + 0x5e, 0xc2, 0x53, 0x31, 0xd7, 0x25, 0xf3, 0x45, 0x3c, 0x6f, 0x9c, 0xeb, 0x32, 0x8d, 0xbf, 0x84, + 0xf1, 0x6c, 0x1d, 0xc4, 0x2b, 0x19, 0x24, 0x0a, 0x65, 0xb7, 0xbc, 0x7a, 0x01, 0x8f, 0x84, 0xee, + 0x0a, 0xda, 0xdc, 0x7d, 0x72, 0x52, 0x41, 0x4f, 0x4f, 0x2a, 0xe8, 0xdf, 0x93, 0x0a, 0xfa, 0xee, + 0xb4, 0xd2, 0xf7, 0xf4, 0xb4, 0xd2, 0xf7, 0xd7, 0x69, 0xa5, 0xef, 0xd3, 0x37, 0x6a, 0x4c, 0xd4, + 0x9b, 0x55, 0xdd, 0xe6, 0x5e, 0x77, 0x32, 0xd1, 0x9d, 0xd7, 0xa5, 0xe0, 0x1a, 0x6d, 0xcb, 0x51, + 0x92, 0xa0, 0x38, 0x6e, 0xd0, 0xb0, 0x7a, 0x45, 0x9a, 0x6f, 0x3f, 0x0b, 0x00, 0x00, 0xff, 0xff, + 0xf1, 0xed, 0x1e, 0x02, 0x67, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -759,6 +897,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 +963,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 +1009,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 +1035,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 +1151,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 +1201,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 +1647,104 @@ 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.ExecMode != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ExecMode)) + i-- + dAtA[i] = 0x20 + } + if m.BlockHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x18 + } + 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 +1921,46 @@ 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 + } + if m.BlockHeight != 0 { + n += 1 + sovQuery(uint64(m.BlockHeight)) + } + if m.ExecMode != 0 { + n += 1 + sovQuery(uint64(m.ExecMode)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2687,6 +3029,274 @@ 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) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecMode", wireType) + } + m.ExecMode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecMode |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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