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

feat: replaced HbarLimit module with the new HbarLimitService class #3024

Conversation

quiet-node
Copy link
Member

Description:

  • This PR replaces all usages of the HbarLimit module with the new HbarLimitService class in the SdkClient and MetricService classes.
  • Removes the HbarLimit module from the codebase.
  • The addExpense logic in the new HbarLimitService has been updated to accept a nullable ethAddress value. Certain queries, such as getAccountInfo, getBalanceInfo, FileContentsQuery, etc., also add expenses to remainingBalance but don’t always require an originalCaller (ethAddress). Therefore, addExpense can now handle a nullable ethAddress value. If either ethAddress or ipAddress is valid, the spendingPlan logic is applied. Otherwise, it is skipped entirely.
  • Moved the preemptive rate limit logic to the sdkClient.createFile() method.
  • Related tests have been updated to align with the new HbarLimitService class.
  • Updated log messages accordingly.

Related issue(s):

Fixes #2896

Notes for reviewer:

Checklist

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

@quiet-node quiet-node added the enhancement New feature or request label Sep 21, 2024
@quiet-node quiet-node added this to the 0.57.0 milestone Sep 21, 2024
@quiet-node quiet-node self-assigned this Sep 21, 2024
Copy link

github-actions bot commented Sep 21, 2024

Tests

       3 files     397 suites   18s ⏱️
1 412 tests 1 411 ✔️ 1 💤 0
1 421 runs  1 420 ✔️ 1 💤 0

Results for commit 97f66d8.

♻️ This comment has been updated with latest results.

@quiet-node quiet-node marked this pull request as draft September 21, 2024 00:55
Copy link

github-actions bot commented Sep 21, 2024

Acceptance Tests

  19 files  238 suites   30m 41s ⏱️
599 tests 592 ✔️ 4 💤 3
628 runs  620 ✔️ 4 💤 4

Results for commit 15cfe72.

♻️ This comment has been updated with latest results.

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.

Please, avoid introducing unnecessary changes unrelated to what is asked from the issue:

  • it makes the PR harder to review, because it is cluttered with too many empty / unrelated changes
  • makes it easier to slip in bugs, because reviewers might overlook an important change among all the "empty" changes which surround it
  • wastes other people's time because it creates unnecessary conflicts with other PRs

packages/relay/src/lib/clients/sdkClient.ts Show resolved Hide resolved
packages/relay/src/lib/clients/sdkClient.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/clients/sdkClient.ts Show resolved Hide resolved
packages/relay/src/lib/constants.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/relay.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/services/hbarLimitService/index.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/services/hbarLimitService/index.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/services/hbarLimitService/index.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/types/events.ts Show resolved Hide resolved
@ebadiere ebadiere modified the milestones: 0.57.0, 0.58.0 Sep 30, 2024
@quiet-node quiet-node force-pushed the 2896-hbar-rate-limit-redesign-replace-usages-of-hbarlimit-with-the-new-hbarlimitservice-and-delete-it branch from 8523fe9 to 3a20364 Compare September 30, 2024 17:26
@quiet-node quiet-node marked this pull request as ready for review September 30, 2024 21:45
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.

@quiet-node quiet-node force-pushed the 2896-hbar-rate-limit-redesign-replace-usages-of-hbarlimit-with-the-new-hbarlimitservice-and-delete-it branch 2 times, most recently from e04b43b to 349eb2d Compare October 3, 2024 16:44
@quiet-node quiet-node force-pushed the 2896-hbar-rate-limit-redesign-replace-usages-of-hbarlimit-with-the-new-hbarlimitservice-and-delete-it branch from 5066ec9 to ebc1b72 Compare October 7, 2024 20:28
Copy link

github-actions bot commented Oct 8, 2024

🚨 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: 25,871.2 ms

Heap Statistics (before vs after executing the test):

  • Total Heap Size: increased with 1.46 MB
  • Total Heap Size Executable: no changes
  • Total Physical Size: decreased with 348.16 KB
  • Total Available Size: decreased with 11.42 MB
  • Total Global Handles Size: no changes
  • Used Global Handles Size: decreased with 64.00 bytes
  • Used Heap Size: decreased with 3.43 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 1.84 MB
    • Space Used Size: increased with 2.09 MB
    • Space Available Size: decreased with 14.71 MB
    • Physical Space Size: increased with 1.84 MB
  • Large Object Space:

    • Space Size: increased with 835.58 KB
    • Space Used Size: increased with 813.50 KB
    • Space Available Size: no changes
    • Physical Space Size: increased with 835.58 KB

Recommendations

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

