hashgraph / hedera-json-rpc-relay

Implementation of Ethereum JSON-RPC APIs for Hedera
Apache License 2.0
68 stars 72 forks source link

fix: Protect preconfigured spending plans from being deleted automatically in `LRUCache` #3140

Closed victor-yanev closed 3 weeks ago

victor-yanev commented 4 weeks ago

Description:

This PR introduces changes to ensure that preconfigured HBAR spending plans are protected from automatic deletion by the LRUCache on reaching the maximum cache size.

Includes the following updates:

Related issue(s):

Fixes #3096

Notes for reviewer:

Checklist

github-actions[bot] commented 4 weeks ago

Acceptance Tests

  20 files  256 suites   38m 2s :stopwatch: 599 tests 574 :heavy_check_mark: 4 :zzz: 21 :x: 728 runs  701 :heavy_check_mark: 4 :zzz: 23 :x:

Results for commit 5002fe43.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 4 weeks ago

Tests

       3 files     398 suites   18s :stopwatch: 1 418 tests 1 417 :heavy_check_mark: 1 :zzz: 0 :x: 1 427 runs  1 426 :heavy_check_mark: 1 :zzz: 0 :x:

Results for commit 5002fe43.

github-actions[bot] commented 4 weeks ago

Test Results

 19 files   -  1  251 suites   - 32   32m 39s :stopwatch: - 1m 56s 607 tests + 2  598 :white_check_mark: + 7  4 :zzz: ±0  5 :x:  - 5  696 runs   - 98  687 :white_check_mark:  - 93  4 :zzz: ±0  5 :x:  - 5 

For more details on these failures, see this check.

Results for commit dc49c9df. ± Comparison against base commit 9afe7c21.

This pull request removes 1 and adds 3 tests. Note that renamed tests count towards both. ``` "before all" hook in "@tokenmanagement HTS Precompile Token Management Acceptance Tests" ‑ RPC Server Acceptance Tests Acceptance tests @tokenmanagement HTS Precompile Token Management Acceptance Tests "before all" hook in "@tokenmanagement HTS Precompile Token Management Acceptance Tests" ``` ``` "before all" hook for "should execute "eth_getCode" for hts token" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode "before all" hook for "should execute "eth_getCode" for hts token" "before all" hook in "@api-batch-2 RPC Server Acceptance Tests" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests "before all" hook in "@api-batch-2 RPC Server Acceptance Tests" "before each" hook for "should execute "eth_getStorageAt" request to get current state changes" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests "before each" hook for "should execute "eth_getStorageAt" request to get current state changes" ```

:recycle: This comment has been updated with latest results.

sonarcloud[bot] commented 3 weeks ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
2 Accepted issues

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

See analysis details on SonarCloud

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled validates enforcement of request id. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 28,715.7 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

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

Details

📊 Memory Leak Detection Report 📊

GC Type: Scavenge Cost: 784.991 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 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: Scavenge Cost: 6,341.77 ms

Heap Statistics (before vs after executing the test):

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

GC Type: Scavenge Cost: 4,331.32 ms

Heap Statistics (before vs after executing the test):

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

GC Type: MarkSweepCompact Cost: 35,614.5 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

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

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 22,483.3 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

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

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 22,622.1 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled should not execute batch request when disabled. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 25,023.9 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled validates parameter 1 is valid block tag. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 24,004.4 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled validates parameter 1 exists. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 27,262.9 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled validates parameter 0 exists. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 25,286.9 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled validates toBlock filter. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 26,233.3 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled should execute metrics collection. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: Scavenge Cost: 3,357.12 ms

Heap Statistics (before vs after executing the test):

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

GC Type: Scavenge Cost: 2,540.88 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled should execute with valid hash, valid TracerType and empty TracerConfig. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 48,585.7 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled should execute with empty TracerConfigWrapper.tracerConfig. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 25,461.2 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled should fail with valid hash and invalid TracerType string. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 33,784.5 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled throws an error if address is NOT 0x prefixed. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 38,176.7 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled throws an error if the param is not an array. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 28,368.4 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled throws error if block number is not correct tag. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 37,390 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled throws an error for input: {"tracer":"opcodeLogger","tracerConfig":{"disableStack":"invalid"}}. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 26,701.9 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled does not throw an error for input: {"tracer":"opcodeLogger","tracerConfig":{}}. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 27,439 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

github-actions[bot] commented 3 weeks ago

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled should return the limit duration from environment variable. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact Cost: 37,021.4 ms

Heap Statistics (before vs after executing the test):

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

Recommendations

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

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 95.45455% with 2 lines in your changes missing coverage. Please review.

