Skip to content

Conversation

@ironcev
Copy link
Member

@ironcev ironcev commented Nov 14, 2025

Description

This PR increases gas limits 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.

Note that other max parameters like script length, script data length, number of transaction parameters etc. are already set to u64::MAX. Therefore, I don't see a drawback for this change.

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.

Note

Sets with_max_gas_per_tx(u64::MAX) and block_gas_limit = u64::MAX in maxed_consensus_params for forc test.

  • Consensus parameters (for tests) in forc-test/src/lib.rs:
    • Tx parameters: add TxParameters::DEFAULT.with_max_size(u64::MAX).with_max_gas_per_tx(u64::MAX).
    • Block limit: set ConsensusParametersV1.block_gas_limit = u64::MAX.

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

@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

👍

@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) 😞

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.

5 participants