diff --git a/backend/src/client/parentchain/index.ts b/backend/src/client/parentchain/index.ts index 5b48768..3886455 100644 --- a/backend/src/client/parentchain/index.ts +++ b/backend/src/client/parentchain/index.ts @@ -73,7 +73,9 @@ export class ParentChainClient { * @param committedSubnetBlockHash WARNING: This method only check against the block has that has already been committed, otherwise always 0 * @returns The full block header that hosted the transaction submitted by relayer (i.e the tx for committing the subnet block into parentchain) */ - async getParentChainBlockBySubnetHash(committedSubnetBlockHash: string) { + async getParentChainBlockBySubnetHash(committedSubnetBlockHash: string) { + // TODO: check if this is possible, how can parentchain block num be known in SC + // TODO: also SC is returning subnet block height not parentnet height try { const { mainnet_num } = await this.smartContractInstance.methods.getHeader(committedSubnetBlockHash).call(); if (!mainnet_num) { diff --git a/backend/src/services/block.service.ts b/backend/src/services/block.service.ts index 5b7e6b6..04768a4 100644 --- a/backend/src/services/block.service.ts +++ b/backend/src/services/block.service.ts @@ -7,6 +7,8 @@ import { BaseBlockResponse, BlockResponse } from '../interfaces/output/blocksRes import { SubnetClient } from '../client/subnet'; import { HttpException } from '@/exceptions/httpException'; import { NUM_OF_BLOCKS_RETURN } from '../config'; +import { logger } from '../utils/logger'; + @Service() export class BlockService { @@ -211,10 +213,15 @@ export class BlockService { const { smartContractHeight, smartContractCommittedHash } = await this.getAndSetLastSubmittedBlockInfo(); const mode = await this.parentChainClient.mode(); const { timestamp } = await this.parentChainClient.getParentChainBlockBySubnetHash(smartContractCommittedHash); + const { number: subnetCommittedNumber } = await this.subnetClient.getLatestCommittedBlockInfo(); - const timeDiff = new Date().getTime() / 1000 - parseInt(timestamp.toString()); - - const isProcessing = (mode == 'full' && timeDiff < 120) || (mode == 'lite' && timeDiff < 1000); + let isProcessing = true; + const blockDiff = subnetCommittedNumber - smartContractHeight; + if (mode == 'lite') { + if (blockDiff > 1000) isProcessing = false; + } else if (mode == 'full') { + if (blockDiff > 100) isProcessing = false; + } return { processedUntil: smartContractHeight, diff --git a/frontend/src/components/info-cards/InfoCards.tsx b/frontend/src/components/info-cards/InfoCards.tsx index 7ff56c8..03d0391 100644 --- a/frontend/src/components/info-cards/InfoCards.tsx +++ b/frontend/src/components/info-cards/InfoCards.tsx @@ -50,7 +50,7 @@ export default function InfoCards(props: InfoCardsProps) { } function getRelayerStatus(): InfoListHealth { - if (Number(loaderData.relayer?.account.balance) < 1) { + if (Number(loaderData.relayer?.account.balance) < 100) { return "Low funds"; } if (loaderData.relayer?.health.status === "UP") {