From c83f6ae060970757d32f79aae5113b37b6a37395 Mon Sep 17 00:00:00 2001 From: vladenysiuk Date: Tue, 2 Apr 2024 11:54:22 +0100 Subject: [PATCH] fix returndata + comments --- system-contracts/contracts/EvmInterpreter.sol | 10 +++++----- .../contracts/interfaces/IEvmGasManager.sol | 8 -------- .../contracts/libraries/SystemContractsCaller.sol | 11 ++++++----- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/system-contracts/contracts/EvmInterpreter.sol b/system-contracts/contracts/EvmInterpreter.sol index 7ac3a6ce7..5a89c966e 100644 --- a/system-contracts/contracts/EvmInterpreter.sol +++ b/system-contracts/contracts/EvmInterpreter.sol @@ -387,7 +387,7 @@ contract EvmInterpreter { uint32 dataStart = 0; uint32 dataLength = 36; - bool success = SystemContractsCaller.contractCall(uint32(gasleft()), addr, 0, 0, 36); + bool success = SystemContractsCaller.rawSystemCall(uint32(gasleft()), addr, 0, 0, 36, true); assembly { if iszero(success) { // This error should never happen @@ -433,7 +433,7 @@ contract EvmInterpreter { mstore(4, key) mstore(36, currentValue) } - bool success = SystemContractsCaller.contractCall(uint32(gasleft()), addr, 0, 0, 68); + bool success = SystemContractsCaller.rawSystemCall(uint32(gasleft()), addr, 0, 0, 68, true); assembly { if iszero(success) { // This error should never happen @@ -2313,7 +2313,7 @@ contract EvmInterpreter { mstore(4, _passGas) mstore(36, _isStatic) } - bool success = SystemContractsCaller.contractCall(uint32(gasleft()), addr, 0, 0, 68); + bool success = SystemContractsCaller.rawSystemCall(uint32(gasleft()), addr, 0, 0, 68, true); assembly { if iszero(success) { // This error should never happen @@ -2328,7 +2328,7 @@ contract EvmInterpreter { assembly { mstore(0, selector) } - bool success = SystemContractsCaller.contractCall(uint32(gasleft()), addr, 0, 0, 4); + bool success = SystemContractsCaller.rawSystemCall(uint32(gasleft()), addr, 0, 0, 4, true); assembly { if iszero(success) { // This error should never happen @@ -2343,7 +2343,7 @@ contract EvmInterpreter { assembly { mstore(0, selector) } - bool success = SystemContractsCaller.contractCall(uint32(gasleft()), addr, 0, 0, 4); + bool success = SystemContractsCaller.rawSystemCall(uint32(gasleft()), addr, 0, 0, 4, true); assembly { _passGas := mload(0) isStatic := mload(32) diff --git a/system-contracts/contracts/interfaces/IEvmGasManager.sol b/system-contracts/contracts/interfaces/IEvmGasManager.sol index cc400d41b..177f1d949 100644 --- a/system-contracts/contracts/interfaces/IEvmGasManager.sol +++ b/system-contracts/contracts/interfaces/IEvmGasManager.sol @@ -1,13 +1,5 @@ pragma solidity ^0.8.20; -/** - * @author Matter Labs - * @dev The interface that is used for encoding/decoding of - * different types of paymaster flows. - * @notice This is NOT an interface to be implementated - * by contracts. It is just used for encoding. - */ - interface IEvmGasManager { function warmAccount(address account) external payable returns (bool wasWarm); diff --git a/system-contracts/contracts/libraries/SystemContractsCaller.sol b/system-contracts/contracts/libraries/SystemContractsCaller.sol index 5ce630185..2eb679640 100644 --- a/system-contracts/contracts/libraries/SystemContractsCaller.sol +++ b/system-contracts/contracts/libraries/SystemContractsCaller.sol @@ -70,19 +70,20 @@ enum CalldataForwardingMode { * @dev It is needed to call ContractDeployer and NonceHolder. */ library SystemContractsCaller { - /// @notice executes a low-level call with the `isSystem` flag. + /// @notice Executes a low-level call with the `isSystem` flag. /// @param gasLimit The gas limit for the call. /// @param to The address to call. /// @param value The value to pass with the transaction. /// @param dataStart Beggining of the calldata /// @param dataLength The size of the calldata. /// @return success Whether the transaction has been successful. - function contractCall( + function rawSystemCall( uint32 gasLimit, address to, uint256 value, uint32 dataStart, - uint32 dataLength + uint32 dataLength, + bool returnDataCopy ) internal returns (bool success) { address callAddr = SYSTEM_CALL_CALL_ADDRESS; uint256 farCallAbi = SystemContractsCaller.getFarCallABI( @@ -112,7 +113,7 @@ library SystemContractsCaller { success := call(msgValueSimulator, callAddr, value, to, farCallAbi, forwardMask, 0) } } - if (success) { + if (success && returnDataCopy) { assembly { let returndataSize := returndatasize() returndatacopy(0, 0, returndataSize) @@ -133,7 +134,7 @@ library SystemContractsCaller { dataStart := add(data, 0x20) } uint32 dataLength = uint32(Utils.safeCastToU32(data.length)); - success = contractCall(gasLimit, to, value, dataStart, dataLength); + success = rawSystemCall(gasLimit, to, value, dataStart, dataLength, false); } /// @notice Makes a call with the `isSystem` flag.