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

chore: Implement memory leak detection in tests #2695

Merged
merged 52 commits into from
Jul 30, 2024

Conversation

victor-yanev
Copy link
Contributor

@victor-yanev victor-yanev commented Jul 11, 2024

Description:

This PR introduces a method captureMemoryLeaks to detect and report potential memory leaks in test suites, enhancing the reliability and performance of applications by ensuring early detection and resolution of memory leaks.

It leverages the V8 engine's garbage collection (GC) profiling capabilities to monitor memory usage before and after test execution, identifying significant increases in totalHeapSize that may indicate a memory leak.

  1. Initialization: The method begins by enabling the garbage collection (GC) through the setFlagsFromString('--expose_gc') command. This allows for manual triggering of garbage collection within the test environment.
  2. Test Setup: Before each test case runs, profiler.start() is called to set up the GC profiler to monitor heap usage and other GC-related statistics during the test execution.
  3. Test Teardown: After each test case completes, several critical actions are performed:
    • Garbage collection is manually triggered using await gc() to ensure that all unreferenced objects are cleared from memory. This step aims to capture the most accurate state of the heap after test execution.
    • The GC profiler is then stopped with profiler.stop(), and the method collects the GC statistics, including heap sizes before and after the GC.
    • The method calculates the total difference in heap size before and after the test execution. If this difference exceeds 500KB (defined as HEAP_SIZE_DIFF_MEMORY_LEAK_THRESHOLD), it indicates a potential memory leak.
    • For tests that potentially leak memory, detailed statistics about the memory usage and the specific areas of the heap that have grown are compiled into a report. This includes information such as the type of garbage collection event, the cost (in milliseconds) of the GC, and detailed heap statistics before and after the test.
    • A comment is generated with the memory leak report and is programmatically added or updated in a pull request (PR) associated with the test suite. This comment includes a header indicating a memory leak detection, a summary of the issue, detailed statistics, and recommendations for further investigation.
    • Optionally, if enabled through an environment variable (WRITE_SNAPSHOT_ON_MEMORY_LEAK), a heap snapshot is taken for leaks exceeding 1MB (defined as HEAP_SIZE_DIFF_SNAPSHOT_THRESHOLD). This snapshot can be used for a more in-depth analysis of the memory allocation and retention patterns. (this env is disabled everywhere by default and can be enabled locally by the person who is investigating the memory leak)

Related issue(s):

Fixes #2260

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
@victor-yanev victor-yanev added the enhancement New feature or request label Jul 11, 2024
@victor-yanev victor-yanev self-assigned this Jul 11, 2024
Copy link

github-actions bot commented Jul 11, 2024

Acceptance Tests

     33 files     353 suites   50m 21s ⏱️
   610 tests    588 ✔️ 4 💤 18
1 506 runs  1 462 ✔️ 4 💤 40

Results for commit 7ba48a4.

♻️ This comment has been updated with latest results.

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
…ction-Test

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
@victor-yanev victor-yanev added this to the 0.53.0 milestone Jul 12, 2024
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	package-lock.json
#	package.json
#	packages/server/tsconfig.json
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	package-lock.json
#	package.json
#	packages/server/tsconfig.json
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	packages/server/tests/acceptance/index.spec.ts
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	packages/server/tests/acceptance/index.spec.ts
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	packages/server/tests/acceptance/index.spec.ts
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
@hashgraph hashgraph deleted a comment from github-actions bot Jul 19, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Jul 19, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Jul 19, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Jul 19, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Jul 19, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Jul 19, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Jul 19, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Jul 19, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Jul 19, 2024
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Copy link
Collaborator

@ebadiere ebadiere left a comment

Choose a reason for hiding this comment

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

Nice work! Once this is merged it will get picked up in CI. I'd like to discuss briefly some window of time during the first release when this is run, and you can be available if the CI breaks down. CI updates can make releases interesting.