konstantinabl
konstantinabl previously approved these changes Oct 9, 2024
Copy link
Collaborator

@konstantinabl konstantinabl left a comment

Choose a reason for hiding this comment

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

LGTM! Good job!

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.

LGTM, just a few small things

packages/relay/src/lib/services/hbarLimitService/index.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/services/hbarLimitService/index.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/types/events.ts Show resolved Hide resolved
packages/relay/src/utils.ts Show resolved Hide resolved
packages/relay/src/utils.ts Show resolved Hide resolved
@quiet-node quiet-node force-pushed the 2896-hbar-rate-limit-redesign-replace-usages-of-hbarlimit-with-the-new-hbarlimitservice-and-delete-it branch from 7b46596 to 97f66d8 Compare October 15, 2024 02:54
victor-yanev
victor-yanev previously approved these changes Oct 15, 2024
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.

Looks good! Great job overall.

Comment on lines +869 to +871
if (shouldPreemptivelyLimit) {
throw predefined.HBAR_RATE_LIMIT_EXCEEDED;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If shouldPreemptivelyLimit is set to false, we will have no limiting for file transactions since we are passing always passing false to executeTransaction and executeQuery.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this comment here answers the question. The shouldPreemptivelyLimit check was intended to validate the shouldLimit logic for both executeTransaction() for fileCreate and executeAllTransaction() for fileAppend. That’s why I passed false in both executeTransaction() and executeAllTransaction() below to skip

The shouldThrowHbarLimit variable in executeTransaction() and executeAllTransaction() only checks if another shouldLimit evaluation is needed. However, since this logic is already handled by the preemptive rate limit, there’s no need for an additional check in the individual flow. This was mentioned in the earlier comment.

@@ -859,7 +879,7 @@ export class SDKClient {
callerName,
interactingEntity,
requestDetails,
true,
false,
Copy link
Contributor

Choose a reason for hiding this comment

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

For this reason, instead of passing false we can pass: !shouldPreemptivelyLimit so that this is set to true if shouldPreemptivelyLimit is false

Suggested change
false,
!shouldPreemptivelyLimit,

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -877,7 +897,7 @@ export class SDKClient {
callerName,
interactingEntity,
requestDetails,
true,
false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
false,
!shouldPreemptivelyLimit,

Copy link
Member Author

Choose a reason for hiding this comment

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

packages/relay/src/lib/services/hbarLimitService/index.ts Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Oct 15, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@quiet-node quiet-node changed the base branch from main to FEATURE_BRANCH-HbarRateLimitService October 15, 2024 14:56
@quiet-node quiet-node merged commit 338de4a into FEATURE_BRANCH-HbarRateLimitService Oct 15, 2024
42 of 45 checks passed
@quiet-node quiet-node deleted the 2896-hbar-rate-limit-redesign-replace-usages-of-hbarlimit-with-the-new-hbarlimitservice-and-delete-it branch October 15, 2024 14:57
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

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

Project coverage is 82.06%. Comparing base (afc3349) to head (15cfe72).
Report is 1 commits behind head on FEATURE_BRANCH-HbarRateLimitService.

Files with missing lines Patch % Lines
packages/relay/src/lib/clients/sdkClient.ts 90.90% 1 Missing ⚠️
packages/relay/src/lib/constants.ts 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                           Coverage Diff                           @@
##           FEATURE_BRANCH-HbarRateLimitService    #3024      +/-   ##
=======================================================================
- Coverage                                83.16%   82.06%   -1.11%     
=======================================================================
  Files                                       63       65       +2     
  Lines                                     4236     4338     +102     
  Branches                                   830      859      +29     
=======================================================================
+ Hits                                      3523     3560      +37     
- Misses                                     470      529      +59     
- Partials                                   243      249       +6     
Flag Coverage Δ
relay 85.25% <95.83%> (-0.35%) ⬇️
server 83.48% <ø> (ø)
ws-server 33.91% <ø> (ø)

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

Files with missing lines Coverage Δ
packages/relay/src/lib/relay.ts 88.73% <100.00%> (+1.58%) ⬆️
.../relay/src/lib/services/hapiService/hapiService.ts 81.11% <100.00%> (+1.11%) ⬆️
...s/relay/src/lib/services/hbarLimitService/index.ts 95.83% <100.00%> (-1.65%) ⬇️
...ay/src/lib/services/metricService/metricService.ts 92.68% <100.00%> (+0.18%) ⬆️
packages/relay/src/utils.ts 100.00% <100.00%> (ø)
packages/relay/src/lib/clients/sdkClient.ts 59.55% <90.90%> (+1.14%) ⬆️
packages/relay/src/lib/constants.ts 98.11% <66.66%> (+6.11%) ⬆️

... and 9 files with indirect coverage changes

quiet-node added a commit that referenced this pull request Oct 15, 2024
…3024)

* fix: converted constant HBAR_RATE_LIMIT_DURATION from var into function

Signed-off-by: Logan Nguyen <[email protected]>

* chore: added jsdoc to private vars in hapiService module

Signed-off-by: Logan Nguyen <[email protected]>

* feat: initialized an instance of HbarLimitService in relay.ts

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into HapiService class

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into SDKClient class

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into MetricService class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: modified addExpense to turn ethAddress to be optional

Some queries like getAccountInfo, getBalanceInfo, FileContentsQuery, etc. also add expense to remainingBalance but don't necessarily need to have an originalCaller (ethAddress).

Therefore, addExpense can accept nullable ethAddress value.

Only when ethAddress or ipAddress is valid, utilize spendingPlan logic. Otherwise, skip completely.

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added getRemainingBudget() getter

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added originalCallerAddress to IExecuteTransactionEventPayload and IExecuteQueryEventPayload

Signed-off-by: Logan Nguyen <[email protected]>

* feat: removed metricService instance in relay

Signed-off-by: Logan Nguyen <[email protected]>

* feat: replaced hbarLimitter with hbarLimitService in MetricService class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added estimateFileTransactionsFee to Utils

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added txConstructorName and updated log messages for shouldLimit

Signed-off-by: Logan Nguyen <[email protected]>

* fix: rework logic for estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* feat: removed hbarLimiter instance in SDKClient classes

Signed-off-by: Logan Nguyen <[email protected]>

* feat: deleted HbarLimit module from codease

Signed-off-by: Logan Nguyen <[email protected]>

* feat: reverted logic reworked on estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added preemptive rate limit logic to createFile() method

Signed-off-by: Logan Nguyen <[email protected]>

* test: updated hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added names for child loggers for spending plan repo

Signed-off-by: Logan Nguyen <[email protected]>

* chore: reverted "feat: added getRemainingBudget() getter"

This reverts commit fd9e119 and updated related tests

Signed-off-by: Logan Nguyen <[email protected]>

* fix: updated log message

Signed-off-by: Logan Nguyen <[email protected]>

* test: added HBAR_DAILY_LIMIT_BASIC to localTestEnv

Signed-off-by: Logan Nguyen <[email protected]>

* fix: converted function HBAR_RATE_LIMIT_DURATION from function into var

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted "feat: removed metricService instance in relay"

This reverts commit e45c321.

Signed-off-by: Logan Nguyen <[email protected]>

* chore: updated log message

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed failing test in hapiService

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted ethAddress back to be a required param for addExpense

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed failing test in hapiService.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: loaded env into prcess.env for constant module

Signed-off-by: Logan Nguyen <[email protected]>

* chore: removed duplicating doc for estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* chore: sort imports

Signed-off-by: Victor Yanev <[email protected]>

* fix: removed ipAddresses from log in hbarLimitService

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed isDailyBudgetExceeded -> isTotalBudgetExceeded

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed conflicts after rebased

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed acceptance test for exhausting HBAR case

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC

Signed-off-by: Logan Nguyen <[email protected]>

* fix: overrode env vars for npm acceptancetest:hbarlimiter script

Signed-off-by: Logan Nguyen <[email protected]>

* fix: moved logic of adding expenses to totalBudget above hbarSpendingPlan

Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
Co-authored-by: Victor Yanev <[email protected]>
quiet-node added a commit that referenced this pull request Oct 16, 2024
…3024)

* fix: converted constant HBAR_RATE_LIMIT_DURATION from var into function

Signed-off-by: Logan Nguyen <[email protected]>

* chore: added jsdoc to private vars in hapiService module

Signed-off-by: Logan Nguyen <[email protected]>

* feat: initialized an instance of HbarLimitService in relay.ts

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into HapiService class

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into SDKClient class

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into MetricService class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: modified addExpense to turn ethAddress to be optional

Some queries like getAccountInfo, getBalanceInfo, FileContentsQuery, etc. also add expense to remainingBalance but don't necessarily need to have an originalCaller (ethAddress).

Therefore, addExpense can accept nullable ethAddress value.

Only when ethAddress or ipAddress is valid, utilize spendingPlan logic. Otherwise, skip completely.

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added getRemainingBudget() getter

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added originalCallerAddress to IExecuteTransactionEventPayload and IExecuteQueryEventPayload

Signed-off-by: Logan Nguyen <[email protected]>

* feat: removed metricService instance in relay

Signed-off-by: Logan Nguyen <[email protected]>

* feat: replaced hbarLimitter with hbarLimitService in MetricService class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added estimateFileTransactionsFee to Utils

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added txConstructorName and updated log messages for shouldLimit

Signed-off-by: Logan Nguyen <[email protected]>

* fix: rework logic for estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* feat: removed hbarLimiter instance in SDKClient classes

Signed-off-by: Logan Nguyen <[email protected]>

* feat: deleted HbarLimit module from codease

Signed-off-by: Logan Nguyen <[email protected]>

* feat: reverted logic reworked on estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added preemptive rate limit logic to createFile() method

Signed-off-by: Logan Nguyen <[email protected]>

* test: updated hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added names for child loggers for spending plan repo

Signed-off-by: Logan Nguyen <[email protected]>

* chore: reverted "feat: added getRemainingBudget() getter"

This reverts commit fd9e119 and updated related tests

Signed-off-by: Logan Nguyen <[email protected]>

* fix: updated log message

Signed-off-by: Logan Nguyen <[email protected]>

* test: added HBAR_DAILY_LIMIT_BASIC to localTestEnv

Signed-off-by: Logan Nguyen <[email protected]>

* fix: converted function HBAR_RATE_LIMIT_DURATION from function into var

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted "feat: removed metricService instance in relay"

This reverts commit e45c321.

Signed-off-by: Logan Nguyen <[email protected]>

* chore: updated log message

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed failing test in hapiService

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted ethAddress back to be a required param for addExpense

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed failing test in hapiService.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: loaded env into prcess.env for constant module

Signed-off-by: Logan Nguyen <[email protected]>

* chore: removed duplicating doc for estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* chore: sort imports

Signed-off-by: Victor Yanev <[email protected]>

* fix: removed ipAddresses from log in hbarLimitService

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed isDailyBudgetExceeded -> isTotalBudgetExceeded

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed conflicts after rebased

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed acceptance test for exhausting HBAR case

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC

Signed-off-by: Logan Nguyen <[email protected]>

* fix: overrode env vars for npm acceptancetest:hbarlimiter script

Signed-off-by: Logan Nguyen <[email protected]>

* fix: moved logic of adding expenses to totalBudget above hbarSpendingPlan

Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
Co-authored-by: Victor Yanev <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
quiet-node added a commit that referenced this pull request Oct 16, 2024
…3024)