Project coverage is 83.37%. Comparing base (9afe7c2) to head (dc49c9d). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...barLimiter/ethAddressHbarSpendingPlanRepository.ts 50.00% 0 Missing and 1 partial :warning:
packages/relay/src/lib/eth.ts 0.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3140 +/- ## ========================================== - Coverage 85.59% 83.37% -2.23% ========================================== Files 48 66 +18 Lines 3395 4277 +882 Branches 670 832 +162 ========================================== + Hits 2906 3566 +660 - Misses 283 471 +188 - Partials 206 240 +34 ``` | [Flag](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph) | Coverage Δ | | |---|---|---| | [config-service](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph) | `98.14% <ø> (ø)` | | | [relay](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph) | `85.58% <95.45%> (+0.18%)` | :arrow_up: | | [server](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph) | `83.52% <ø> (?)` | | | [ws-server](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph) | `36.87% <ø> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files with missing lines](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph) | Coverage Δ | | |---|---|---| | [...ckages/config-service/src/services/globalConfig.ts](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140?src=pr&el=tree&filepath=packages%2Fconfig-service%2Fsrc%2Fservices%2FglobalConfig.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph#diff-cGFja2FnZXMvY29uZmlnLXNlcnZpY2Uvc3JjL3NlcnZpY2VzL2dsb2JhbENvbmZpZy50cw==) | `100.00% <ø> (ø)` | | | [...kages/relay/src/lib/clients/cache/localLRUCache.ts](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140?src=pr&el=tree&filepath=packages%2Frelay%2Fsrc%2Flib%2Fclients%2Fcache%2FlocalLRUCache.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph#diff-cGFja2FnZXMvcmVsYXkvc3JjL2xpYi9jbGllbnRzL2NhY2hlL2xvY2FsTFJVQ2FjaGUudHM=) | `93.75% <100.00%> (+0.89%)` | :arrow_up: | | [...ay/src/lib/config/hbarSpendingPlanConfigService.ts](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140?src=pr&el=tree&filepath=packages%2Frelay%2Fsrc%2Flib%2Fconfig%2FhbarSpendingPlanConfigService.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph#diff-cGFja2FnZXMvcmVsYXkvc3JjL2xpYi9jb25maWcvaGJhclNwZW5kaW5nUGxhbkNvbmZpZ1NlcnZpY2UudHM=) | `98.09% <100.00%> (+0.26%)` | :arrow_up: | | [...sitories/hbarLimiter/hbarSpendingPlanRepository.ts](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140?src=pr&el=tree&filepath=packages%2Frelay%2Fsrc%2Flib%2Fdb%2Frepositories%2FhbarLimiter%2FhbarSpendingPlanRepository.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph#diff-cGFja2FnZXMvcmVsYXkvc3JjL2xpYi9kYi9yZXBvc2l0b3JpZXMvaGJhckxpbWl0ZXIvaGJhclNwZW5kaW5nUGxhblJlcG9zaXRvcnkudHM=) | `100.00% <100.00%> (ø)` | | | [...hbarLimiter/ipAddressHbarSpendingPlanRepository.ts](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140?src=pr&el=tree&filepath=packages%2Frelay%2Fsrc%2Flib%2Fdb%2Frepositories%2FhbarLimiter%2FipAddressHbarSpendingPlanRepository.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph#diff-cGFja2FnZXMvcmVsYXkvc3JjL2xpYi9kYi9yZXBvc2l0b3JpZXMvaGJhckxpbWl0ZXIvaXBBZGRyZXNzSGJhclNwZW5kaW5nUGxhblJlcG9zaXRvcnkudHM=) | `94.87% <100.00%> (ø)` | | | [packages/relay/src/lib/relay.ts](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140?src=pr&el=tree&filepath=packages%2Frelay%2Fsrc%2Flib%2Frelay.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph#diff-cGFja2FnZXMvcmVsYXkvc3JjL2xpYi9yZWxheS50cw==) | `88.57% <100.00%> (+0.16%)` | :arrow_up: | | [...elay/src/lib/services/cacheService/cacheService.ts](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140?src=pr&el=tree&filepath=packages%2Frelay%2Fsrc%2Flib%2Fservices%2FcacheService%2FcacheService.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph#diff-cGFja2FnZXMvcmVsYXkvc3JjL2xpYi9zZXJ2aWNlcy9jYWNoZVNlcnZpY2UvY2FjaGVTZXJ2aWNlLnRz) | `92.59% <100.00%> (+0.05%)` | :arrow_up: | | [...barLimiter/ethAddressHbarSpendingPlanRepository.ts](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140?src=pr&el=tree&filepath=packages%2Frelay%2Fsrc%2Flib%2Fdb%2Frepositories%2FhbarLimiter%2FethAddressHbarSpendingPlanRepository.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph#diff-cGFja2FnZXMvcmVsYXkvc3JjL2xpYi9kYi9yZXBvc2l0b3JpZXMvaGJhckxpbWl0ZXIvZXRoQWRkcmVzc0hiYXJTcGVuZGluZ1BsYW5SZXBvc2l0b3J5LnRz) | `92.30% <50.00%> (ø)` | | | [packages/relay/src/lib/eth.ts](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140?src=pr&el=tree&filepath=packages%2Frelay%2Fsrc%2Flib%2Feth.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph#diff-cGFja2FnZXMvcmVsYXkvc3JjL2xpYi9ldGgudHM=) | `82.20% <0.00%> (ø)` | | ... and [20 files with indirect coverage changes](https://app.codecov.io/gh/hashgraph/hedera-json-rpc-relay/pull/3140/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hashgraph)