ignore prelaunch for killing process
This commit is contained in:
@@ -46,6 +46,8 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
Map<number, { slot: number; ts: number }>
|
Map<number, { slot: number; ts: number }>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
public skipSlotStalenessCheckMarkets = new Set<number>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
config: DLOBSubscriptionConfig & {
|
config: DLOBSubscriptionConfig & {
|
||||||
redisClient: RedisClient;
|
redisClient: RedisClient;
|
||||||
@@ -73,6 +75,10 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
market.marketIndex
|
market.marketIndex
|
||||||
);
|
);
|
||||||
const includeVamm = !isVariant(perpMarket.status, 'ammPaused');
|
const includeVamm = !isVariant(perpMarket.status, 'ammPaused');
|
||||||
|
const oracleSource = perpMarket.amm.oracleSource;
|
||||||
|
if (isVariant(oracleSource, 'prelaunch')) {
|
||||||
|
this.skipSlotStalenessCheckMarkets.add(market.marketIndex);
|
||||||
|
}
|
||||||
|
|
||||||
this.marketArgs.push({
|
this.marketArgs.push({
|
||||||
marketIndex: market.marketIndex,
|
marketIndex: market.marketIndex,
|
||||||
@@ -175,9 +181,13 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Check if slot diffs are too large for oracle
|
// Check if slot diffs are too large for oracle
|
||||||
|
const skipSlotCheck =
|
||||||
|
marketType === 'perp' &&
|
||||||
|
this.skipSlotStalenessCheckMarkets.has(marketArgs.marketIndex);
|
||||||
if (
|
if (
|
||||||
Math.abs(slot - parseInt(l2Formatted['oracleData']['slot'])) >
|
Math.abs(slot - parseInt(l2Formatted['oracleData']['slot'])) >
|
||||||
this.killSwitchSlotDiffThreshold
|
this.killSwitchSlotDiffThreshold &&
|
||||||
|
!skipSlotCheck
|
||||||
) {
|
) {
|
||||||
console.log(`Killing process due to slot diffs for market ${marketName}:
|
console.log(`Killing process due to slot diffs for market ${marketName}:
|
||||||
dlobProvider slot: ${slot}
|
dlobProvider slot: ${slot}
|
||||||
@@ -194,7 +204,8 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
if (
|
if (
|
||||||
lastMarketSlotAndTime &&
|
lastMarketSlotAndTime &&
|
||||||
l2Formatted['marketSlot'] === lastMarketSlotAndTime.slot &&
|
l2Formatted['marketSlot'] === lastMarketSlotAndTime.slot &&
|
||||||
Date.now() - lastMarketSlotAndTime.ts > MAKRET_STALENESS_THRESHOLD
|
Date.now() - lastMarketSlotAndTime.ts > MAKRET_STALENESS_THRESHOLD &&
|
||||||
|
!skipSlotCheck
|
||||||
) {
|
) {
|
||||||
console.log(`Killing process due to same slot for market ${marketName} after > ${MAKRET_STALENESS_THRESHOLD}ms:
|
console.log(`Killing process due to same slot for market ${marketName} after > ${MAKRET_STALENESS_THRESHOLD}ms:
|
||||||
dlobProvider slot: ${slot}
|
dlobProvider slot: ${slot}
|
||||||
@@ -329,48 +340,6 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
marketArgs.marketIndex
|
marketArgs.marketIndex
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if slot diffs are too large for oracle
|
|
||||||
if (
|
|
||||||
Math.abs(slot - parseInt(l3['oracleData']['slot'])) >
|
|
||||||
this.killSwitchSlotDiffThreshold
|
|
||||||
) {
|
|
||||||
console.log(`Killing process due to slot diffs for market ${marketName}:
|
|
||||||
dlobProvider slot: ${slot}
|
|
||||||
oracle slot: ${l3['oracleData']['slot']}
|
|
||||||
`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if times and slots are too different for market
|
|
||||||
const MAKRET_STALENESS_THRESHOLD =
|
|
||||||
marketType === 'perp'
|
|
||||||
? PERP_MAKRET_STALENESS_THRESHOLD
|
|
||||||
: SPOT_MAKRET_STALENESS_THRESHOLD;
|
|
||||||
if (
|
|
||||||
lastMarketSlotAndTime &&
|
|
||||||
l3['marketSlot'] === lastMarketSlotAndTime.slot &&
|
|
||||||
Date.now() - lastMarketSlotAndTime.ts > MAKRET_STALENESS_THRESHOLD
|
|
||||||
) {
|
|
||||||
console.log(`Killing process due to same slot for market ${marketName} after > ${MAKRET_STALENESS_THRESHOLD}ms:
|
|
||||||
dlobProvider slot: ${slot}
|
|
||||||
market slot: ${l3['marketSlot']}
|
|
||||||
`);
|
|
||||||
process.exit(1);
|
|
||||||
} else if (
|
|
||||||
lastMarketSlotAndTime &&
|
|
||||||
l3['marketSlot'] !== lastMarketSlotAndTime.slot
|
|
||||||
) {
|
|
||||||
console.log(
|
|
||||||
`Updating market slot for ${marketArgs.marketName} with slot ${l3['marketSlot']}`
|
|
||||||
);
|
|
||||||
this.lastMarketSlotMap
|
|
||||||
.get(marketArgs.marketType)
|
|
||||||
.set(marketArgs.marketIndex, {
|
|
||||||
slot: l3['marketSlot'],
|
|
||||||
ts: Date.now(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.redisClient.client.set(
|
this.redisClient.client.set(
|
||||||
`last_update_orderbook_l3_${marketType}_${marketArgs.marketIndex}`,
|
`last_update_orderbook_l3_${marketType}_${marketArgs.marketIndex}`,
|
||||||
JSON.stringify(l3)
|
JSON.stringify(l3)
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ const main = async (): Promise<void> => {
|
|||||||
commitment: stateCommitment,
|
commitment: stateCommitment,
|
||||||
};
|
};
|
||||||
slotSubscriber = new SlotSubscriber(connection, {
|
slotSubscriber = new SlotSubscriber(connection, {
|
||||||
resubTimeoutMs: 5000
|
resubTimeoutMs: 5000,
|
||||||
});
|
});
|
||||||
await slotSubscriber.subscribe();
|
await slotSubscriber.subscribe();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user