* fix: converted constant HBAR_RATE_LIMIT_DURATION from var into function

Signed-off-by: Logan Nguyen <[email protected]>

* chore: added jsdoc to private vars in hapiService module

Signed-off-by: Logan Nguyen <[email protected]>

* feat: initialized an instance of HbarLimitService in relay.ts

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into HapiService class

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into SDKClient class

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into MetricService class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: modified addExpense to turn ethAddress to be optional

Some queries like getAccountInfo, getBalanceInfo, FileContentsQuery, etc. also add expense to remainingBalance but don't necessarily need to have an originalCaller (ethAddress).

Therefore, addExpense can accept nullable ethAddress value.

Only when ethAddress or ipAddress is valid, utilize spendingPlan logic. Otherwise, skip completely.

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added getRemainingBudget() getter

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added originalCallerAddress to IExecuteTransactionEventPayload and IExecuteQueryEventPayload

Signed-off-by: Logan Nguyen <[email protected]>

* feat: removed metricService instance in relay

Signed-off-by: Logan Nguyen <[email protected]>

* feat: replaced hbarLimitter with hbarLimitService in MetricService class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added estimateFileTransactionsFee to Utils

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added txConstructorName and updated log messages for shouldLimit

Signed-off-by: Logan Nguyen <[email protected]>

