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

Introduce gasUnit property to allow greater gas per second throttle #9994

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

bilyana-gospodinova
Copy link
Contributor

@bilyana-gospodinova bilyana-gospodinova commented Dec 20, 2024

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 the gasUnit multiplier, 200_000 / gasUnit = 20_000 gas will be returned back to the bucket and can be used by another transaction.

Fixes #9977

Signed-off-by: Bilyana Gospodinova <[email protected]>
@bilyana-gospodinova bilyana-gospodinova added enhancement Type: New feature web3 Area: Web3 API labels Dec 20, 2024
@bilyana-gospodinova bilyana-gospodinova self-assigned this Dec 20, 2024
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.23%. Comparing base (3f29e8a) to head (47ce8a7).
Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

@bilyana-gospodinova bilyana-gospodinova marked this pull request as ready for review December 20, 2024 13:05
@bilyana-gospodinova bilyana-gospodinova requested a review from a team as a code owner December 20, 2024 13:05
@kselveliev kselveliev self-requested a review December 20, 2024 14:36
kselveliev
kselveliev previously approved these changes Dec 20, 2024
Signed-off-by: Bilyana Gospodinova <[email protected]>
@steven-sheehy steven-sheehy added this to the 0.121.0 milestone Dec 20, 2024
Copy link
Collaborator

@xin-hedera xin-hedera left a comment

Choose a reason for hiding this comment

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

LGTM

@steven-sheehy steven-sheehy merged commit d2e5ae1 into main Dec 20, 2024
31 of 32 checks passed
@steven-sheehy steven-sheehy deleted the 09977-increase-gas-throttle branch December 20, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type: New feature web3 Area: Web3 API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Web3 does not support a gas throttle limit higher than the default (1B)
4 participants