Revert OutOfGas error when using the produce_blocks function in the provider to go forward in time
calldelegation opened this issue ยท 4 comments
calldelegation commented
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
Rcontre360 commented
Hi! is there any progress with this?
Br1ght0ne commented
Reproduced on both fuels 0.62
and fuels 0.64
, looking into it.
Br1ght0ne commented
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);
Br1ght0ne commented
@calldelegation There's a way to fix the problem in Sway, without the TxPolicies
change, 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")