Skip to content

Conversation

@ironcev
Copy link
Member

@ironcev ironcev commented Nov 14, 2025

Description

This PR adds --no-gas-limit CLI option to forc test. The option increases tx gas limit in forc test to u64::MAX, essentially removing it.

The motivation for the change was the need to benchmark heavy gas consuming algorithms. E.g., a brute force prime factorization of the number 9223372021822390277 took 21_474_836_627 gas units.

The new TestGasLimit enum provides a Limit(limit) variant which is currently unused, but added for future extensions, if we want to limit the test gas to a particular value.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@ironcev ironcev self-assigned this Nov 14, 2025
@ironcev ironcev added the testing General testing label Nov 14, 2025
@ironcev ironcev requested a review from a team November 14, 2025 13:20
@ironcev ironcev marked this pull request as ready for review November 14, 2025 13:20
@ironcev ironcev requested a review from a team as a code owner November 14, 2025 13:20
@ironcev ironcev enabled auto-merge (squash) November 14, 2025 13:20
@kayagokalp
Copy link
Member

👍

kayagokalp
kayagokalp previously approved these changes Nov 14, 2025
@xunilrj
Copy link
Contributor

xunilrj commented Nov 15, 2025

How long it takes to consume all gas? In a infinite loop, for example.

If it is too long, we may need to timeout execution.

@ironcev ironcev marked this pull request as draft November 16, 2025 10:29
auto-merge was automatically disabled November 16, 2025 10:29

Pull request was converted to draft

@ironcev
Copy link
Member Author

ironcev commented Nov 16, 2025

How long it takes to consume all gas? In a infinite loop, for example.
If it is too long, we may need to timeout execution.

This is a drawback!

Those 21_474_836_627 gas units are ~4 mins of execution time on my machine. u64::MAX gas units would give us like 6,500 years of execution 😄 (if I didn't mess the calculations).

Putting the PR into draft.

I want to have the possibility to increase the gas limit without tweaking the compiler. But it looks having a CLI option would be the right way to do it. E.g., forc call has sctipt-gas-limit. Also, I can imagine wanting to have it other way around to lower the limit to get high consuming tests fail.

What we also need to improve is the error message in the case of running out of gas. Currently we get the infamous Revert(0) 😞

zees-dev
zees-dev previously approved these changes Nov 17, 2025
vaivaswatha
vaivaswatha previously approved these changes Nov 25, 2025
@ironcev ironcev dismissed stale reviews from vaivaswatha, zees-dev, and kayagokalp via c7ca4be December 1, 2025 12:57
@ironcev ironcev changed the title Remove gas limits in forc test Optionally remove test gas limit in forc test Dec 1, 2025
@ironcev ironcev marked this pull request as ready for review December 1, 2025 13:05
@ironcev ironcev requested a review from a team as a code owner December 1, 2025 13:05
@cursor
Copy link

cursor bot commented Dec 1, 2025

PR Summary

Adds --no-gas-limit to forc test and introduces TestGasLimit to control tx gas, wiring it through consensus params and test execution.

  • CLI:
    • Add --no-gas-limit to forc test to run tests with unlimited gas.
  • Core (forc-test):
    • Introduce enum TestGasLimit { Default, Unlimited, Limited(u64) }.
    • Thread gas_limit through BuiltTests::run, PackageTests::run_tests, and execute::TestExecutor::build.
    • Update maxed_consensus_params(gas_costs_values, gas_limit) to set tx_params.max_gas_per_tx per TestGasLimit and include block_gas_limit = u64::MAX.
    • Use TestGasLimit::default() for deployments and defaults.
  • Debug Adapter (forc-plugins/forc-debug/src/server/mod.rs):
    • Pass TestGasLimit::default() to TestExecutor::build.
  • E2E Harness (test/src/e2e_vm_tests/harness.rs):
    • Update calls to BuiltTests::run(...) to include TestGasLimit::default().
  • Config:
    • Minor .typos.toml updates (ignore list/exclusions).

Written by Cursor Bugbot for commit 4e47b31. This will update automatically on new commits. Configure here.

@ironcev ironcev enabled auto-merge (squash) December 1, 2025 13:05
@JoshuaBatty JoshuaBatty requested a review from a team December 2, 2025 01:48
@ironcev ironcev merged commit c73137d into master Dec 2, 2025
46 checks passed
@ironcev ironcev deleted the ironcev/remove-gas-limits-in-forc-test branch December 2, 2025 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing General testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants