Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Makes ICacheClient return type promise and changes LRUCache accordingly #2410

Conversation

konstantinabl
Copy link
Collaborator

@konstantinabl konstantinabl commented Apr 25, 2024

Description:
Currently, the redisCache service is implementing the ICacheClient interface. However, in this interface the methods are not asynchronous as it should be when we are using redis. The goal of this PR is to change the interface and make the methods asynchronous as well as adding specific interface for redis and the internal cache.

Main Files Changed

  1. ICacheClient.ts: Added Promise return types.
  2. IRedisCacheClient.ts: Added an interface for the RedisCache service.
  3. localLRUCache.ts: Changed method return types to Promise.
  4. redisCache.ts: Changed method return types to Promise and added 'await' for asynchronous methods.
  5. eth.ts: Updated methods to use Promise return types and added 'await'.
  6. cacheService.ts: Made methods asynchronous, added return types, and implemented conditions to use internalCache when Redis is unavailable.
  7. Test files: Updated tests to comply with new logic.

Type of Change:

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring

Related issue(s):
Fixes #2387

@konstantinabl konstantinabl force-pushed the 2387-interface-for-redis-and-lru-cache-icacheclient-has-void-return-types-instead-of-promisevoid branch from bad263e to 48370eb Compare April 25, 2024 11:39
Copy link

sonarcloud bot commented Apr 25, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@konstantinabl konstantinabl force-pushed the 2387-interface-for-redis-and-lru-cache-icacheclient-has-void-return-types-instead-of-promisevoid branch 2 times, most recently from 1291746 to 5ea2204 Compare July 16, 2024 10:54
@konstantinabl konstantinabl changed the title Makes ICacheClient return type promise and changes LRUCache accordingly fix: Makes ICacheClient return type promise and changes LRUCache accordingly Jul 16, 2024
@konstantinabl konstantinabl added the bug Something isn't working label Jul 16, 2024
@konstantinabl konstantinabl added this to the 0.53.0 milestone Jul 16, 2024
Copy link

github-actions bot commented Jul 16, 2024

Tests

    3 files  165 suites   14s ⏱️
885 tests 884 ✔️ 1 💤 0
898 runs  897 ✔️ 1 💤 0

Results for commit 6220250.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 16, 2024

Acceptance Tests

  19 files  246 suites   30m 1s ⏱️
613 tests 605 ✔️ 4 💤 4
806 runs  798 ✔️ 4 💤 4

Results for commit 6220250.

♻️ This comment has been updated with latest results.

@konstantinabl konstantinabl marked this pull request as ready for review July 17, 2024 13:21
Copy link
Contributor

@victor-yanev victor-yanev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, I left a few suggestions

@konstantinabl konstantinabl force-pushed the 2387-interface-for-redis-and-lru-cache-icacheclient-has-void-return-types-instead-of-promisevoid branch from bf2b252 to 9740166 Compare July 30, 2024 08:47
victor-yanev
victor-yanev previously approved these changes Jul 30, 2024
@konstantinabl konstantinabl force-pushed the 2387-interface-for-redis-and-lru-cache-icacheclient-has-void-return-types-instead-of-promisevoid branch from 9740166 to 83ff74e Compare July 30, 2024 10:16
Copy link

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled should execute "eth_getTransactionByHash with missing transaction". This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact
Cost: 30,396.7 ms

Heap Statistics (before vs after executing the test):

  • Total Heap Size: increased with 524.29 KB
  • Total Heap Size Executable: no changes
  • Total Physical Size: increased with 524.29 KB
  • Total Available Size: increased with 2.56 MB
  • Total Global Handles Size: no changes
  • Used Global Handles Size: decreased with 64.00 bytes
  • Used Heap Size: decreased with 2.57 MB
  • Heap Size Limit: no changes
  • Malloced Memory: no changes
  • External Memory: no changes
  • Peak Malloced Memory: no changes

Heap Space Statistics (before vs after executing the test):

  • Old Space:
    • Space Size: increased with 524.29 KB
    • Space Used Size: increased with 540.25 KB
    • Space Available Size: increased with 217.37 KB
    • Physical Space Size: increased with 524.29 KB

Recommendations

Please investigate the memory allocations in this test, focusing on objects that are not being properly deallocated.

@konstantinabl konstantinabl force-pushed the 2387-interface-for-redis-and-lru-cache-icacheclient-has-void-return-types-instead-of-promisevoid branch from 83ff74e to d2700ba Compare July 31, 2024 10:42
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
…ined via ? operator

Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
@konstantinabl konstantinabl force-pushed the 2387-interface-for-redis-and-lru-cache-icacheclient-has-void-return-types-instead-of-promisevoid branch from 5b81b10 to 7a53da8 Compare August 6, 2024 14:04
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Copy link

sonarcloud bot commented Aug 6, 2024

Copy link

codecov bot commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 88.15789% with 9 lines in your changes missing coverage. Please review.

Project coverage is 77.86%. Comparing base (750f590) to head (6220250).
Report is 1 commits behind head on main.

Files Patch % Lines
...elay/src/lib/services/cacheService/cacheService.ts 61.11% 4 Missing and 3 partials ⚠️
...kages/relay/src/lib/clients/cache/localLRUCache.ts 66.66% 1 Missing ⚠️
packages/relay/src/lib/eth.ts 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2410      +/-   ##
==========================================
+ Coverage   77.44%   77.86%   +0.41%     
==========================================
  Files          43       43              
  Lines        3330     3329       -1     
  Branches      707      706       -1     
==========================================
+ Hits         2579     2592      +13     
+ Misses        505      491      -14     
  Partials      246      246              
Flag Coverage Δ
relay 78.95% <88.15%> (+0.60%) ⬆️
server 74.61% <ø> (-0.31%) ⬇️
ws-server 61.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/relay/src/lib/clients/cache/redisCache.ts 44.44% <100.00%> (+6.34%) ⬆️
packages/relay/src/lib/clients/mirrorNodeClient.ts 88.43% <100.00%> (ø)
packages/relay/src/lib/clients/sdkClient.ts 50.74% <100.00%> (ø)
.../lib/services/ethService/ethCommonService/index.ts 89.14% <100.00%> (+0.08%) ⬆️
.../lib/services/ethService/ethFilterService/index.ts 80.00% <100.00%> (+1.25%) ⬆️
...kages/relay/src/lib/clients/cache/localLRUCache.ts 78.78% <66.66%> (+2.31%) ⬆️
packages/relay/src/lib/eth.ts 81.57% <96.29%> (ø)
...elay/src/lib/services/cacheService/cacheService.ts 63.76% <61.11%> (+11.06%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Collaborator

@georgi-l95 georgi-l95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, a step in the right direction.

@konstantinabl konstantinabl merged commit d74f13b into main Aug 7, 2024
37 of 38 checks passed
@konstantinabl konstantinabl deleted the 2387-interface-for-redis-and-lru-cache-icacheclient-has-void-return-types-instead-of-promisevoid branch August 7, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Interface for Redis and LRU cache (ICacheClient) has void return types instead of Promise<void>
3 participants