-
Notifications
You must be signed in to change notification settings - Fork 112
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
Introduce gasUnit
property to allow greater gas per second throttle
#9994
Conversation
Signed-off-by: Bilyana Gospodinova <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9994 +/- ##
============================================
- Coverage 92.23% 92.23% -0.01%
Complexity 7856 7856
============================================
Files 956 956
Lines 32896 32900 +4
Branches 4148 4148
============================================
+ Hits 30342 30345 +3
Misses 1579 1579
- Partials 975 976 +1 ☔ View full report in Codecov by Sentry. |
hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/throttle/ThrottleProperties.java
Show resolved
Hide resolved
Signed-off-by: Bilyana Gospodinova <[email protected]>
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description:
The current bucket4j implementation does not allow a greater consumption than 1 token per nanosecond. Because of this the current max gas per second is capped at 1_000_000_000 gas.
This PR adds a new property called
hedera.mirror.web3.throttle.gasUnit
. This is a multiplier that allows a mapping between the token and the gas that will be consumed in the bucket. For example, if the value of the property is set to 10, this means that 1 token in the bucket will correspond to 10 gas. This will make the max supported gas limit per second to be equal to 10_000_000_000. Please note that there might be some small precision loss due to number rounding.The implementation change is that when a request is made, the passed gas limit is divided by the configured
gasUnit
property value (by default it is set to 1). After the transaction processing is finished, the remaining (unused) gas is then returned back to the bucket and is available to be used by another transaction.Example: a request is made with gasLimit set to 1_000_000. The
gasUnit
is set to 10. This means that 100_000 tokens will be reserved in the gas throttle bucket. The transaction finishes and the actual gas used is 800_000. This means that there are 200_000 gas remaining. Using thegasUnit
multiplier, 200_000 /gasUnit
= 20_000 gas will be returned back to the bucket and can be used by another transaction.Fixes #9977