FuelLabs/fuels-rs

Revert OutOfGas error when using the produce_blocks function in the provider to go forward in time

calldelegation opened this issue ยท 4 comments

The bug happens when trying to go forward in time using the provider.produce_blocks function
After doing that, the calls performed to the same contract fail with a Revert OutOfGas error

This issue was found by the protofire team

Repository to reproduce the bug
https://github.com/0xLucca/fuels-bug

Hi! is there any progress with this?

Reproduced on both fuels 0.62 and fuels 0.64, looking into it.

Seems like adding an explicit gas limit with TxPolicies allows the test to pass:

@@ -85,7 +85,7 @@ async fn bug_occurs_when_time_is_incremented() {
     // Now that the time has passed, we should be able to execute the action
     let result = contract_caller
         .contract
-        .methods().execute_some_action().call_params(params).unwrap().call().await;
+        .methods().execute_some_action().with_tx_policies(TxPolicies::default().with_script_gas_limit(2_000)).call_params(params).unwrap().call().await;
 
     // But it reverts with OutOfGas error
     println!("{:?}", result);

@calldelegation There's a way to fix the problem in Sway, without the TxPolicieschange, by moving the state lookups from inside the require call to separate calls, like this:

        let start_time = storage.start_time.read();
        let end_time = storage.end_time.read();

        require(asset_amount > 0, "Asset amount must be greater than 0");
        require(current_time >= start_time && current_time < end_time, "Action can only be executed within the time window")