From e0cd6be9eb6682fba8dc736fff5c9ba3bf8cfc6e Mon Sep 17 00:00:00 2001 From: Logan Nguyen Date: Mon, 27 Jan 2025 16:48:56 -0600 Subject: [PATCH] fix: added validation to ensure the timestamp range between fromBlock and toBlock is valid Signed-off-by: Logan Nguyen --- .../lib/services/ethService/ethCommonService/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/relay/src/lib/services/ethService/ethCommonService/index.ts b/packages/relay/src/lib/services/ethService/ethCommonService/index.ts index fa6217285..2f9510fb4 100644 --- a/packages/relay/src/lib/services/ethService/ethCommonService/index.ts +++ b/packages/relay/src/lib/services/ethService/ethCommonService/index.ts @@ -147,6 +147,15 @@ export class CommonService implements ICommonService { params.timestamp.push(`lte:${toBlockResponse.timestamp.to}`); toBlockNum = parseInt(toBlockResponse.number); + // Add timestamp range validation (7 days = 604800 seconds) + const timestampDiff = toBlockResponse.timestamp.to - fromBlockResponse.timestamp.from; + if (timestampDiff > 604800) { + throw predefined.TIMESTAMP_RANGE_TOO_LARGE( + `0x${fromBlockNum.toString(16)}`, + fromBlockResponse.timestamp.from, + `0x${toBlockNum.toString(16)}`, + toBlockResponse.timestamp.to, + ); } if (fromBlockNum > toBlockNum) {