Skip to content

Commit 13ae128

Browse files
committed
chore: resolve comments
Signed-off-by: nikolay <[email protected]>
1 parent ece6f4c commit 13ae128

File tree

15 files changed

+27
-144
lines changed

15 files changed

+27
-144
lines changed

packages/relay/src/lib/clients/cache/redisCache/redisCache.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,8 @@ export class RedisCache implements ICacheClient {
236236
const prefixedKey = this.prefixKey(key);
237237
const serializedValue = JSON.stringify(value);
238238
const result = await this.client.rPush(prefixedKey, serializedValue);
239-
if (this.logger.isLevelEnabled('trace')) {
240-
this.logger.trace(`pushing %s to %s on %s call`, serializedValue, key, callingMethod);
241-
}
239+
this.logger.trace(`pushing %s to %s on %s call`, serializedValue, key, callingMethod);
240+
242241
return result;
243242
}
244243

@@ -275,9 +274,7 @@ export class RedisCache implements ICacheClient {
275274

276275
await pipeline.exec();
277276

278-
if (this.logger.isLevelEnabled('trace')) {
279-
this.logger.trace(`Cleared %s cache keys`, keysToDelete.length);
280-
}
277+
this.logger.trace(`Cleared %s cache keys`, keysToDelete.length);
281278
}
282279
}
283280
}