ebadiere and others added 3 commits July 23, 2024 15:08
Signed-off-by: Eric Badiere <ebadiere@gmail.com>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Copy link

sonarcloud bot commented Jul 26, 2024

Copy link
Member

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

Wonderful work 🚀 🚀 !! Some qqs

packages/server/tests/helpers/utils.ts Show resolved Hide resolved
packages/server/tests/helpers/utils.ts Show resolved Hide resolved
packages/server/tests/helpers/utils.ts Show resolved Hide resolved
packages/server/tests/integration/test.env Show resolved Hide resolved
@victor-yanev victor-yanev merged commit 59ede4c into main Jul 30, 2024
36 checks passed
@victor-yanev victor-yanev deleted the 2260-Implement-a-Memory-Leak-detection-Test branch July 30, 2024 08:52
ebadiere added a commit that referenced this pull request Aug 1, 2024
* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: add docs

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: fix sonar issues

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: small fix

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: trace GC and write snapshot if memory leak > 0.5 MB

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: revert false changes to eth.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: optimize code

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* Merge branch 'main' into 2260-Implement-a-Memory-Leak-detection-Test

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	package-lock.json
#	package.json
#	packages/server/tsconfig.json

* fix: Do not write heap snapshots for acceptance tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: add TODO for removing --trace_gc flag

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: add github comment in cases a test is having memory leaks

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: add github context env variables

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: extract common logic for github api calls

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: console.debug -> console.log for successful PR comments

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: fix request to github API

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* Merge branch 'main' into 2260-Implement-a-Memory-Leak-detection-Test

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	packages/server/tests/acceptance/index.spec.ts

* Merge branch 'main' into 2260-Implement-a-Memory-Leak-detection-Test

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	packages/server/tests/acceptance/index.spec.ts

* fix: request to github API

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: add upload heap snapshots step in github workflow for acceptance and integration tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: add `subject_type: file` to github request for adding comment on PR

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: fix path in request to github API

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: extract github request logic in new file - githubClient.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: path of upload-artifact action for uploading heap snapshots

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: requests in githubClient.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: requests in githubClient.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: format message of github-actions[bot]

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: format message of github-actions[bot]

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: remove unused github context env variable

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: `formatBytes` returns `NaN undefined` when `0` is passed to it

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: `formatBytes` returns `NaN undefined` when negative number is passed to it

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: predicate for updating existing comment

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: remove unused constant + temporary console logs

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: make memory leak report more descriptive

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: remove unnecessary console logs

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: reduce MEMORY_LEAK_SNAPSHOT_THRESHOLD to 500 KB

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: update logic for detecting memory leak based on heap size threshold

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: add separate threshold for taking heap snapshots

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: set `WRITE_SNAPSHOT_ON_MEMORY_LEAK` to be `false` by default

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: add warm-up phase to memory leak detection

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: revert changes to rpc_batch1.spec.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

---------

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Eric Badiere <ebadiere@gmail.com>
Co-authored-by: Eric Badiere <ebadiere@gmail.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>
ebadiere added a commit that referenced this pull request Aug 1, 2024
* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: add docs

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: fix sonar issues

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: small fix

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: trace GC and write snapshot if memory leak > 0.5 MB

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: revert false changes to eth.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: optimize code

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* Merge branch 'main' into 2260-Implement-a-Memory-Leak-detection-Test

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	package-lock.json
#	package.json
#	packages/server/tsconfig.json

* fix: Do not write heap snapshots for acceptance tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: add TODO for removing --trace_gc flag

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: add github comment in cases a test is having memory leaks

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: add github context env variables

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: extract common logic for github api calls

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: console.debug -> console.log for successful PR comments

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: fix request to github API

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* Merge branch 'main' into 2260-Implement-a-Memory-Leak-detection-Test

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	packages/server/tests/acceptance/index.spec.ts

* Merge branch 'main' into 2260-Implement-a-Memory-Leak-detection-Test

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	packages/server/tests/acceptance/index.spec.ts

