Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with socks subaccount subscription with best effort canceled logic. #2718

Merged
merged 7 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions indexer/services/socks/__tests__/lib/subscriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
};
Expand Down
14 changes: 13 additions & 1 deletion indexer/services/socks/src/lib/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,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,
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down