packages/relay/src/lib/clients/mirrorNodeClient.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ export class MirrorNodeClient {
224224
retries: mirrorNodeRetries,
225225
retryDelay: (retryCount, error) => {
226226
const delay = mirrorNodeRetryDelay * retryCount;
227-
if (this.logger.isLevelEnabled('trace')) {
228-
this.logger.trace(`Retry delay %s ms on '%s'`, delay, error?.request?.path);
229-
}
227+
this.logger.trace(`Retry delay %s ms on '%s'`, delay, error?.request?.path);
230228
return delay;
231229
},
232230
retryCondition: (error) => {
@@ -509,9 +507,7 @@ export class MirrorNodeClient {
509507

510508
if (page === pageMax) {
511509
// max page reached
512-
if (this.logger.isLevelEnabled('trace')) {
513-
this.logger.trace(`Max page reached %s with %s results`, pageMax, results.length);
514-
}
510+
this.logger.trace(`Max page reached %s with %s results`, pageMax, results.length);
515511
throw predefined.PAGINATION_MAX(pageMax);
516512
}
517513

packages/relay/src/lib/config/hbarSpendingPlanConfigService.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export class HbarSpendingPlanConfigService {
178178
const plansToDelete = existingPlans.filter((plan) => !spendingPlanConfigs.some((spc) => spc.id === plan.id));
179179
for (const { id } of plansToDelete) {
180180
this.logger.info(
181-
`Deleting HBAR spending plan with ID "%s", as it is no longer in the spending plan configuration...`,
181+
`Deleting HBAR spending plan with ID %s, as it is no longer in the spending plan configuration...`,
182182
id,
183183
);
184184
await this.hbarSpendingPlanRepository.delete(id);
@@ -202,12 +202,7 @@ export class HbarSpendingPlanConfigService {
202202
const plansToAdd = spendingPlanConfigs.filter((spc) => !existingPlans.some((plan) => plan.id === spc.id));
203203
for (const { id, name, subscriptionTier } of plansToAdd) {
204204
await this.hbarSpendingPlanRepository.create(subscriptionTier, this.TTL, id);
205-
this.logger.info(
206-
`Created HBAR spending plan "%s" with ID "%s" and subscriptionTier "%s"`,
207-
name,
208-
id,
209-
subscriptionTier,
210-
);
205+
this.logger.info(`Created HBAR spending plan %s with ID %s and subscriptionTier %s`, name, id, subscriptionTier);
211206
}
212207
return plansToAdd.length;
213208
}
@@ -222,7 +217,7 @@ export class HbarSpendingPlanConfigService {
222217
private async updatePlanAssociations(spendingPlanConfigs: SpendingPlanConfig[]): Promise<void> {
223218
for (const planConfig of spendingPlanConfigs) {
224219
this.logger.trace(
225-
`Updating associations for HBAR spending plan '%s' with ID %s...`,
220+
`Updating associations for HBAR spending plan %s with ID %s...`,
226221
planConfig.name,
227222
planConfig.id,
228223
);
@@ -252,7 +247,7 @@ export class HbarSpendingPlanConfigService {
252247
addressesToDelete.map(async (evmAddress) => {
253248
await this.evmAddressHbarSpendingPlanRepository.delete(evmAddress);
254249
this.logger.info(
255-
`Removed association between EVM address %s and HBAR spending plan '%s'`,
250+
`Removed association between EVM address %s and HBAR spending plan %s`,
256251
evmAddress,
257252
planConfig.name,
258253
);
@@ -264,7 +259,7 @@ export class HbarSpendingPlanConfigService {
264259
await Promise.all(
265260
addressesToAdd.map(async (evmAddress) => {
266261
await this.evmAddressHbarSpendingPlanRepository.save({ evmAddress, planId: planConfig.id }, this.TTL);
267-
this.logger.info(`Associated HBAR spending plan '%s' with EVM address %s`, planConfig.name, evmAddress);
262+
this.logger.info(`Associated HBAR spending plan %s with EVM address %s`, planConfig.name, evmAddress);
268263
}),
269264
);
270265
}
@@ -285,15 +280,15 @@ export class HbarSpendingPlanConfigService {
285280
await Promise.all(
286281
addressesToDelete.map(async (ipAddress) => {
287282
await this.ipAddressHbarSpendingPlanRepository.delete(ipAddress);
288-
this.logger.info(`Removed association between IP address and HBAR spending plan '%s'`, planConfig.name);
283+
this.logger.info(`Removed association between IP address and HBAR spending plan %s`, planConfig.name);
289284
}),
290285
);
291286

292287
const addressesToAdd = planConfig.ipAddresses?.filter((ipAddress) => !currentIpAddresses.includes(ipAddress)) || [];
293288
await Promise.all(
294289
addressesToAdd.map(async (ipAddress) => {
295290
await this.ipAddressHbarSpendingPlanRepository.save({ ipAddress, planId: planConfig.id }, this.TTL);
296-
this.logger.info(`Associated HBAR spending plan '%s' with IP address`, planConfig.name);
291+
this.logger.info(`Associated HBAR spending plan %s with IP address`, planConfig.name);
297292
}),
298293
);
299294
}
@@ -313,7 +308,7 @@ export class HbarSpendingPlanConfigService {
313308
const evmAddressPlan = await this.evmAddressHbarSpendingPlanRepository.findByAddress(evmAddress);
314309
if (evmAddressPlan.planId !== planConfig.id) {
315310
this.logger.info(
316-
`Deleting association between EVM address %s and HBAR spending plan '%s'`,
311+
`Deleting association between EVM address %s and HBAR spending plan %s`,
317312
evmAddress,
318313
planConfig.name,
319314
);
@@ -337,7 +332,7 @@ export class HbarSpendingPlanConfigService {
337332
if (exists) {
338333
const ipAddressPlan = await this.ipAddressHbarSpendingPlanRepository.findByAddress(ipAddress);
339334
if (ipAddressPlan.planId !== planConfig.id) {
340-
this.logger.info(`Deleting association between IP address and HBAR spending plan '%s'`, planConfig.name);
335+
this.logger.info(`Deleting association between IP address and HBAR spending plan %s`, planConfig.name);
341336
await this.ipAddressHbarSpendingPlanRepository.delete(ipAddress);
342337
}
343338
}

packages/relay/src/lib/db/repositories/hbarLimiter/evmAddressHbarSpendingPlanRepository.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ export class EvmAddressHbarSpendingPlanRepository {
126126
const errorMessage = evmAddressPlan
127127
? `Removed EVM address ${evmAddress} from HbarSpendingPlan with ID ${evmAddressPlan.planId}`
128128
: `Trying to remove EVM address ${evmAddress}, which is not linked to a spending plan`;
129-
if (this.logger.isLevelEnabled('trace')) {
130-
this.logger.trace(`%s`, errorMessage);
131-
}
129+
this.logger.trace(`%s`, errorMessage);
132130
}
133131

134132
/**

packages/relay/src/lib/db/repositories/hbarLimiter/hbarSpendingPlanRepository.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ export class HbarSpendingPlanRepository {
156156
const callerMethod = this.resetAmountSpentOfAllPlans.name;
157157
const keys = await this.cache.keys(this.getAmountSpentKey('*'), callerMethod);
158158
await Promise.all(keys.map((key) => this.cache.delete(key, callerMethod)));
159-
if (this.logger.isLevelEnabled('trace')) {
160-
this.logger.trace(`Successfully reset %s "amountSpent" entries for HbarSpendingPlans.`, keys.length);
161-
}
159+
this.logger.trace(`Successfully reset %s "amountSpent" entries for HbarSpendingPlans.`, keys.length);
162160
}
163161

164162
/**

packages/relay/src/lib/db/repositories/hbarLimiter/ipAddressHbarSpendingPlanRepository.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ export class IPAddressHbarSpendingPlanRepository {
117117
const errorMessage = ipAddressSpendingPlan
118118
? `Removed IP address from HbarSpendingPlan with ID ${ipAddressSpendingPlan.planId}`
119119
: `Trying to remove an IP address, which is not linked to a spending plan`;
120-
if (this.logger.isLevelEnabled('trace')) {
121-
this.logger.trace(`%s`, errorMessage);
122-
}
120+
this.logger.trace(`%s`, errorMessage);
123121
}
124122

125123
/**

packages/relay/src/lib/debug.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ export class DebugImpl implements Debug {
115115
tracerObject: TransactionTracerConfig,
116116
requestDetails: RequestDetails,
117117
): Promise<any> {
118-
this.logger.trace(`traceTransaction(%s)`, transactionIdOrHash);
119-
120118
//we use a wrapper since we accept a transaction where a second param with tracer/tracerConfig may not be provided
121119
//and we will still default to opcodeLogger
122120
const tracer = tracerObject?.tracer ?? TracerType.OpcodeLogger;
@@ -197,14 +195,6 @@ export class DebugImpl implements Debug {
197195
tracerObject: BlockTracerConfig,
198196
requestDetails: RequestDetails,
199197
): Promise<TraceBlockByNumberTxResult[]> {
200-
if (this.logger.isLevelEnabled('trace')) {
201-
this.logger.trace(
202-
`traceBlockByNumber(blockNumber=%s, tracerObject=%s)`,
203-
blockNumber,
204-
JSON.stringify(tracerObject),
205-
);
206-
}
207-
208198
try {
209199
DebugImpl.requireDebugAPIEnabled();
210200
const blockResponse = await this.common.getHistoricalBlockResponse(requestDetails, blockNumber, true);

packages/relay/src/lib/eth.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ export class EthImpl implements Eth {
219219
@rpcMethod
220220
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
221221
async blockNumber(requestDetails: RequestDetails): Promise<string> {
222-
this.logger.trace(`blockNumber()`);
223222
return await this.common.getLatestBlockNumber(requestDetails);
224223
}
225224

@@ -236,7 +235,6 @@ export class EthImpl implements Eth {
236235
@rpcMethod
237236
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
238237
chainId(): string {
239-
this.logger.trace(`chainId()`);
240238
return this.chain;
241239
}
242240

@@ -304,7 +302,6 @@ export class EthImpl implements Eth {
304302
@rpcMethod
305303
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
306304
async mining(): Promise<boolean> {
307-
this.logger.trace('mining()');
308305
return false;
309306
}
310307

@@ -324,9 +321,6 @@ export class EthImpl implements Eth {
324321
0: { type: 'filter', required: true },
325322
})
326323
async newFilter(params: INewFilterParams, requestDetails: RequestDetails): Promise<string> {
327-
if (this.logger.isLevelEnabled('trace')) {
328-
this.logger.trace(`newFilter(params=%s)`, JSON.stringify(params));
329-
}
330324
return this.filterService.newFilter(params, requestDetails);
331325
}
332326

@@ -345,7 +339,6 @@ export class EthImpl implements Eth {
345339
0: { type: 'hex', required: true },
346340
})
347341
async getFilterLogs(filterId: string, requestDetails: RequestDetails): Promise<Log[]> {
348-
this.logger.trace(`getFilterLogs(%s)`, filterId);
349342
return this.filterService.getFilterLogs(filterId, requestDetails);
350343
}
351344

@@ -364,7 +357,6 @@ export class EthImpl implements Eth {
364357
0: { type: 'hex', required: true },
365358
})
366359
async getFilterChanges(filterId: string, requestDetails: RequestDetails): Promise<string[] | Log[]> {
367-
this.logger.trace(`getFilterChanges(%s)`, filterId);
368360
return this.filterService.getFilterChanges(filterId, requestDetails);
369361
}
370362

@@ -380,7 +372,6 @@ export class EthImpl implements Eth {
380372
@rpcMethod
381373
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
382374
async newBlockFilter(requestDetails: RequestDetails): Promise<string> {
383-
this.logger.trace('newBlockFilter()');
384375
return this.filterService.newBlockFilter(requestDetails);
385376
}
386377

@@ -398,7 +389,6 @@ export class EthImpl implements Eth {
398389
0: { type: 'hex', required: true },
399390
})
400391
async uninstallFilter(filterId: string): Promise<boolean> {
401-
this.logger.trace(`uninstallFilter(%s)`, filterId);
402392
return this.filterService.uninstallFilter(filterId);
403393
}
404394

@@ -414,7 +404,6 @@ export class EthImpl implements Eth {
414404
@rpcMethod
415405
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
416406
newPendingTransactionFilter(): JsonRpcError {
417-
this.logger.trace('newPendingTransactionFilter()');
418407
return predefined.UNSUPPORTED_METHOD;
419408
}
420409

@@ -424,7 +413,6 @@ export class EthImpl implements Eth {
424413
@rpcMethod
425414
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
426415
async submitWork(): Promise<boolean> {
427-
this.logger.trace('submitWork()');
428416
return false;
429417
}
430418

@@ -434,7 +422,6 @@ export class EthImpl implements Eth {
434422
@rpcMethod
435423
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
436424
async syncing(): Promise<boolean> {
437-
this.logger.trace('syncing()');
438425
return false;
439426
}
440427

@@ -516,7 +503,6 @@ export class EthImpl implements Eth {
516503
@rpcMethod
517504
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
518505
async hashrate(): Promise<string> {
519-
this.logger.trace('hashrate()');
520506
return constants.ZERO_HEX;
521507
}
522508

@@ -531,7 +517,6 @@ export class EthImpl implements Eth {
531517
@rpcMethod
532518
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
533519
getWork(): JsonRpcError {
534-
this.logger.trace('getWork()');
535520
return predefined.UNSUPPORTED_METHOD;
536521
}
537522

@@ -546,7 +531,6 @@ export class EthImpl implements Eth {
546531
@rpcMethod
547532
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
548533
submitHashrate(): JsonRpcError {
549-
this.logger.trace('submitHashrate()');
550534
return predefined.UNSUPPORTED_METHOD;
551535
}
552536

@@ -603,7 +587,6 @@ export class EthImpl implements Eth {
603587
@rpcMethod
604588
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
605589
protocolVersion(): JsonRpcError {
606-
this.logger.trace('protocolVersion()');
607590
return predefined.UNSUPPORTED_METHOD;
608591
}
609592

@@ -618,7 +601,6 @@ export class EthImpl implements Eth {
618601
@rpcMethod
619602
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
620603
coinbase(): JsonRpcError {
621-
this.logger.trace('coinbase()');
622604
return predefined.UNSUPPORTED_METHOD;
623605
}
624606

@@ -633,7 +615,6 @@ export class EthImpl implements Eth {
633615
@rpcMethod
634616
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
635617
simulateV1(): JsonRpcError {
636-
this.logger.trace('simulateV1()');
637618
return predefined.UNSUPPORTED_METHOD;
638619
}
639620

@@ -648,7 +629,6 @@ export class EthImpl implements Eth {
648629
@rpcMethod
649630
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
650631
blobBaseFee(): JsonRpcError {
651-
this.logger.trace('blobBaseFee()');
652632
return predefined.UNSUPPORTED_METHOD;
653633
}
654634

@@ -1069,7 +1049,6 @@ export class EthImpl implements Eth {
10691049
@rpcMethod
10701050
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
10711051
async maxPriorityFeePerGas(): Promise<string> {
1072-
this.logger.trace('maxPriorityFeePerGas()');
10731052
return constants.ZERO_HEX;
10741053
}
10751054

@@ -1108,7 +1087,6 @@ export class EthImpl implements Eth {
11081087
@rpcMethod
11091088
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
11101089
getProof(): JsonRpcError {
1111-
this.logger.trace('getProof()');
11121090
return predefined.UNSUPPORTED_METHOD;
11131091
}
11141092

@@ -1124,7 +1102,6 @@ export class EthImpl implements Eth {
11241102
@rpcMethod
11251103
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
11261104
createAccessList(): JsonRpcError {
1127-
this.logger.trace('createAccessList()');
11281105
return predefined.UNSUPPORTED_METHOD;
11291106
}
11301107
}

packages/relay/src/lib/services/ethService/accountService/AccountService.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ export class AccountService implements IAccountService {
112112
blockNumberOrTagOrHash: string,
113113
requestDetails: RequestDetails,
114114
): Promise<string> {
115-
this.logger.trace(`getBalance(account=%s, blockNumberOrTag=%s)`, account, blockNumberOrTagOrHash);
116-
117115
let latestBlock: LatestBlockNumberTimestamp | null | undefined;
118116
// this check is required, because some tools like Metamask pass for parameter latest block, with a number (ex 0x30ea)
119117
// tolerance is needed, because there is a small delay between requesting latest block from blockNumber and passing it here
@@ -311,8 +309,6 @@ export class AccountService implements IAccountService {
311309
blockNumOrTag: string,
312310
requestDetails: RequestDetails,
313311
): Promise<string | JsonRpcError> {
314-
this.logger.trace(`getTransactionCount(address=%s, blockNumOrTag=%s)`, address, blockNumOrTag);
315-
316312
const blockNum = Number(blockNumOrTag);
317313
if (blockNum === 0 || blockNum === 1) {
318314
// previewnet and testnet bug have a genesis blockNumber of 1 but non system account were yet to be created
@@ -342,8 +338,6 @@ export class AccountService implements IAccountService {
342338
caller: string,
343339
requestDetails: RequestDetails,
344340
): Promise<LatestBlockNumberTimestamp> {
345-
this.logger.trace(`blockNumber()`);
346-
347341
const cacheKey = `${constants.CACHE_KEY.ETH_BLOCK_NUMBER}`;
348342

349343
const blocksResponse = await this.mirrorNodeClient.getLatestBlock(requestDetails);

0 commit comments

Comments
 (0)