From 9302c27ec5530e2de34fc7354ea6d3f9bd5b2ba4 Mon Sep 17 00:00:00 2001 From: Konstantina Blazhukova Date: Fri, 15 Nov 2024 17:10:25 +0200 Subject: [PATCH] Masks ip beforehand instead of changing object in repeated request Signed-off-by: Konstantina Blazhukova --- .../relay/src/lib/clients/mirrorNodeClient.ts | 25 ++++++++++--------- packages/relay/src/lib/eth.ts | 8 +++++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/relay/src/lib/clients/mirrorNodeClient.ts b/packages/relay/src/lib/clients/mirrorNodeClient.ts index acb24cf76..d2b73a3f5 100644 --- a/packages/relay/src/lib/clients/mirrorNodeClient.ts +++ b/packages/relay/src/lib/clients/mirrorNodeClient.ts @@ -18,22 +18,22 @@ * */ +import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; +import Axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; +import axiosRetry from 'axios-retry'; +import { install as betterLookupInstall } from 'better-lookup'; +import { ethers } from 'ethers'; import http from 'http'; import https from 'https'; import { Logger } from 'pino'; -import { ethers } from 'ethers'; -import axiosRetry from 'axios-retry'; -import constants from './../constants'; import { Histogram, Registry } from 'prom-client'; + +import { formatRequestIdMessage, formatTransactionId, parseNumericEnvVar } from '../../formatters'; import { predefined } from '../errors/JsonRpcError'; +import { MirrorNodeClientError } from '../errors/MirrorNodeClientError'; import { SDKClientError } from '../errors/SDKClientError'; -import { IOpcodesResponse } from './models/IOpcodesResponse'; -import { install as betterLookupInstall } from 'better-lookup'; +import { EthImpl } from '../eth'; import { CacheService } from '../services/cacheService/cacheService'; -import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; -import { MirrorNodeClientError } from '../errors/MirrorNodeClientError'; -import Axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; -import { formatRequestIdMessage, formatTransactionId, parseNumericEnvVar } from '../../formatters'; import { IContractCallRequest, IContractCallResponse, @@ -45,7 +45,8 @@ import { MirrorNodeTransactionRecord, RequestDetails, } from '../types'; -import { EthImpl } from '../eth'; +import constants from './../constants'; +import { IOpcodesResponse } from './models/IOpcodesResponse'; type REQUEST_METHODS = 'GET' | 'POST'; @@ -1315,7 +1316,7 @@ export class MirrorNodeClient { } else { this.logger.warn( e, - `${requestDetails?.formattedRequestId} Error raised during polling mirror node for updated records: method=${methodName}, args=${args}`, + `${requestDetails?.formattedRequestId} Error raised during polling mirror node for updated records: method=${methodName}, args=${args}}`, ); } } @@ -1366,7 +1367,7 @@ export class MirrorNodeClient { const transactionRecords = await this.repeatedRequest( this.getTransactionById.name, - [transactionId, requestDetails, 0], + [transactionId, 0], this.MIRROR_NODE_REQUEST_RETRY_COUNT, requestDetails, ); diff --git a/packages/relay/src/lib/eth.ts b/packages/relay/src/lib/eth.ts index 1c7ceb28b..aaa5e4378 100644 --- a/packages/relay/src/lib/eth.ts +++ b/packages/relay/src/lib/eth.ts @@ -1720,9 +1720,15 @@ export class EthImpl implements Eth { if (submittedTransactionId) { try { const formattedTransactionId = formatTransactionIdWithoutQueryParams(submittedTransactionId); + + // Create a modified copy of requestDetails + const modifiedRequestDetails = { + ...requestDetails, + ipAddress: 'xxx.xxx.xxx.xxx', + }; const contractResult = await this.mirrorNodeClient.repeatedRequest( this.mirrorNodeClient.getContractResult.name, - [formattedTransactionId], + [formattedTransactionId, modifiedRequestDetails], this.mirrorNodeClient.getMirrorNodeRequestRetryCount(), requestDetails, );