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

[IND-481] Delete price cache in ender. #815

Merged
merged 1 commit into from
Nov 29, 2023
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
5 changes: 0 additions & 5 deletions indexer/services/ender/__tests__/caches/block-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
shouldSkipBlock,
} from '../../src/caches/block-cache';
import { clearCandlesMap, getCandlesMap } from '../../src/caches/candle-cache';
import { clearPriceMap, getPriceMap } from '../../src/caches/price-cache';

describe('block-cache', () => {
beforeAll(async () => {
Expand All @@ -34,7 +33,6 @@ describe('block-cache', () => {
await dbHelpers.clearData();
resetBlockCache();
clearCandlesMap();
clearPriceMap();
perpetualMarketRefresher.clear();
assetRefresher.clear();
marketRefresher.clear();
Expand Down Expand Up @@ -80,7 +78,6 @@ describe('block-cache', () => {
// validate that block, candles, and price cache are updated
expect(getCurrentBlockHeight()).toEqual('3');
expect(getCandlesMap()).not.toEqual({});
expect(getPriceMap()).not.toEqual({});
expect(perpetualMarketRefresher.getPerpetualMarketsMap()).not.toEqual({});
expect(assetRefresher.getAssetsMap()).not.toEqual({});
expect(marketRefresher.getMarketsMap()).not.toEqual({});
Expand All @@ -93,7 +90,6 @@ describe('block-cache', () => {
// Validate that caches are empty
expect(getCurrentBlockHeight()).toEqual('-1');
expect(getCandlesMap()).toEqual({});
expect(getPriceMap()).toEqual({});
expect(perpetualMarketRefresher.getPerpetualMarketsMap()).toEqual({});
expect(assetRefresher.getAssetsMap()).toEqual({});
expect(marketRefresher.getMarketsMap()).toEqual({});
Expand All @@ -103,7 +99,6 @@ describe('block-cache', () => {
// Validate that caches are populated
expect(getCurrentBlockHeight()).toEqual('2');
expect(getCandlesMap()).not.toEqual({});
expect(getPriceMap()).not.toEqual({});
expect(perpetualMarketRefresher.getPerpetualMarketsMap()).not.toEqual({});
expect(assetRefresher.getAssetsMap()).not.toEqual({});
expect(marketRefresher.getMarketsMap()).not.toEqual({});
Expand Down
133 changes: 0 additions & 133 deletions indexer/services/ender/__tests__/caches/price-cache.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { redis } from '@dydxprotocol-indexer/redis';
import Big from 'big.js';
import { redisClient } from '../../src/helpers/redis/redis-controller';
import { bigIntToBytes } from '@dydxprotocol-indexer/v4-proto-parser';
import { startPriceCache } from '../../src/caches/price-cache';
import { createPostgresFunctions } from '../../src/helpers/postgres/postgres-functions';

describe('fundingHandler', () => {
Expand All @@ -57,7 +56,6 @@ describe('fundingHandler', () => {
await perpetualMarketRefresher.updatePerpetualMarkets();
await assetRefresher.updateAssets();
updateBlockCache(defaultPreviousHeight);
await startPriceCache(defaultPreviousHeight);
});

afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { updateBlockCache } from '../../../src/caches/block-cache';
import { MarketEventV1, IndexerTendermintBlock, IndexerTendermintEvent } from '@dydxprotocol-indexer/v4-protos';
import { MarketPriceUpdateHandler } from '../../../src/handlers/markets/market-price-update-handler';
import Long from 'long';
import { getPrice } from '../../../src/caches/price-cache';
import { createPostgresFunctions } from '../../../src/helpers/postgres/postgres-functions';

describe('marketPriceUpdateHandler', () => {
Expand Down Expand Up @@ -148,8 +147,6 @@ describe('marketPriceUpdateHandler', () => {
defaultHeight,
);

expect(getPrice(oraclePrice.marketId)).toEqual(oraclePrice.price);

const contents: MarketMessageContents = generateOraclePriceContents(
oraclePrice,
market.pair,
Expand Down Expand Up @@ -202,8 +199,6 @@ describe('marketPriceUpdateHandler', () => {
defaultHeight,
);

expect(getPrice(oraclePrice.marketId)).toEqual(oraclePrice.price);

const contents: MarketMessageContents = generateOraclePriceContents(
oraclePrice,
market.pair,
Expand Down
3 changes: 0 additions & 3 deletions indexer/services/ender/src/caches/block-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Big from 'big.js';

import config from '../config';
import { startCandleCache } from './candle-cache';
import { startPriceCache } from './price-cache';

const INITIAL_BLOCK_HEIGHT: string = '-1';

Expand Down Expand Up @@ -114,8 +113,6 @@ export async function initializeAllCaches(): Promise<void> {
assetRefresher.updateAssets({ txId }),
marketRefresher.updateMarkets({ txId }),
]);
// Must be run after startBlockCache() because it uses the block cache.
await startPriceCache(getCurrentBlockHeight(), txId);

await Transaction.rollback(txId);
}
Expand Down
60 changes: 0 additions & 60 deletions indexer/services/ender/src/caches/price-cache.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { MarketEventV1 } from '@dydxprotocol-indexer/v4-protos';
import * as pg from 'pg';

import { updatePriceCacheWithPrice } from '../../caches/price-cache';
import { generateOraclePriceContents } from '../../helpers/kafka-helper';
import {
ConsolidatedKafkaEvent,
Expand Down Expand Up @@ -64,7 +63,6 @@ export class MarketPriceUpdateHandler extends Handler<MarketEventV1> {
result.rows[0].result.oracle_price) as OraclePriceFromDatabase;

marketRefresher.updateMarket(market);
updatePriceCacheWithPrice(oraclePrice);

return [
this.generateKafkaEvent(
Expand Down