* fix: rework logic for estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* feat: removed hbarLimiter instance in SDKClient classes

Signed-off-by: Logan Nguyen <[email protected]>

* feat: deleted HbarLimit module from codease

Signed-off-by: Logan Nguyen <[email protected]>

* feat: reverted logic reworked on estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added preemptive rate limit logic to createFile() method

Signed-off-by: Logan Nguyen <[email protected]>

* test: updated hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added names for child loggers for spending plan repo

Signed-off-by: Logan Nguyen <[email protected]>

* chore: reverted "feat: added getRemainingBudget() getter"

This reverts commit fd9e119 and updated related tests

Signed-off-by: Logan Nguyen <[email protected]>

* fix: updated log message

Signed-off-by: Logan Nguyen <[email protected]>

* test: added HBAR_DAILY_LIMIT_BASIC to localTestEnv

Signed-off-by: Logan Nguyen <[email protected]>

* fix: converted function HBAR_RATE_LIMIT_DURATION from function into var

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted "feat: removed metricService instance in relay"

This reverts commit e45c321.

Signed-off-by: Logan Nguyen <[email protected]>

* chore: updated log message

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed failing test in hapiService

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted ethAddress back to be a required param for addExpense

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed failing test in hapiService.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: loaded env into prcess.env for constant module

