Skip to content

Commit 55289de

Browse files
authored
Merge pull request #41 from pinto-org/exchange-sg-sunrise
disable waiting for bean/basin sg before processing apys
2 parents 61bff2b + d9fc6b3 commit 55289de

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/scheduled/tasks/deposits.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const MAX_BLOCKS = 2000;
1717

1818
class DepositsTask {
1919
// Set by SunriseTask when a new season is encountered. Indicates that all deposits should be updated.
20+
// This approach would not work if also taking deposit snapshots (this flag/behavior is only triggered in real-time).
2021
static __seasonUpdate = false;
2122

2223
// Returns true if the task can be called again immediately
@@ -29,6 +30,9 @@ class DepositsTask {
2930
}
3031
Log.info(`Updating deposits for block range [${lastUpdate}, ${updateBlock}]`);
3132

33+
// FIXME: there is an issue here when whitelisting or pausing (and their inverse) occurs.
34+
// Should assign the updateBlock to the block right before one of those events.
35+
// When paused, the indexer should auto advance (since there can be no deposit activity)
3236
const tokenInfos = await SiloService.getWhitelistedTokenInfo({ block: updateBlock, chain: C().CHAIN });
3337

3438
await AsyncContext.sequelizeTransaction(async () => {

src/scheduled/util/on-sunrise.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ class OnSunriseUtil {
4646
const newSeasonBlock = parseInt(beanstalkSeason.sunriseBlock);
4747
// See if bean, basin subgraphs are ready also
4848
const [beanMeta, basinMeta] = await Promise.all([
49-
CommonSubgraphRepository.getMeta(C().SG.BEAN),
50-
CommonSubgraphRepository.getMeta(C().SG.BASIN)
49+
/// Currently we don't need either of these subgraphs to be ready for downstream use cases.
50+
/// Test cases were modified to not test bean/basin anymore.
51+
/// This is a temporary measure that was added due to this subgraph crashign and being unavailable for a long period.
52+
/// A more robust solution would allow upstream callers to specify which subgraphs they expect to be ready.
53+
Promise.resolve({ block: Number.MAX_SAFE_INTEGER.toString() }),
54+
Promise.resolve({ block: Number.MAX_SAFE_INTEGER.toString() })
55+
/// CommonSubgraphRepository.getMeta(C().SG.BEAN),
56+
/// CommonSubgraphRepository.getMeta(C().SG.BASIN)
5157
]);
5258
return Math.min(parseInt(beanMeta.block), parseInt(basinMeta.block)) >= newSeasonBlock;
5359
}

test/scheduled/sunrise.test.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@ describe('OnSunrise', () => {
3838
// Fast-forward timers and continue
3939
jest.advanceTimersByTime(5000);
4040
jest.runAllTimers();
41-
await checkLastPromiseResult(checkSpy, false);
41+
await checkLastPromiseResult(checkSpy, true);
4242

43-
// Now, bean/basin are ready also
44-
const metaReady = require('../mock-responses/subgraph/scheduled/sunrise/metaReady.json');
45-
beanSGSpy.mockResolvedValueOnce(metaReady);
46-
basinSGSpy.mockResolvedValueOnce(metaReady);
43+
/// Disabled due to not checking for these in the waiting function anymore
44+
// // Now, bean/basin are ready also
45+
// const metaReady = require('../mock-responses/subgraph/scheduled/sunrise/metaReady.json');
46+
// beanSGSpy.mockResolvedValueOnce(metaReady);
47+
// basinSGSpy.mockResolvedValueOnce(metaReady);
4748

48-
jest.advanceTimersByTime(5000);
49-
jest.runAllTimers();
50-
await checkLastPromiseResult(checkSpy, true);
49+
// jest.advanceTimersByTime(5000);
50+
// jest.runAllTimers();
51+
// await checkLastPromiseResult(checkSpy, true);
5152

5253
await expect(waitPromise).resolves.toBeUndefined();
5354
});

0 commit comments

Comments
 (0)