diff --git a/system-contracts/contracts/EvmInterpreterFunctions.template.yul b/system-contracts/contracts/EvmInterpreterFunctions.template.yul index 89f3837c7..9e70a22d9 100644 --- a/system-contracts/contracts/EvmInterpreterFunctions.template.yul +++ b/system-contracts/contracts/EvmInterpreterFunctions.template.yul @@ -823,12 +823,13 @@ function getEVMGas() -> evmGas { let _gas := gas() let requiredGas := add(EVM_GAS_STIPEND(), OVERHEAD()) - if lt(sub(_gas,shl(30,1)), requiredGas) { - // This cheks if enough zkevm gas was provided, we are substracting 2^30 since that's the stipend, - // and we need to make sure that the gas provided over that is enough for security reasons - revert(0, 0) + switch lt(_gas, requiredGas) + case 1 { + evmGas := 0 + } + default { + evmGas := div(sub(_gas, requiredGas), GAS_DIVISOR()) } - evmGas := div(sub(_gas, requiredGas), GAS_DIVISOR()) } function _getZkEVMGas(_evmGas) -> zkevmGas { diff --git a/system-contracts/contracts/EvmInterpreterPreprocessed.yul b/system-contracts/contracts/EvmInterpreterPreprocessed.yul index b4ae22738..962c991d9 100644 --- a/system-contracts/contracts/EvmInterpreterPreprocessed.yul +++ b/system-contracts/contracts/EvmInterpreterPreprocessed.yul @@ -897,12 +897,13 @@ object "EVMInterpreter" { let _gas := gas() let requiredGas := add(EVM_GAS_STIPEND(), OVERHEAD()) - if lt(sub(_gas,shl(30,1)), requiredGas) { - // This cheks if enough zkevm gas was provided, we are substracting 2^30 since that's the stipend, - // and we need to make sure that the gas provided over that is enough for security reasons - revert(0, 0) + switch lt(_gas, requiredGas) + case 1 { + evmGas := 0 + } + default { + evmGas := div(sub(_gas, requiredGas), GAS_DIVISOR()) } - evmGas := div(sub(_gas, requiredGas), GAS_DIVISOR()) } function _getZkEVMGas(_evmGas) -> zkevmGas { @@ -3728,12 +3729,13 @@ object "EVMInterpreter" { let _gas := gas() let requiredGas := add(EVM_GAS_STIPEND(), OVERHEAD()) - if lt(sub(_gas,shl(30,1)), requiredGas) { - // This cheks if enough zkevm gas was provided, we are substracting 2^30 since that's the stipend, - // and we need to make sure that the gas provided over that is enough for security reasons - revert(0, 0) + switch lt(_gas, requiredGas) + case 1 { + evmGas := 0 + } + default { + evmGas := div(sub(_gas, requiredGas), GAS_DIVISOR()) } - evmGas := div(sub(_gas, requiredGas), GAS_DIVISOR()) } function _getZkEVMGas(_evmGas) -> zkevmGas {