From aa85870dec134a078de5f476bdf834f4bcc8fe63 Mon Sep 17 00:00:00 2001 From: Shunji Zhan Date: Sat, 6 Apr 2024 10:39:26 +0800 Subject: [PATCH] do not throw error if subql stops --- packages/eth-providers/src/base-provider.ts | 27 +-------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/packages/eth-providers/src/base-provider.ts b/packages/eth-providers/src/base-provider.ts index 09c8b3cc5..16d5d4cc3 100644 --- a/packages/eth-providers/src/base-provider.ts +++ b/packages/eth-providers/src/base-provider.ts @@ -1750,37 +1750,12 @@ export abstract class BaseProvider extends AbstractProvider { return txFromCache; } - await this._checkSubqlHeight(); - const txFromSubql = await this.subql?.getTxReceiptByHash(txHash); return txFromSubql ? subqlReceiptAdapter(txFromSubql) : null; }; - // make sure there is no gap between subql and cache - _checkSubqlHeight = async (): Promise => { - if (!this.subql) return; - - const maxMissedBlockCount = this.blockCache.cachedBlockHashes.length; - const lastProcessedHeight = await this.subql.getLastProcessedHeight(); - const minSubqlHeight = await this.finalizedBlockNumber - maxMissedBlockCount; - if (lastProcessedHeight < minSubqlHeight) { - return logger.throwError( - 'subql indexer height is less than the minimum height required', - Logger.errors.SERVER_ERROR, - { - lastProcessedHeight, - minSubqlHeight, - maxMissedBlockCount, - curFinalizedHeight: await this.finalizedBlockNumber, - } - ); - } - - return lastProcessedHeight; - }; - _sanitizeRawFilter = async (rawFilter: LogFilter): Promise => { const { fromBlock, toBlock, blockHash, address, topics } = rawFilter; const filter: SanitizedLogFilter = { @@ -1819,7 +1794,7 @@ export abstract class BaseProvider extends AbstractProvider { _getSubqlMissedLogs = async (toBlock: number, filter: SanitizedLogFilter): Promise => { const targetBlock = Math.min(toBlock, await this.finalizedBlockNumber); // subql upperbound is finalizedBlockNumber - const lastProcessedHeight = await this._checkSubqlHeight(); + const lastProcessedHeight = await this.subql.getLastProcessedHeight(); const missedBlockCount = targetBlock - lastProcessedHeight; if (missedBlockCount <= 0) return [];