Skip to content

Commit

Permalink
Add system call with return value
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Aug 26, 2024
1 parent 4090937 commit 0d47c89
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion system-contracts/contracts/EvmGasManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ contract EvmGasManager is ISystemContract {
evmStackFrames.push(frame);
}

function consumeEvmFrame() external returns (uint256 passGas, bool isStatic) {
function consumeEvmFrame() onlySystemCall onlySystemEvm external returns (uint256 passGas, bool isStatic) {
if (evmStackFrames.length == 0) return (INF_PASS_GAS, false);

EVMStackFrameInfo memory frameInfo = evmStackFrames[evmStackFrames.length - 1];
Expand Down
17 changes: 16 additions & 1 deletion system-contracts/contracts/EvmInterpreterFunctions.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,28 @@ function consumeEvmFrame() -> passGas, isStatic, callerEVM {
// function consumeEvmFrame() external returns (uint256 passGas, bool isStatic)
mstore(0, 0x04C14E9E00000000000000000000000000000000000000000000000000000000)

let success := call(gas(), EVM_GAS_MANAGER_CONTRACT(), 0, 0, 4, 0, 64)
let farCallAbi := getFarCallABI(
0,
0,
0,
4,
gas(),
// Only rollup is supported for now
0,
0,
0,
1
)
let to := EVM_GAS_MANAGER_CONTRACT()
let success := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0)

if iszero(success) {
// Should never happen
revert(0, 0)
}

returndatacopy(0,0,64)

passGas := mload(0)
isStatic := mload(32)

Expand Down
34 changes: 32 additions & 2 deletions system-contracts/contracts/EvmInterpreterPreprocessed.yul
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,28 @@ object "EVMInterpreter" {
// function consumeEvmFrame() external returns (uint256 passGas, bool isStatic)
mstore(0, 0x04C14E9E00000000000000000000000000000000000000000000000000000000)

let success := call(gas(), EVM_GAS_MANAGER_CONTRACT(), 0, 0, 4, 0, 64)
let farCallAbi := getFarCallABI(
0,
0,
0,
4,
gas(),
// Only rollup is supported for now
0,
0,
0,
1
)
let to := EVM_GAS_MANAGER_CONTRACT()
let success := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0)

if iszero(success) {
// Should never happen
revert(0, 0)
}

returndatacopy(0,0,64)

passGas := mload(0)
isStatic := mload(32)

Expand Down Expand Up @@ -3419,13 +3434,28 @@ object "EVMInterpreter" {
// function consumeEvmFrame() external returns (uint256 passGas, bool isStatic)
mstore(0, 0x04C14E9E00000000000000000000000000000000000000000000000000000000)

let success := call(gas(), EVM_GAS_MANAGER_CONTRACT(), 0, 0, 4, 0, 64)
let farCallAbi := getFarCallABI(
0,
0,
0,
4,
gas(),
// Only rollup is supported for now
0,
0,
0,
1
)
let to := EVM_GAS_MANAGER_CONTRACT()
let success := verbatim_6i_1o("system_call", to, farCallAbi, 0, 0, 0, 0)

if iszero(success) {
// Should never happen
revert(0, 0)
}

returndatacopy(0,0,64)

passGas := mload(0)
isStatic := mload(32)

Expand Down

0 comments on commit 0d47c89

Please sign in to comment.