Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

feat: Have ExecutionManager pass data up #342

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ contract OVM_ProxyEOA {
return(add(returndata, 0x20), mload(returndata))
}
} else {
Lib_SafeExecutionManagerWrapper.safeREVERT(
string(returndata)
Lib_SafeExecutionManagerWrapper.safeREVERTbytes(
returndata
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,19 @@ 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,
address _ovmStateManager
)
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
Expand Down Expand Up @@ -185,15 +191,15 @@ 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.
// // Check gas right before the call to get total gas consumed by OVM transaction.
// 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
Expand All @@ -209,6 +215,8 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {

// Reset the ovmStateManager.
ovmStateManager = iOVM_StateManager(address(0));

return (success, returndata);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
maurelian marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
Lib_SafeExecutionManagerWrapper.safeREVERTbytes(
returndata
);
}
}


/**********************
* Internal Functions *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ interface iOVM_ExecutionManager {
function run(
Lib_OVMCodec.Transaction calldata _transaction,
address _txStateManager
) external;
)
external
returns (
bool,
bytes memory
);


/*******************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -355,10 +372,6 @@ library Lib_SafeExecutionManagerWrapper {
assembly {
revert(add(returndata, 0x20), mload(returndata))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's outside of scope, but why does this need assembly?

}
} else if (returndata.length == 1) {
assembly {
return(0, 1)
}
} else {
return returndata;
}
Expand Down