Skip to content

Commit

Permalink
Simplify consumeEvmFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov committed Sep 11, 2024
1 parent 57ef771 commit eed9402
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions system-contracts/contracts/EvmGasManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {SystemContractHelper} from "./libraries/SystemContractHelper.sol";
// We consider all the contracts (including system ones) as warm.
uint160 constant PRECOMPILES_END = 0xffff;

// Denotes that passGas has been consumed
uint256 constant INF_PASS_GAS = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;

// Transient storage prefixes
Expand Down Expand Up @@ -116,10 +115,8 @@ contract EvmGasManager {
When conducting call:
1. caller calls to an EVM contract pushEVMFrame with the corresponding gas
2. callee calls consumeEvmFrame to get the gas & make sure that subsequent callee won't be able to read it.
3. callee sets the return gas
4. callee calls popEVMFrame to return the gas to the caller & remove the frame
2. callee calls consumeEvmFrame to get the gas and determine if a call is static
3. calleer calls popEVMFrame to remove the frame
*/

function pushEVMFrame(uint256 passGas, bool isStatic) external onlySystemEvm {
Expand All @@ -132,7 +129,7 @@ contract EvmGasManager {
}
}

function consumeEvmFrame() external onlySystemEvm returns (uint256 passGas, bool isStatic) {
function consumeEvmFrame() external view returns (uint256 passGas, bool isStatic) {
uint256 stackDepth;
assembly {
stackDepth := tload(EVM_STACK_SLOT)
Expand All @@ -143,7 +140,6 @@ contract EvmGasManager {
let stackPointer := add(EVM_STACK_SLOT, mul(2, stackDepth))
passGas := tload(stackPointer)
isStatic := tload(add(stackPointer, 1))
tstore(stackPointer, INF_PASS_GAS) // Mark as used
}
}

Expand Down

0 comments on commit eed9402

Please sign in to comment.