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

throttle "refund" for gas/sec should be based on _consumed_ not _used_ #17708

Open
15 tasks
david-bakin-sl opened this issue Feb 4, 2025 · 0 comments
Open
15 tasks
Labels
Hedera Smart Contract Service Issues related to the Hedera Smart Contract Service.

Comments

@david-bakin-sl
Copy link
Member

Background

We have two different measures of gas eaten by a contract:

  • consumed - actual amount computed by the EVM (+ our charges for system contract methods + intrinsic minimum)
  • used - amount charged caller which is consumed + the 80% tariff for overestimating the gas limit on submitting a transaction

The gas throttle limiting how many contract executions we run per second is done based on the gas limit - because the transaction hasn't run yet. But after the transaction is run and we know how much gas was actually used, we "refund" the excess back to the throttle so that we can accept more work in that period.

This happens in DispatchUsageManager.leakUnusedGas.

And if I'm reading that correctly, it's based on gas used. But since this is a performance limit (on the network) it should be based instead on gas consumed.

Acceptance Criteria

  1. Difference in amount refunded to throttle based on transactions with gas limit, gas consumed, and gas used (based on overestimates of gas limit).
  2. Performance testing showing that after this change you get more contract execution tx/sec accepted and executed even though those contract txs together would hit the 15M throttle based on gas limit, or based on total gas used, but not with total gas consumed.

Dependencies

No response

Definition of Ready (DoR) Checklist

  • Clear acceptance criteria
  • Clear and detailed description
  • Dependencies identified
  • Links to documentation
  • Should be completable in 2-3 Days
  • Initial draft of Low-level design document
  • At least high level test plan
  • Groomed/Estimated

Definition of Done (DoD) Checklist

  • Acceptance Criteria complete
  • No Codacy issues greater than minor (in new code)
  • JavaDocs updated/created
  • Code commented
  • Unit tests created/updated
  • 80% test code coverage (in new code)
  • Happy Path and major negative cases in HAPI tests as applicable
@david-bakin-sl david-bakin-sl added the Hedera Smart Contract Service Issues related to the Hedera Smart Contract Service. label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hedera Smart Contract Service Issues related to the Hedera Smart Contract Service.
Projects
Status: Backlog
Development

No branches or pull requests

1 participant