Skip to content

Commit

Permalink
fix returndata + comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vladenysiuk committed Apr 2, 2024
1 parent c7db582 commit c83f6ae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
10 changes: 5 additions & 5 deletions system-contracts/contracts/EvmInterpreter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions system-contracts/contracts/interfaces/IEvmGasManager.sol
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
11 changes: 6 additions & 5 deletions system-contracts/contracts/libraries/SystemContractsCaller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down

0 comments on commit c83f6ae

Please sign in to comment.