diff --git a/contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol b/contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol index 0f376f821..904b23d2a 100644 --- a/contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol +++ b/contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol @@ -58,8 +58,8 @@ contract OVM_ProxyEOA { return(add(returndata, 0x20), mload(returndata)) } } else { - Lib_SafeExecutionManagerWrapper.safeREVERT( - string(returndata) + Lib_SafeExecutionManagerWrapper.safeREVERTbytes( + returndata ); } } diff --git a/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol b/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol index 9c30f819b..266cb6bde 100644 --- a/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol +++ b/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol @@ -151,6 +151,8 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { * Starts the execution of a transaction via the OVM_ExecutionManager. * @param _transaction Transaction data to be executed. * @param _ovmStateManager iOVM_StateManager implementation providing account state. + * @return `true` if the top-level CALL succeeded, `false` if it reverted. + * @return Data returned by the top-level CALL. */ function run( Lib_OVMCodec.Transaction memory _transaction, @@ -158,6 +160,10 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ) override public + returns ( + bool, + bytes memory + ) { require(transactionContext.ovmNUMBER == 0, "Only be callable at the start of a transaction"); // Store our OVM_StateManager instance (significantly easier than attempting to pass the @@ -185,7 +191,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { // reverts for INVALID_STATE_ACCESS. if (_isValidGasLimit(_transaction.gasLimit, _transaction.l1QueueOrigin) == false) { _resetContext(); - return; + return (false, bytes("")); } // TEMPORARY: Gas metering is disabled for minnet. @@ -193,7 +199,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { // uint256 gasProvided = gasleft(); // Run the transaction, make sure to meter the gas usage. - ovmCALL( + (bool success, bytes memory returndata) = ovmCALL( _transaction.gasLimit - gasMeterConfig.minTransactionGasLimit, _transaction.entrypoint, _transaction.data @@ -209,6 +215,8 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { // Reset the ovmStateManager. ovmStateManager = iOVM_StateManager(address(0)); + + return (success, returndata); } diff --git a/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol b/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol index bba7dd59c..4371719d4 100644 --- a/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol +++ b/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol @@ -89,13 +89,23 @@ contract OVM_SequencerEntrypoint { s ); - Lib_SafeExecutionManagerWrapper.safeCALL( + (bool success, bytes memory returndata) = Lib_SafeExecutionManagerWrapper.safeCALL( gasleft(), target, callbytes ); + + if (success) { + assembly { + return(add(returndata, 0x20), mload(returndata)) + } + } else { + Lib_SafeExecutionManagerWrapper.safeREVERTbytes( + returndata + ); + } } - + /********************** * Internal Functions * diff --git a/contracts/optimistic-ethereum/iOVM/execution/iOVM_ExecutionManager.sol b/contracts/optimistic-ethereum/iOVM/execution/iOVM_ExecutionManager.sol index 404822fc9..5e39c0776 100644 --- a/contracts/optimistic-ethereum/iOVM/execution/iOVM_ExecutionManager.sol +++ b/contracts/optimistic-ethereum/iOVM/execution/iOVM_ExecutionManager.sol @@ -75,7 +75,12 @@ interface iOVM_ExecutionManager { function run( Lib_OVMCodec.Transaction calldata _transaction, address _txStateManager - ) external; + ) + external + returns ( + bool, + bytes memory + ); /******************* diff --git a/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol b/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol index 5ebe12fb4..c59c644b5 100644 --- a/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol +++ b/contracts/optimistic-ethereum/libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol @@ -269,6 +269,23 @@ library Lib_SafeExecutionManagerWrapper { ); } + /** + * Same as safeREVERT, but does *not* attach the sighash of Error(string). + * @param _revertdata Data to revert with. + */ + function safeREVERTbytes( + bytes memory _revertdata + ) + internal + { + _safeExecutionManagerInteraction( + abi.encodeWithSignature( + "ovmREVERT(bytes)", + _revertdata + ) + ); + } + /** * Performs a safe "require". * @param _condition Boolean condition that must be true or will revert. @@ -355,10 +372,6 @@ library Lib_SafeExecutionManagerWrapper { assembly { revert(add(returndata, 0x20), mload(returndata)) } - } else if (returndata.length == 1) { - assembly { - return(0, 1) - } } else { return returndata; }