Signed-off-by: Logan Nguyen <[email protected]>

* chore: removed duplicating doc for estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* chore: sort imports

Signed-off-by: Victor Yanev <[email protected]>

* fix: removed ipAddresses from log in hbarLimitService

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed isDailyBudgetExceeded -> isTotalBudgetExceeded

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed conflicts after rebased

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed acceptance test for exhausting HBAR case

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC

Signed-off-by: Logan Nguyen <[email protected]>

* fix: overrode env vars for npm acceptancetest:hbarlimiter script

Signed-off-by: Logan Nguyen <[email protected]>

* fix: moved logic of adding expenses to totalBudget above hbarSpendingPlan

Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
Co-authored-by: Victor Yanev <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
ebadiere pushed a commit that referenced this pull request Oct 21, 2024
…3110)

* feat: replaced HbarLimit module with the new HbarLimitService class (#3024)

* fix: converted constant HBAR_RATE_LIMIT_DURATION from var into function

Signed-off-by: Logan Nguyen <[email protected]>

* chore: added jsdoc to private vars in hapiService module

Signed-off-by: Logan Nguyen <[email protected]>

* feat: initialized an instance of HbarLimitService in relay.ts

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into HapiService class

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into SDKClient class

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into MetricService class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: modified addExpense to turn ethAddress to be optional

Some queries like getAccountInfo, getBalanceInfo, FileContentsQuery, etc. also add expense to remainingBalance but don't necessarily need to have an originalCaller (ethAddress).

Therefore, addExpense can accept nullable ethAddress value.

Only when ethAddress or ipAddress is valid, utilize spendingPlan logic. Otherwise, skip completely.

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added getRemainingBudget() getter

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added originalCallerAddress to IExecuteTransactionEventPayload and IExecuteQueryEventPayload

Signed-off-by: Logan Nguyen <[email protected]>

* feat: removed metricService instance in relay

Signed-off-by: Logan Nguyen <[email protected]>

* feat: replaced hbarLimitter with hbarLimitService in MetricService class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added estimateFileTransactionsFee to Utils

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added txConstructorName and updated log messages for shouldLimit

Signed-off-by: Logan Nguyen <[email protected]>

* fix: rework logic for estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* feat: removed hbarLimiter instance in SDKClient classes

Signed-off-by: Logan Nguyen <[email protected]>

* feat: deleted HbarLimit module from codease

Signed-off-by: Logan Nguyen <[email protected]>

* feat: reverted logic reworked on estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added preemptive rate limit logic to createFile() method

Signed-off-by: Logan Nguyen <[email protected]>

* test: updated hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added names for child loggers for spending plan repo

Signed-off-by: Logan Nguyen <[email protected]>

* chore: reverted "feat: added getRemainingBudget() getter"

This reverts commit fd9e119 and updated related tests

Signed-off-by: Logan Nguyen <[email protected]>

* fix: updated log message

Signed-off-by: Logan Nguyen <[email protected]>

* test: added HBAR_DAILY_LIMIT_BASIC to localTestEnv

Signed-off-by: Logan Nguyen <[email protected]>

* fix: converted function HBAR_RATE_LIMIT_DURATION from function into var

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted "feat: removed metricService instance in relay"

This reverts commit e45c321.

Signed-off-by: Logan Nguyen <[email protected]>

* chore: updated log message

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed failing test in hapiService

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted ethAddress back to be a required param for addExpense

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed failing test in hapiService.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: loaded env into prcess.env for constant module

Signed-off-by: Logan Nguyen <[email protected]>

* chore: removed duplicating doc for estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* chore: sort imports

Signed-off-by: Victor Yanev <[email protected]>

* fix: removed ipAddresses from log in hbarLimitService

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed isDailyBudgetExceeded -> isTotalBudgetExceeded

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed conflicts after rebased

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed acceptance test for exhausting HBAR case

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC

Signed-off-by: Logan Nguyen <[email protected]>

* fix: overrode env vars for npm acceptancetest:hbarlimiter script

Signed-off-by: Logan Nguyen <[email protected]>

* fix: moved logic of adding expenses to totalBudget above hbarSpendingPlan

Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
Co-authored-by: Victor Yanev <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>

* test: create e2e tests for basic spending plan limit (#3104)

* Adds acceptance test for BASIC user spending plans

Signed-off-by: Konstantina Blazhukova <[email protected]>

Fixes failing acceptance test

Signed-off-by: Konstantina Blazhukova <[email protected]>

Revert accidental deletion of method

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Fixes CI

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Fixes failiing acceptance tests and improves setup

Signed-off-by: Konstantina Blazhukova <[email protected]>

Update hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: switched back HBAR_RATE_LIMIT_DURATION

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC

Signed-off-by: Logan Nguyen <[email protected]>

Update localAcceptance.env

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed hbar limiter test

Signed-off-by: Logan Nguyen <[email protected]>

* fix: re-ordered test cases

Signed-off-by: Logan Nguyen <[email protected]>

* Improves test case and skips unecessary one

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Improves unlinking of ip addresses

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Revert "chore: remove unnecessary timeouts in tests"

This reverts commit f688a4e.

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Adds new deleteAll method in ipAddressRepository

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Removes timeouts and adds logic to wait for limiter reset

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Adds appropriate limits for acceptance tests

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Adds new variables to .env

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Improves test setup, removes unneeded limiter reset

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Removes setting of env from terminal command, adds it to test setup instead

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Adds necessary timeouts in tests relying on queries to mirror node

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Fixes import in hbarLimiter spec

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Removes unused imports, adds const where needed

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Removes unused method

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Makes improvements in ipAddressHbarRepo

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Adds reset timestamp method to test

Signed-off-by: Konstantina Blazhukova <[email protected]>

* fix: added deleteAll() to EthAddressHbarSpendingPlanRepository class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted and cleaned up

Signed-off-by: Logan Nguyen <[email protected]>

* fix: removed duplicated test

Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>

Signed-off-by: Logan Nguyen <[email protected]>

Update hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

Update hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>
Co-Authored-By: Logan Nguyen <[email protected]>

* chore: added info log after HbarLimiter is successfully configured

Signed-off-by: Logan Nguyen <[email protected]>

* chore: removed overriden variables in `acceptancetest:hbarlimiter` npm script

Signed-off-by: Logan Nguyen <[email protected]>

* fix: bumped HBAR_RATE_LIMIT_BASIC to 40 HBARs

Signed-off-by: Logan Nguyen <[email protected]>

* Shortens and improves logger name for new hbar plan repositories

Signed-off-by: Konstantina Blazhukova <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
Co-authored-by: Victor Yanev <[email protected]>
Co-authored-by: konstantinabl <[email protected]>
ebadiere pushed a commit that referenced this pull request Oct 21, 2024
…3110)

* feat: replaced HbarLimit module with the new HbarLimitService class (#3024)

* fix: converted constant HBAR_RATE_LIMIT_DURATION from var into function

Signed-off-by: Logan Nguyen <[email protected]>

* chore: added jsdoc to private vars in hapiService module

Signed-off-by: Logan Nguyen <[email protected]>

* feat: initialized an instance of HbarLimitService in relay.ts

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into HapiService class

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into SDKClient class

Signed-off-by: Logan Nguyen <[email protected]>

* feat: integrated HbarLimitService instance into MetricService class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: modified addExpense to turn ethAddress to be optional

Some queries like getAccountInfo, getBalanceInfo, FileContentsQuery, etc. also add expense to remainingBalance but don't necessarily need to have an originalCaller (ethAddress).

Therefore, addExpense can accept nullable ethAddress value.

Only when ethAddress or ipAddress is valid, utilize spendingPlan logic. Otherwise, skip completely.

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added getRemainingBudget() getter

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added originalCallerAddress to IExecuteTransactionEventPayload and IExecuteQueryEventPayload

Signed-off-by: Logan Nguyen <[email protected]>

* feat: removed metricService instance in relay

Signed-off-by: Logan Nguyen <[email protected]>

* feat: replaced hbarLimitter with hbarLimitService in MetricService class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added estimateFileTransactionsFee to Utils

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added txConstructorName and updated log messages for shouldLimit

Signed-off-by: Logan Nguyen <[email protected]>

* fix: rework logic for estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* feat: removed hbarLimiter instance in SDKClient classes

Signed-off-by: Logan Nguyen <[email protected]>

* feat: deleted HbarLimit module from codease

Signed-off-by: Logan Nguyen <[email protected]>

* feat: reverted logic reworked on estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added preemptive rate limit logic to createFile() method

Signed-off-by: Logan Nguyen <[email protected]>

* test: updated hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added names for child loggers for spending plan repo

Signed-off-by: Logan Nguyen <[email protected]>

* chore: reverted "feat: added getRemainingBudget() getter"

This reverts commit fd9e119 and updated related tests

Signed-off-by: Logan Nguyen <[email protected]>

* fix: updated log message

Signed-off-by: Logan Nguyen <[email protected]>

* test: added HBAR_DAILY_LIMIT_BASIC to localTestEnv

Signed-off-by: Logan Nguyen <[email protected]>

* fix: converted function HBAR_RATE_LIMIT_DURATION from function into var

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted "feat: removed metricService instance in relay"

This reverts commit e45c321.

Signed-off-by: Logan Nguyen <[email protected]>

* chore: updated log message

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed failing test in hapiService

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted ethAddress back to be a required param for addExpense

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed failing test in hapiService.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: loaded env into prcess.env for constant module

Signed-off-by: Logan Nguyen <[email protected]>

* chore: removed duplicating doc for estimateFileTransactionsFee

Signed-off-by: Logan Nguyen <[email protected]>

* chore: sort imports

Signed-off-by: Victor Yanev <[email protected]>

* fix: removed ipAddresses from log in hbarLimitService

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed isDailyBudgetExceeded -> isTotalBudgetExceeded

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed conflicts after rebased

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed acceptance test for exhausting HBAR case

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC

Signed-off-by: Logan Nguyen <[email protected]>

* fix: overrode env vars for npm acceptancetest:hbarlimiter script

Signed-off-by: Logan Nguyen <[email protected]>

* fix: moved logic of adding expenses to totalBudget above hbarSpendingPlan

Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
Co-authored-by: Victor Yanev <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>

* test: create e2e tests for basic spending plan limit (#3104)

* Adds acceptance test for BASIC user spending plans

Signed-off-by: Konstantina Blazhukova <[email protected]>

Fixes failing acceptance test

Signed-off-by: Konstantina Blazhukova <[email protected]>

Revert accidental deletion of method

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Fixes CI

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Fixes failiing acceptance tests and improves setup

Signed-off-by: Konstantina Blazhukova <[email protected]>

Update hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

* fix: switched back HBAR_RATE_LIMIT_DURATION

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC

Signed-off-by: Logan Nguyen <[email protected]>

Update localAcceptance.env

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed hbar limiter test

Signed-off-by: Logan Nguyen <[email protected]>

* fix: re-ordered test cases

Signed-off-by: Logan Nguyen <[email protected]>

* Improves test case and skips unecessary one

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Improves unlinking of ip addresses

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Revert "chore: remove unnecessary timeouts in tests"

This reverts commit f688a4e.

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Adds new deleteAll method in ipAddressRepository

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Removes timeouts and adds logic to wait for limiter reset

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Adds appropriate limits for acceptance tests

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Adds new variables to .env

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Improves test setup, removes unneeded limiter reset

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Removes setting of env from terminal command, adds it to test setup instead

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Adds necessary timeouts in tests relying on queries to mirror node

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Fixes import in hbarLimiter spec

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Removes unused imports, adds const where needed

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Removes unused method

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Makes improvements in ipAddressHbarRepo

Signed-off-by: Konstantina Blazhukova <[email protected]>

* Adds reset timestamp method to test

Signed-off-by: Konstantina Blazhukova <[email protected]>

* fix: added deleteAll() to EthAddressHbarSpendingPlanRepository class

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted and cleaned up

Signed-off-by: Logan Nguyen <[email protected]>

* fix: removed duplicated test

Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>

Signed-off-by: Logan Nguyen <[email protected]>

Update hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>

Update hbarLimiter.spec.ts

Signed-off-by: Logan Nguyen <[email protected]>
Co-Authored-By: Logan Nguyen <[email protected]>

* chore: added info log after HbarLimiter is successfully configured

Signed-off-by: Logan Nguyen <[email protected]>

* chore: removed overriden variables in `acceptancetest:hbarlimiter` npm script

Signed-off-by: Logan Nguyen <[email protected]>

* fix: bumped HBAR_RATE_LIMIT_BASIC to 40 HBARs

Signed-off-by: Logan Nguyen <[email protected]>

* Shortens and improves logger name for new hbar plan repositories

Signed-off-by: Konstantina Blazhukova <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
Co-authored-by: Victor Yanev <[email protected]>
Co-authored-by: konstantinabl <[email protected]>
ebadiere added a commit that referenced this pull request Oct 21, 2024
feat: replaced HbarLimit module with the new HbarLimitService class (#3110)

* feat: replaced HbarLimit module with the new HbarLimitService class (#3024)

* fix: converted constant HBAR_RATE_LIMIT_DURATION from var into function



* chore: added jsdoc to private vars in hapiService module



* feat: initialized an instance of HbarLimitService in relay.ts



* feat: integrated HbarLimitService instance into HapiService class



* feat: integrated HbarLimitService instance into SDKClient class



* feat: integrated HbarLimitService instance into MetricService class



* fix: modified addExpense to turn ethAddress to be optional

Some queries like getAccountInfo, getBalanceInfo, FileContentsQuery, etc. also add expense to remainingBalance but don't necessarily need to have an originalCaller (ethAddress).

Therefore, addExpense can accept nullable ethAddress value.

Only when ethAddress or ipAddress is valid, utilize spendingPlan logic. Otherwise, skip completely.



* feat: added getRemainingBudget() getter



* feat: added originalCallerAddress to IExecuteTransactionEventPayload and IExecuteQueryEventPayload



* feat: removed metricService instance in relay



* feat: replaced hbarLimitter with hbarLimitService in MetricService class



* fix: added estimateFileTransactionsFee to Utils



* feat: added txConstructorName and updated log messages for shouldLimit



* fix: rework logic for estimateFileTransactionsFee



* feat: removed hbarLimiter instance in SDKClient classes



* feat: deleted HbarLimit module from codease



* feat: reverted logic reworked on estimateFileTransactionsFee



* feat: added preemptive rate limit logic to createFile() method



* test: updated hbarLimiter.spec.ts



* fix: added names for child loggers for spending plan repo



* chore: reverted "feat: added getRemainingBudget() getter"

This reverts commit fd9e119 and updated related tests



* fix: updated log message



* test: added HBAR_DAILY_LIMIT_BASIC to localTestEnv



* fix: converted function HBAR_RATE_LIMIT_DURATION from function into var



* fix: reverted "feat: removed metricService instance in relay"

This reverts commit e45c321.



* chore: updated log message



* fix: fixed failing test in hapiService



* fix: reverted ethAddress back to be a required param for addExpense



* fix: fixed failing test in hapiService.spec.ts



* fix: loaded env into prcess.env for constant module



* chore: removed duplicating doc for estimateFileTransactionsFee



* chore: sort imports



* fix: removed ipAddresses from log in hbarLimitService



* fix: renamed isDailyBudgetExceeded -> isTotalBudgetExceeded



* fix: fixed conflicts after rebased



* fix: fixed acceptance test for exhausting HBAR case



* fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC



* fix: overrode env vars for npm acceptancetest:hbarlimiter script



* fix: moved logic of adding expenses to totalBudget above hbarSpendingPlan



---------






* test: create e2e tests for basic spending plan limit (#3104)

* Adds acceptance test for BASIC user spending plans



Fixes failing acceptance test



Revert accidental deletion of method



* Fixes CI



* Fixes failiing acceptance tests and improves setup



Update hbarLimiter.spec.ts



* fix: switched back HBAR_RATE_LIMIT_DURATION



* fix: renamed HBAR_DAILY_LIMIT_BASIC to HBAR_RATE_LIMIT_BASIC



Update localAcceptance.env



* fix: fixed hbar limiter test



* fix: re-ordered test cases



* Improves test case and skips unecessary one



* Improves unlinking of ip addresses



* Revert "chore: remove unnecessary timeouts in tests"

This reverts commit f688a4e.



* Adds new deleteAll method in ipAddressRepository



* Removes timeouts and adds logic to wait for limiter reset



* Adds appropriate limits for acceptance tests



* Adds new variables to .env



* Improves test setup, removes unneeded limiter reset



* Removes setting of env from terminal command, adds it to test setup instead



* Adds necessary timeouts in tests relying on queries to mirror node



* Fixes import in hbarLimiter spec



* Removes unused imports, adds const where needed



* Removes unused method



* Makes improvements in ipAddressHbarRepo



* Adds reset timestamp method to test



* fix: added deleteAll() to EthAddressHbarSpendingPlanRepository class



* fix: reverted and cleaned up



* fix: removed duplicated test



---------






Update hbarLimiter.spec.ts



Update hbarLimiter.spec.ts




* chore: added info log after HbarLimiter is successfully configured



* chore: removed overriden variables in `acceptancetest:hbarlimiter` npm script



* fix: bumped HBAR_RATE_LIMIT_BASIC to 40 HBARs



* Shortens and improves logger name for new hbar plan repositories



---------

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
Co-authored-by: Logan Nguyen <[email protected]>
Co-authored-by: Victor Yanev <[email protected]>
Co-authored-by: konstantinabl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[HBAR Rate Limit Redesign] Replace usages of HbarLimit with the new HbarLimitService and delete it
4 participants