From 72f17552cfb1b51f547b03456610e9d05bce0191 Mon Sep 17 00:00:00 2001 From: Vincent Chau <99756290+vincentwschau@users.noreply.github.com> Date: Fri, 7 Feb 2025 15:54:14 -0500 Subject: [PATCH 1/7] Debug socks. --- .github/workflows/indexer-build-and-push-dev-staging.yml | 1 + indexer/services/socks/src/lib/subscription.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/indexer-build-and-push-dev-staging.yml b/.github/workflows/indexer-build-and-push-dev-staging.yml index 5a98b72552e..ac01e06252f 100644 --- a/.github/workflows/indexer-build-and-push-dev-staging.yml +++ b/.github/workflows/indexer-build-and-push-dev-staging.yml @@ -6,6 +6,7 @@ on: # yamllint disable-line rule:truthy - main - 'release/indexer/v[0-9]+.[0-9]+.x' # e.g. release/indexer/v0.1.x - 'release/indexer/v[0-9]+.x' # e.g. release/indexer/v1.x + - 'vincentc/*' # TODO(DEC-837): Customize github build and push to ECR by service with paths jobs: diff --git a/indexer/services/socks/src/lib/subscription.ts b/indexer/services/socks/src/lib/subscription.ts index cdfa9ebdce0..8816b301354 100644 --- a/indexer/services/socks/src/lib/subscription.ts +++ b/indexer/services/socks/src/lib/subscription.ts @@ -608,6 +608,11 @@ export class Subscriptions { blockHeight, }); } catch (error) { + logger.error({ + at: 'getInitialResponseForSubaccountSubscription', + message: `Received error when subscribing ${id}`, + error, + }); // The subaccounts API endpoint returns a 404 for subaccounts that are not indexed, however // such subaccounts can be subscribed to and events can be sent when the subaccounts are // indexed to an existing subscription. From a27871fbcfda8b0b423dfe0359217909dcabc715 Mon Sep 17 00:00:00 2001 From: Vincent Chau <99756290+vincentwschau@users.noreply.github.com> Date: Fri, 7 Feb 2025 16:13:03 -0500 Subject: [PATCH 2/7] more logging. --- .../services/socks/src/lib/subscription.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/indexer/services/socks/src/lib/subscription.ts b/indexer/services/socks/src/lib/subscription.ts index 8816b301354..822690d863c 100644 --- a/indexer/services/socks/src/lib/subscription.ts +++ b/indexer/services/socks/src/lib/subscription.ts @@ -545,6 +545,11 @@ export class Subscriptions { throw new Error('Invalid undefined id'); } + logger.info({ + at: "getInitialResponseForSubaccountSubscription", + message: `Getting initial subaccount data for ${id}`, + }); + try { const { address, @@ -557,6 +562,12 @@ export class Subscriptions { const blockHeight: string = await blockHeightRefresher.getLatestBlockHeight(); const numBlockHeight: number = parseInt(blockHeight, 10); + logger.info({ + at: "getInitialResponseForSubaccountSubscription", + message: `Got initial block height ${numBlockHeight}`, + id, + }); + const [ subaccountsResponse, ordersResponse, @@ -596,12 +607,28 @@ export class Subscriptions { }), ]); + logger.info({ + at: "getInitialResponseForSubaccountSubscription", + message: `Got order responses`, + id, + subaccountsResponse, + ordersResponse, + currentBestEffortCanceledOrdersResponse, + }); + const orders: OrderFromDatabase[] = JSON.parse(ordersResponse); const currentBestEffortCanceledOrders: OrderFromDatabase[] = JSON.parse( currentBestEffortCanceledOrdersResponse, ); const allOrders: OrderFromDatabase[] = orders.concat(currentBestEffortCanceledOrders); + logger.info({ + at: "getInitialResponseForSubaccountScription", + message: `Concatenated orders`, + allOrders, + id, + }); + return JSON.stringify({ ...JSON.parse(subaccountsResponse), orders: allOrders, From e0a3d3dc81120985f5877c9468e12be6961c1fb2 Mon Sep 17 00:00:00 2001 From: Vincent Chau <99756290+vincentwschau@users.noreply.github.com> Date: Fri, 7 Feb 2025 17:17:30 -0500 Subject: [PATCH 3/7] Test more. --- .../socks/__tests__/lib/subscriptions.test.ts | 4 +- .../services/socks/src/lib/subscription.ts | 37 ++++++++++++++++--- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/indexer/services/socks/__tests__/lib/subscriptions.test.ts b/indexer/services/socks/__tests__/lib/subscriptions.test.ts index 02bf9ceea2d..83b6b9a0dcb 100644 --- a/indexer/services/socks/__tests__/lib/subscriptions.test.ts +++ b/indexer/services/socks/__tests__/lib/subscriptions.test.ts @@ -59,7 +59,7 @@ describe('Subscriptions', () => { [Channel.V4_ACCOUNTS]: [ '/v4/addresses/.+/subaccountNumber/.+', '/v4/orders?.+subaccountNumber.+OPEN,UNTRIGGERED,BEST_EFFORT_OPENED', - '/v4/orders?.+subaccountNumber.+BEST_EFFORT_CANCELED.+goodTilBlockAfter.+', + '/v4/orders?.+subaccountNumber.+BEST_EFFORT_CANCELED.+goodTilBlockAfter=[0-9]+', ], [Channel.V4_CANDLES]: ['/v4/candles/perpetualMarkets/.+?resolution=.+'], [Channel.V4_MARKETS]: ['/v4/perpetualMarkets'], @@ -68,7 +68,7 @@ describe('Subscriptions', () => { [Channel.V4_PARENT_ACCOUNTS]: [ '/v4/addresses/.+/parentSubaccountNumber/.+', '/v4/orders/parentSubaccountNumber?.+parentSubaccountNumber.+OPEN,UNTRIGGERED,BEST_EFFORT_OPENED', - '/v4/orders/parentSubaccountNumber?.+parentSubaccountNumber.+BEST_EFFORT_CANCELED.+goodTilBlockAfter.+', + '/v4/orders/parentSubaccountNumber?.+parentSubaccountNumber.+BEST_EFFORT_CANCELED.+goodTilBlockAfter=[0-9]+', ], [Channel.V4_BLOCK_HEIGHT]: ['v4/height'], }; diff --git a/indexer/services/socks/src/lib/subscription.ts b/indexer/services/socks/src/lib/subscription.ts index 822690d863c..4e821cab6c1 100644 --- a/indexer/services/socks/src/lib/subscription.ts +++ b/indexer/services/socks/src/lib/subscription.ts @@ -545,7 +545,7 @@ export class Subscriptions { throw new Error('Invalid undefined id'); } - logger.info({ + logger.error({ at: "getInitialResponseForSubaccountSubscription", message: `Getting initial subaccount data for ${id}`, }); @@ -562,7 +562,7 @@ export class Subscriptions { const blockHeight: string = await blockHeightRefresher.getLatestBlockHeight(); const numBlockHeight: number = parseInt(blockHeight, 10); - logger.info({ + logger.error({ at: "getInitialResponseForSubaccountSubscription", message: `Got initial block height ${numBlockHeight}`, id, @@ -598,7 +598,7 @@ export class Subscriptions { }), axiosRequest({ method: RequestMethod.GET, - url: `${COMLINK_URL}/v4/orders?address=${address}&subaccountNumber=${subaccountNumber}&status=BEST_EFFORT_CANCELED&goodTilBlockAfter=$${Math.max(numBlockHeight - 20, 1)}`, + url: `${COMLINK_URL}/v4/orders?address=${address}&subaccountNumber=${subaccountNumber}&status=BEST_EFFORT_CANCELED&goodTilBlockAfter=${Math.max(numBlockHeight - 20, 1)}`, timeout: config.INITIAL_GET_TIMEOUT_MS, headers: { 'cf-ipcountry': country, @@ -607,7 +607,7 @@ export class Subscriptions { }), ]); - logger.info({ + logger.error({ at: "getInitialResponseForSubaccountSubscription", message: `Got order responses`, id, @@ -622,7 +622,7 @@ export class Subscriptions { ); const allOrders: OrderFromDatabase[] = orders.concat(currentBestEffortCanceledOrders); - logger.info({ + logger.error({ at: "getInitialResponseForSubaccountScription", message: `Concatenated orders`, allOrders, @@ -663,6 +663,11 @@ export class Subscriptions { throw new Error('Invalid undefined id'); } + logger.error({ + at: "getInitialResponseForParentSubaccountSubscription", + message: `Getting initial parent subaccount data for ${id}`, + }); + try { const { address, @@ -675,6 +680,12 @@ export class Subscriptions { const blockHeight: string = await blockHeightRefresher.getLatestBlockHeight(); const numBlockHeight: number = parseInt(blockHeight, 10); + logger.error({ + at: "getInitialResponseForParentSubaccountSubscription", + message: `Got initial block height ${numBlockHeight}`, + id, + }); + const [ subaccountsResponse, ordersResponse, @@ -714,12 +725,28 @@ export class Subscriptions { }), ]); + logger.error({ + at: "getInitialResponseForParentSubaccountSubscription", + message: `Got order responses`, + id, + subaccountsResponse, + ordersResponse, + currentBestEffortCanceledOrdersResponse, + }); + const orders: OrderFromDatabase[] = JSON.parse(ordersResponse); const currentBestEffortCanceledOrders: OrderFromDatabase[] = JSON.parse( currentBestEffortCanceledOrdersResponse, ); const allOrders: OrderFromDatabase[] = orders.concat(currentBestEffortCanceledOrders); + logger.error({ + at: "getInitialResponseForSubaccountScription", + message: `Concatenated orders`, + allOrders, + id, + }); + return JSON.stringify({ ...JSON.parse(subaccountsResponse), orders: allOrders, From 6b946cc0fe4eda963a70f6984c3d7a0aca7667ff Mon Sep 17 00:00:00 2001 From: Vincent Chau <99756290+vincentwschau@users.noreply.github.com> Date: Fri, 7 Feb 2025 18:24:20 -0500 Subject: [PATCH 4/7] Fix parent subaccount endpoint. --- .../src/controllers/api/v4/orders-controller.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/indexer/services/comlink/src/controllers/api/v4/orders-controller.ts b/indexer/services/comlink/src/controllers/api/v4/orders-controller.ts index 54c14e929eb..04ee39ce145 100644 --- a/indexer/services/comlink/src/controllers/api/v4/orders-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/orders-controller.ts @@ -492,11 +492,23 @@ router.get( options: { gt: 0 }, }, }, + goodTilBlockAfter: { + in: 'query', + optional: true, + isInt: { + options: { gt: 0 }, + }, + }, goodTilBlockTimeBeforeOrAt: { in: 'query', optional: true, isISO8601: true, }, + goodTilBlockTimeAfter: { + in: 'query', + optional: true, + isISO8601: true, + }, returnLatestOrders: { in: 'query', isBoolean: true, From 39d485e80517f77a5a858786cccd703b60411d6f Mon Sep 17 00:00:00 2001 From: Vincent Chau <99756290+vincentwschau@users.noreply.github.com> Date: Fri, 7 Feb 2025 18:45:34 -0500 Subject: [PATCH 5/7] Remove logging. --- .../services/socks/src/lib/subscription.ts | 59 ------------------- 1 file changed, 59 deletions(-) diff --git a/indexer/services/socks/src/lib/subscription.ts b/indexer/services/socks/src/lib/subscription.ts index 4e821cab6c1..7daf1473a97 100644 --- a/indexer/services/socks/src/lib/subscription.ts +++ b/indexer/services/socks/src/lib/subscription.ts @@ -545,11 +545,6 @@ export class Subscriptions { throw new Error('Invalid undefined id'); } - logger.error({ - at: "getInitialResponseForSubaccountSubscription", - message: `Getting initial subaccount data for ${id}`, - }); - try { const { address, @@ -562,12 +557,6 @@ export class Subscriptions { const blockHeight: string = await blockHeightRefresher.getLatestBlockHeight(); const numBlockHeight: number = parseInt(blockHeight, 10); - logger.error({ - at: "getInitialResponseForSubaccountSubscription", - message: `Got initial block height ${numBlockHeight}`, - id, - }); - const [ subaccountsResponse, ordersResponse, @@ -607,39 +596,18 @@ export class Subscriptions { }), ]); - logger.error({ - at: "getInitialResponseForSubaccountSubscription", - message: `Got order responses`, - id, - subaccountsResponse, - ordersResponse, - currentBestEffortCanceledOrdersResponse, - }); - const orders: OrderFromDatabase[] = JSON.parse(ordersResponse); const currentBestEffortCanceledOrders: OrderFromDatabase[] = JSON.parse( currentBestEffortCanceledOrdersResponse, ); const allOrders: OrderFromDatabase[] = orders.concat(currentBestEffortCanceledOrders); - logger.error({ - at: "getInitialResponseForSubaccountScription", - message: `Concatenated orders`, - allOrders, - id, - }); - return JSON.stringify({ ...JSON.parse(subaccountsResponse), orders: allOrders, blockHeight, }); } catch (error) { - logger.error({ - at: 'getInitialResponseForSubaccountSubscription', - message: `Received error when subscribing ${id}`, - error, - }); // The subaccounts API endpoint returns a 404 for subaccounts that are not indexed, however // such subaccounts can be subscribed to and events can be sent when the subaccounts are // indexed to an existing subscription. @@ -663,11 +631,6 @@ export class Subscriptions { throw new Error('Invalid undefined id'); } - logger.error({ - at: "getInitialResponseForParentSubaccountSubscription", - message: `Getting initial parent subaccount data for ${id}`, - }); - try { const { address, @@ -680,12 +643,6 @@ export class Subscriptions { const blockHeight: string = await blockHeightRefresher.getLatestBlockHeight(); const numBlockHeight: number = parseInt(blockHeight, 10); - logger.error({ - at: "getInitialResponseForParentSubaccountSubscription", - message: `Got initial block height ${numBlockHeight}`, - id, - }); - const [ subaccountsResponse, ordersResponse, @@ -725,28 +682,12 @@ export class Subscriptions { }), ]); - logger.error({ - at: "getInitialResponseForParentSubaccountSubscription", - message: `Got order responses`, - id, - subaccountsResponse, - ordersResponse, - currentBestEffortCanceledOrdersResponse, - }); - const orders: OrderFromDatabase[] = JSON.parse(ordersResponse); const currentBestEffortCanceledOrders: OrderFromDatabase[] = JSON.parse( currentBestEffortCanceledOrdersResponse, ); const allOrders: OrderFromDatabase[] = orders.concat(currentBestEffortCanceledOrders); - logger.error({ - at: "getInitialResponseForSubaccountScription", - message: `Concatenated orders`, - allOrders, - id, - }); - return JSON.stringify({ ...JSON.parse(subaccountsResponse), orders: allOrders, From 47985bd219d9cb7efdf89b5c8f31a0ad37ccca73 Mon Sep 17 00:00:00 2001 From: Vincent Chau <99756290+vincentwschau@users.noreply.github.com> Date: Fri, 7 Feb 2025 18:47:16 -0500 Subject: [PATCH 6/7] Remove debug logging. --- indexer/services/socks/src/lib/subscription.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/indexer/services/socks/src/lib/subscription.ts b/indexer/services/socks/src/lib/subscription.ts index 7daf1473a97..d2735a1b46d 100644 --- a/indexer/services/socks/src/lib/subscription.ts +++ b/indexer/services/socks/src/lib/subscription.ts @@ -608,6 +608,12 @@ export class Subscriptions { blockHeight, }); } catch (error) { + logger.error({ + at: 'getInitialResponseForSubaccountSubscription', + message: 'Error on getting initial response for subaccount subscription', + id, + error, + }); // The subaccounts API endpoint returns a 404 for subaccounts that are not indexed, however // such subaccounts can be subscribed to and events can be sent when the subaccounts are // indexed to an existing subscription. @@ -694,6 +700,12 @@ export class Subscriptions { blockHeight, }); } catch (error) { + logger.error({ + at: 'getInitialResponseForParentSubaccountSubscription', + message: 'Error on getting initial response for subaccount subscription', + id, + error, + }); // The subaccounts API endpoint returns a 404 for subaccounts that are not indexed, however // such subaccounts can be subscribed to and events can be sent when the subaccounts are // indexed to an existing subscription. From 6a2339f039395c75a9b60fd5ebe72bbabbdbf284 Mon Sep 17 00:00:00 2001 From: Vincent Chau <99756290+vincentwschau@users.noreply.github.com> Date: Fri, 7 Feb 2025 18:48:45 -0500 Subject: [PATCH 7/7] Revert workflow. --- .github/workflows/indexer-build-and-push-dev-staging.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/indexer-build-and-push-dev-staging.yml b/.github/workflows/indexer-build-and-push-dev-staging.yml index ac01e06252f..5a98b72552e 100644 --- a/.github/workflows/indexer-build-and-push-dev-staging.yml +++ b/.github/workflows/indexer-build-and-push-dev-staging.yml @@ -6,7 +6,6 @@ on: # yamllint disable-line rule:truthy - main - 'release/indexer/v[0-9]+.[0-9]+.x' # e.g. release/indexer/v0.1.x - 'release/indexer/v[0-9]+.x' # e.g. release/indexer/v1.x - - 'vincentc/*' # TODO(DEC-837): Customize github build and push to ECR by service with paths jobs: