Skip to content

Commit 58f503c

Browse files
authored
Revert "Full Node Streaming - reorder protobuf single length fields before variable length fields (backport #2227)" (#2347)
1 parent 18d44cf commit 58f503c

File tree

3 files changed

+299
-297
lines changed

3 files changed

+299
-297
lines changed

indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -293,71 +293,73 @@ export interface StreamOrderbookUpdatesResponseSDKType {
293293
*/
294294

295295
export interface StreamUpdate {
296+
orderbookUpdate?: StreamOrderbookUpdate;
297+
orderFill?: StreamOrderbookFill;
298+
takerOrder?: StreamTakerOrder;
299+
subaccountUpdate?: StreamSubaccountUpdate;
296300
/** Block height of the update. */
301+
297302
blockHeight: number;
298303
/** Exec mode of the update. */
299304

300305
execMode: number;
301-
orderbookUpdate?: StreamOrderbookUpdate;
302-
orderFill?: StreamOrderbookFill;
303-
takerOrder?: StreamTakerOrder;
304-
subaccountUpdate?: StreamSubaccountUpdate;
305306
}
306307
/**
307308
* StreamUpdate is an update that will be pushed through the
308309
* GRPC stream.
309310
*/
310311

311312
export interface StreamUpdateSDKType {
313+
orderbook_update?: StreamOrderbookUpdateSDKType;
314+
order_fill?: StreamOrderbookFillSDKType;
315+
taker_order?: StreamTakerOrderSDKType;
316+
subaccount_update?: StreamSubaccountUpdateSDKType;
312317
/** Block height of the update. */
318+
313319
block_height: number;
314320
/** Exec mode of the update. */
315321

316322
exec_mode: number;
317-
orderbook_update?: StreamOrderbookUpdateSDKType;
318-
order_fill?: StreamOrderbookFillSDKType;
319-
taker_order?: StreamTakerOrderSDKType;
320-
subaccount_update?: StreamSubaccountUpdateSDKType;
321323
}
322324
/**
323325
* StreamOrderbookUpdate provides information on an orderbook update. Used in
324326
* the full node GRPC stream.
325327
*/
326328

327329
export interface StreamOrderbookUpdate {
330+
/**
331+
* Orderbook updates for the clob pair. Can contain order place, removals,
332+
* or updates.
333+
*/
334+
updates: OffChainUpdateV1[];
328335
/**
329336
* Snapshot indicates if the response is from a snapshot of the orderbook.
330337
* All updates should be ignored until snapshot is recieved.
331338
* If the snapshot is true, then all previous entries should be
332339
* discarded and the orderbook should be resynced.
333340
*/
334-
snapshot: boolean;
335-
/**
336-
* Orderbook updates for the clob pair. Can contain order place, removals,
337-
* or updates.
338-
*/
339341

340-
updates: OffChainUpdateV1[];
342+
snapshot: boolean;
341343
}
342344
/**
343345
* StreamOrderbookUpdate provides information on an orderbook update. Used in
344346
* the full node GRPC stream.
345347
*/
346348

347349
export interface StreamOrderbookUpdateSDKType {
350+
/**
351+
* Orderbook updates for the clob pair. Can contain order place, removals,
352+
* or updates.
353+
*/
354+
updates: OffChainUpdateV1SDKType[];
348355
/**
349356
* Snapshot indicates if the response is from a snapshot of the orderbook.
350357
* All updates should be ignored until snapshot is recieved.
351358
* If the snapshot is true, then all previous entries should be
352359
* discarded and the orderbook should be resynced.
353360
*/
354-
snapshot: boolean;
355-
/**
356-
* Orderbook updates for the clob pair. Can contain order place, removals,
357-
* or updates.
358-
*/
359361

360-
updates: OffChainUpdateV1SDKType[];
362+
snapshot: boolean;
361363
}
362364
/**
363365
* StreamOrderbookFill provides information on an orderbook fill. Used in
@@ -1303,39 +1305,39 @@ export const StreamOrderbookUpdatesResponse = {
13031305

13041306
function createBaseStreamUpdate(): StreamUpdate {
13051307
return {
1306-
blockHeight: 0,
1307-
execMode: 0,
13081308
orderbookUpdate: undefined,
13091309
orderFill: undefined,
13101310
takerOrder: undefined,
1311-
subaccountUpdate: undefined
1311+
subaccountUpdate: undefined,
1312+
blockHeight: 0,
1313+
execMode: 0
13121314
};
13131315
}
13141316

13151317
export const StreamUpdate = {
13161318
encode(message: StreamUpdate, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
1317-
if (message.blockHeight !== 0) {
1318-
writer.uint32(8).uint32(message.blockHeight);
1319-
}
1320-
1321-
if (message.execMode !== 0) {
1322-
writer.uint32(16).uint32(message.execMode);
1323-
}
1324-
13251319
if (message.orderbookUpdate !== undefined) {
1326-
StreamOrderbookUpdate.encode(message.orderbookUpdate, writer.uint32(26).fork()).ldelim();
1320+
StreamOrderbookUpdate.encode(message.orderbookUpdate, writer.uint32(10).fork()).ldelim();
13271321
}
13281322

13291323
if (message.orderFill !== undefined) {
1330-
StreamOrderbookFill.encode(message.orderFill, writer.uint32(34).fork()).ldelim();
1324+
StreamOrderbookFill.encode(message.orderFill, writer.uint32(18).fork()).ldelim();
13311325
}
13321326

13331327
if (message.takerOrder !== undefined) {
1334-
StreamTakerOrder.encode(message.takerOrder, writer.uint32(42).fork()).ldelim();
1328+
StreamTakerOrder.encode(message.takerOrder, writer.uint32(26).fork()).ldelim();
13351329
}
13361330

13371331
if (message.subaccountUpdate !== undefined) {
1338-
StreamSubaccountUpdate.encode(message.subaccountUpdate, writer.uint32(50).fork()).ldelim();
1332+
StreamSubaccountUpdate.encode(message.subaccountUpdate, writer.uint32(34).fork()).ldelim();
1333+
}
1334+
1335+
if (message.blockHeight !== 0) {
1336+
writer.uint32(40).uint32(message.blockHeight);
1337+
}
1338+
1339+
if (message.execMode !== 0) {
1340+
writer.uint32(48).uint32(message.execMode);
13391341
}
13401342

13411343
return writer;
@@ -1351,27 +1353,27 @@ export const StreamUpdate = {
13511353

13521354
switch (tag >>> 3) {
13531355
case 1:
1354-
message.blockHeight = reader.uint32();
1356+
message.orderbookUpdate = StreamOrderbookUpdate.decode(reader, reader.uint32());
13551357
break;
13561358

13571359
case 2:
1358-
message.execMode = reader.uint32();
1360+
message.orderFill = StreamOrderbookFill.decode(reader, reader.uint32());
13591361
break;
13601362

13611363
case 3:
1362-
message.orderbookUpdate = StreamOrderbookUpdate.decode(reader, reader.uint32());
1364+
message.takerOrder = StreamTakerOrder.decode(reader, reader.uint32());
13631365
break;
13641366

13651367
case 4:
1366-
message.orderFill = StreamOrderbookFill.decode(reader, reader.uint32());
1368+
message.subaccountUpdate = StreamSubaccountUpdate.decode(reader, reader.uint32());
13671369
break;
13681370

13691371
case 5:
1370-
message.takerOrder = StreamTakerOrder.decode(reader, reader.uint32());
1372+
message.blockHeight = reader.uint32();
13711373
break;
13721374

13731375
case 6:
1374-
message.subaccountUpdate = StreamSubaccountUpdate.decode(reader, reader.uint32());
1376+
message.execMode = reader.uint32();
13751377
break;
13761378

13771379
default:
@@ -1385,32 +1387,32 @@ export const StreamUpdate = {
13851387

13861388
fromPartial(object: DeepPartial<StreamUpdate>): StreamUpdate {
13871389
const message = createBaseStreamUpdate();
1388-
message.blockHeight = object.blockHeight ?? 0;
1389-
message.execMode = object.execMode ?? 0;
13901390
message.orderbookUpdate = object.orderbookUpdate !== undefined && object.orderbookUpdate !== null ? StreamOrderbookUpdate.fromPartial(object.orderbookUpdate) : undefined;
13911391
message.orderFill = object.orderFill !== undefined && object.orderFill !== null ? StreamOrderbookFill.fromPartial(object.orderFill) : undefined;
13921392
message.takerOrder = object.takerOrder !== undefined && object.takerOrder !== null ? StreamTakerOrder.fromPartial(object.takerOrder) : undefined;
13931393
message.subaccountUpdate = object.subaccountUpdate !== undefined && object.subaccountUpdate !== null ? StreamSubaccountUpdate.fromPartial(object.subaccountUpdate) : undefined;
1394+
message.blockHeight = object.blockHeight ?? 0;
1395+
message.execMode = object.execMode ?? 0;
13941396
return message;
13951397
}
13961398

13971399
};
13981400

13991401
function createBaseStreamOrderbookUpdate(): StreamOrderbookUpdate {
14001402
return {
1401-
snapshot: false,
1402-
updates: []
1403+
updates: [],
1404+
snapshot: false
14031405
};
14041406
}
14051407

14061408
export const StreamOrderbookUpdate = {
14071409
encode(message: StreamOrderbookUpdate, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
1408-
if (message.snapshot === true) {
1409-
writer.uint32(8).bool(message.snapshot);
1410+
for (const v of message.updates) {
1411+
OffChainUpdateV1.encode(v!, writer.uint32(10).fork()).ldelim();
14101412
}
14111413

1412-
for (const v of message.updates) {
1413-
OffChainUpdateV1.encode(v!, writer.uint32(18).fork()).ldelim();
1414+
if (message.snapshot === true) {
1415+
writer.uint32(16).bool(message.snapshot);
14141416
}
14151417

14161418
return writer;
@@ -1426,11 +1428,11 @@ export const StreamOrderbookUpdate = {
14261428

14271429
switch (tag >>> 3) {
14281430
case 1:
1429-
message.snapshot = reader.bool();
1431+
message.updates.push(OffChainUpdateV1.decode(reader, reader.uint32()));
14301432
break;
14311433

14321434
case 2:
1433-
message.updates.push(OffChainUpdateV1.decode(reader, reader.uint32()));
1435+
message.snapshot = reader.bool();
14341436
break;
14351437

14361438
default:
@@ -1444,8 +1446,8 @@ export const StreamOrderbookUpdate = {
14441446

14451447
fromPartial(object: DeepPartial<StreamOrderbookUpdate>): StreamOrderbookUpdate {
14461448
const message = createBaseStreamOrderbookUpdate();
1447-
message.snapshot = object.snapshot ?? false;
14481449
message.updates = object.updates?.map(e => OffChainUpdateV1.fromPartial(e)) || [];
1450+
message.snapshot = object.snapshot ?? false;
14491451
return message;
14501452
}
14511453

proto/dydxprotocol/clob/query.proto

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,35 +182,35 @@ message StreamOrderbookUpdatesResponse {
182182
// StreamUpdate is an update that will be pushed through the
183183
// GRPC stream.
184184
message StreamUpdate {
185-
// Block height of the update.
186-
uint32 block_height = 1;
187-
188-
// Exec mode of the update.
189-
uint32 exec_mode = 2;
190-
191185
// Contains one of an StreamOrderbookUpdate,
192186
// StreamOrderbookFill, StreamTakerOrderStatus.
193187
oneof update_message {
194-
StreamOrderbookUpdate orderbook_update = 3;
195-
StreamOrderbookFill order_fill = 4;
196-
StreamTakerOrder taker_order = 5;
197-
dydxprotocol.subaccounts.StreamSubaccountUpdate subaccount_update = 6;
188+
StreamOrderbookUpdate orderbook_update = 1;
189+
StreamOrderbookFill order_fill = 2;
190+
StreamTakerOrder taker_order = 3;
191+
dydxprotocol.subaccounts.StreamSubaccountUpdate subaccount_update = 4;
198192
}
193+
194+
// Block height of the update.
195+
uint32 block_height = 5;
196+
197+
// Exec mode of the update.
198+
uint32 exec_mode = 6;
199199
}
200200

201201
// StreamOrderbookUpdate provides information on an orderbook update. Used in
202202
// the full node GRPC stream.
203203
message StreamOrderbookUpdate {
204+
// Orderbook updates for the clob pair. Can contain order place, removals,
205+
// or updates.
206+
repeated dydxprotocol.indexer.off_chain_updates.OffChainUpdateV1 updates = 1
207+
[ (gogoproto.nullable) = false ];
208+
204209
// Snapshot indicates if the response is from a snapshot of the orderbook.
205210
// All updates should be ignored until snapshot is recieved.
206211
// If the snapshot is true, then all previous entries should be
207212
// discarded and the orderbook should be resynced.
208-
bool snapshot = 1;
209-
210-
// Orderbook updates for the clob pair. Can contain order place, removals,
211-
// or updates.
212-
repeated dydxprotocol.indexer.off_chain_updates.OffChainUpdateV1 updates = 2
213-
[ (gogoproto.nullable) = false ];
213+
bool snapshot = 2;
214214
}
215215

216216
// StreamOrderbookFill provides information on an orderbook fill. Used in

0 commit comments

Comments
 (0)