Commit 34ec5a2
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
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]>1 parent a1ae911 commit 34ec5a2
File tree
29 files changed
+958
-1005
lines changed- packages
- relay
- src
- lib
- clients
- db/repositories/hbarLimiter
- hbarlimiter
- services
- hapiService
- hbarLimitService
- metricService
- types
- tests
- lib
- eth
- services
- hbarLimitService
- metricService
- server/tests
- acceptance
- types
29 files changed
+958
-1005
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | | - | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 89 | | |
95 | 90 | | |
96 | 91 | | |
| |||
118 | 113 | | |
119 | 114 | | |
120 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
125 | 128 | | |
126 | | - | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
133 | | - | |
134 | 135 | | |
135 | 136 | | |
| 137 | + | |
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
| |||
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
146 | | - | |
147 | 148 | | |
148 | 149 | | |
| 150 | + | |
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
| |||
417 | 419 | | |
418 | 420 | | |
419 | 421 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | 422 | | |
438 | 423 | | |
439 | 424 | | |
440 | 425 | | |
441 | 426 | | |
442 | 427 | | |
443 | 428 | | |
| 429 | + | |
444 | 430 | | |
445 | 431 | | |
446 | 432 | | |
| |||
506 | 492 | | |
507 | 493 | | |
508 | 494 | | |
509 | | - | |
| 495 | + | |
510 | 496 | | |
511 | 497 | | |
512 | 498 | | |
| |||
603 | 589 | | |
604 | 590 | | |
605 | 591 | | |
| 592 | + | |
606 | 593 | | |
607 | 594 | | |
608 | 595 | | |
| |||
613 | 600 | | |
614 | 601 | | |
615 | 602 | | |
| 603 | + | |
616 | 604 | | |
617 | 605 | | |
618 | 606 | | |
| |||
669 | 657 | | |
670 | 658 | | |
671 | 659 | | |
| 660 | + | |
672 | 661 | | |
673 | 662 | | |
674 | 663 | | |
| |||
683 | 672 | | |
684 | 673 | | |
685 | 674 | | |
| 675 | + | |
686 | 676 | | |
687 | 677 | | |
688 | 678 | | |
| |||
693 | 683 | | |
694 | 684 | | |
695 | 685 | | |
| 686 | + | |
696 | 687 | | |
697 | 688 | | |
698 | 689 | | |
699 | 690 | | |
700 | 691 | | |
701 | 692 | | |
702 | | - | |
703 | | - | |
| 693 | + | |
704 | 694 | | |
705 | 695 | | |
| 696 | + | |
706 | 697 | | |
707 | 698 | | |
| 699 | + | |
708 | 700 | | |
| 701 | + | |
709 | 702 | | |
710 | 703 | | |
711 | 704 | | |
| |||
756 | 749 | | |
757 | 750 | | |
758 | 751 | | |
| 752 | + | |
759 | 753 | | |
760 | 754 | | |
761 | 755 | | |
| |||
770 | 764 | | |
771 | 765 | | |
772 | 766 | | |
| 767 | + | |
773 | 768 | | |
774 | 769 | | |
775 | 770 | | |
| |||
780 | 775 | | |
781 | 776 | | |
782 | 777 | | |
| 778 | + | |
783 | 779 | | |
784 | 780 | | |
785 | 781 | | |
786 | 782 | | |
787 | 783 | | |
788 | | - | |
789 | | - | |
| 784 | + | |
790 | 785 | | |
791 | 786 | | |
| 787 | + | |
792 | 788 | | |
793 | 789 | | |
| 790 | + | |
794 | 791 | | |
| 792 | + | |
795 | 793 | | |
796 | 794 | | |
797 | 795 | | |
| |||
822 | 820 | | |
823 | 821 | | |
824 | 822 | | |
| 823 | + | |
825 | 824 | | |
826 | 825 | | |
827 | 826 | | |
| |||
837 | 836 | | |
838 | 837 | | |
839 | 838 | | |
| 839 | + | |
840 | 840 | | |
841 | 841 | | |
842 | 842 | | |
| |||
847 | 847 | | |
848 | 848 | | |
849 | 849 | | |
| 850 | + | |
850 | 851 | | |
851 | 852 | | |
852 | 853 | | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
853 | 873 | | |
854 | 874 | | |
855 | 875 | | |
| |||
859 | 879 | | |
860 | 880 | | |
861 | 881 | | |
862 | | - | |
| 882 | + | |
863 | 883 | | |
864 | 884 | | |
865 | 885 | | |
| |||
877 | 897 | | |
878 | 898 | | |
879 | 899 | | |
880 | | - | |
| 900 | + | |
881 | 901 | | |
882 | 902 | | |
883 | 903 | | |
| |||
889 | 909 | | |
890 | 910 | | |
891 | 911 | | |
| 912 | + | |
892 | 913 | | |
893 | 914 | | |
894 | 915 | | |
| |||
942 | 963 | | |
943 | 964 | | |
944 | 965 | | |
| 966 | + | |
945 | 967 | | |
946 | 968 | | |
947 | 969 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
| 25 | + | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
105 | 120 | | |
106 | 121 | | |
107 | 122 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
105 | 120 | | |
106 | 121 | | |
107 | 122 | | |
| |||
0 commit comments