* fix: request to github API

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: add upload heap snapshots step in github workflow for acceptance and integration tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: add `subject_type: file` to github request for adding comment on PR

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: fix path in request to github API

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: extract github request logic in new file - githubClient.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: path of upload-artifact action for uploading heap snapshots

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: requests in githubClient.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: requests in githubClient.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: format message of github-actions[bot]

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: format message of github-actions[bot]

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: remove unused github context env variable

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: `formatBytes` returns `NaN undefined` when `0` is passed to it

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: `formatBytes` returns `NaN undefined` when negative number is passed to it

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: predicate for updating existing comment

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: remove unused constant + temporary console logs

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: make memory leak report more descriptive

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: remove unnecessary console logs

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: reduce MEMORY_LEAK_SNAPSHOT_THRESHOLD to 500 KB

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: update logic for detecting memory leak based on heap size threshold

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: add separate threshold for taking heap snapshots

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: set `WRITE_SNAPSHOT_ON_MEMORY_LEAK` to be `false` by default

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: add warm-up phase to memory leak detection

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: revert changes to rpc_batch1.spec.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

---------

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Eric Badiere <ebadiere@gmail.com>
Co-authored-by: Eric Badiere <ebadiere@gmail.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>
ebadiere added a commit that referenced this pull request Aug 1, 2024
* test: added E2E test for preemtive rate limit (#2753)

* test: added E2E test fir preemtive rate limit

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* Update hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

---------

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>

* test: expand integration tests for SDK client (#2756)

* test: expand integration tests for SDK client

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: minor improvements to sdkClient.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: typescript error

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: simplify test data

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: fix typescript errors and warnings

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: optimize imports

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: address comments

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: improve readability of tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: fix wrong MIRROR_NODE_LIMIT_PARAM in relay tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: wrong env file loaded

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: remove hardcoded usages of MIRROR_NODE_LIMIT_PARAM in relay tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: revert changes to rpc_batch1.spec.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: remove unused import

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: fix test after merge

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: fix test after merge

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: revert changes to usages of MIRROR_NODE_LIMIT_PARAM

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: revert changes to usages of MIRROR_NODE_LIMIT_PARAM

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

---------

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: ebadiere <ebadiere@gmail.com>

* feat: search contract logs only by transaction hash (#2762)

* chore: refactor eth.ts

Signed-off-by: nikolay <n.atanasow94@gmail.com>

* chore: bump hedera-local version

Signed-off-by: nikolay <n.atanasow94@gmail.com>

---------

Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>

* chore: Implement memory leak detection in tests (#2695)

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: Implement memory leak detection in tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: add docs

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: fix sonar issues

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: small fix

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: trace GC and write snapshot if memory leak > 0.5 MB

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: revert false changes to eth.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: optimize code

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* Merge branch 'main' into 2260-Implement-a-Memory-Leak-detection-Test

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	package-lock.json
#	package.json
#	packages/server/tsconfig.json

* fix: Do not write heap snapshots for acceptance tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: add TODO for removing --trace_gc flag

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: add github comment in cases a test is having memory leaks

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: add github context env variables

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: extract common logic for github api calls

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: console.debug -> console.log for successful PR comments

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: fix request to github API

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* Merge branch 'main' into 2260-Implement-a-Memory-Leak-detection-Test

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	packages/server/tests/acceptance/index.spec.ts

* Merge branch 'main' into 2260-Implement-a-Memory-Leak-detection-Test

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

# Conflicts:
#	packages/server/tests/acceptance/index.spec.ts

* fix: request to github API

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: add upload heap snapshots step in github workflow for acceptance and integration tests

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: add `subject_type: file` to github request for adding comment on PR

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: fix path in request to github API

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: extract github request logic in new file - githubClient.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: path of upload-artifact action for uploading heap snapshots

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: requests in githubClient.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: requests in githubClient.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: format message of github-actions[bot]

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: format message of github-actions[bot]

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: remove unused github context env variable

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: formatting

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: `formatBytes` returns `NaN undefined` when `0` is passed to it

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: `formatBytes` returns `NaN undefined` when negative number is passed to it

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: predicate for updating existing comment

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: remove unused constant + temporary console logs

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: make memory leak report more descriptive

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: remove unnecessary console logs

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: reduce MEMORY_LEAK_SNAPSHOT_THRESHOLD to 500 KB

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: update logic for detecting memory leak based on heap size threshold

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: add separate threshold for taking heap snapshots

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* fix: set `WRITE_SNAPSHOT_ON_MEMORY_LEAK` to be `false` by default

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* test: add warm-up phase to memory leak detection

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

* chore: revert changes to rpc_batch1.spec.ts

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>

---------

Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Eric Badiere <ebadiere@gmail.com>
Co-authored-by: Eric Badiere <ebadiere@gmail.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>

* feat: deprecate `ETH_POPULATE_SYNTHETIC_CONTRACT_RESULTS` env (#2768)

* chore: remove env

Signed-off-by: nikolay <n.atanasow94@gmail.com>

* chore: modify test

Signed-off-by: nikolay <n.atanasow94@gmail.com>

---------

Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>

* Bump versions for v0.53.0-rc1

Signed-off-by: Swirlds Automation <swirlds-eng-automation@swirlds.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>

* feat: reused executetransaction for methods in sdkclient and improved… (#2776)

feat: reused executetransaction for methods in sdkclient and improved logging (#2749)

* fix: reused executeTransaction() in deleteFile() method

* fix: reworked executeTransaction() to accept executeAll

* feat: fix: reused executeTransaction() in fileCreate() method

* fix: removed check rate limit in executeGetTransactionRecord

* fix: fixed SDK HBAR limiter tests

* fix: reverted rework executeTransaction()

* fix: reworked formatRequestIdMessage

* feat: added executeAllTransaction() method

* fix: made shouldLimit optional in executeTransaction()

* Update packages/relay/src/lib/clients/sdkClient.ts

* fix: addressed comments

* fix: extracted handleExecuteAllError()

* fix: renamed handleExecuteAllError to getTransactionMetrics and reuse it in executeTransaction

---------

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Signed-off-by: Logan Nguyen <logan@quiet-node.dev>
Co-authored-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Co-authored-by: Victor Yanev <161485803+victor-yanev@users.noreply.github.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>

* Bump versions for v0.53.0-rc2

Signed-off-by: Swirlds Automation <swirlds-eng-automation@swirlds.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>

* fix: reduce hbar limit only by operator fees (#2755)

* fix: reduce hbar limit only by operator fees

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* chore: update expected values

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* chore: fix code smells

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* nit: re-trigger ci

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* chore: addressing comments

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* fix: hbar limit error handle

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* fix: reduce test flakiness

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* fix: reduce test flakiness

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* nit: update comment

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* fix: unit test mocks

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* fix: update assertions and mocks

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

---------

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>
Signed-off-by: Eric Badiere <ebadiere@gmail.com>
Co-authored-by: Eric Badiere <ebadiere@gmail.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>

---------

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Signed-off-by: ebadiere <ebadiere@gmail.com>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: Eric Badiere <ebadiere@gmail.com>
Signed-off-by: Swirlds Automation <swirlds-eng-automation@swirlds.com>
Signed-off-by: Logan Nguyen <logan@quiet-node.dev>
Signed-off-by: Ivo Yankov <ivo@devlabs.bg>
Co-authored-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Co-authored-by: Victor Yanev <161485803+victor-yanev@users.noreply.github.com>
Co-authored-by: Nikolay Atanasow <n.atanasow94@gmail.com>
Co-authored-by: Swirlds Automation <swirlds-eng-automation@swirlds.com>
Co-authored-by: Ivo Yankov <ivo@devlabs.bg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request limechain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a Memory Leak detection Test
3 participants