Commit 148cb966 authored by ben-chain's avatar ben-chain Committed by GitHub

remove msg.sender from all SafeEM calls (#68)

parent d85d00fa
...@@ -45,7 +45,6 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { ...@@ -45,7 +45,6 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
bytes memory _returndata bytes memory _returndata
) )
{ {
address ovmExecutionManager = msg.sender;
bool isEthSign = _signatureType == Lib_OVMCodec.EOASignatureType.ETH_SIGNED_MESSAGE; bool isEthSign = _signatureType == Lib_OVMCodec.EOASignatureType.ETH_SIGNED_MESSAGE;
// Address of this contract within the ovm (ovmADDRESS) should be the same as the // Address of this contract within the ovm (ovmADDRESS) should be the same as the
...@@ -53,14 +52,13 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { ...@@ -53,14 +52,13 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// account abstraction even though the user isn't a contract. // account abstraction even though the user isn't a contract.
// Need to make sure that the transaction nonce is right and bump it if so. // Need to make sure that the transaction nonce is right and bump it if so.
Lib_SafeExecutionManagerWrapper.safeREQUIRE( Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender,
Lib_ECDSAUtils.recover( Lib_ECDSAUtils.recover(
_transaction, _transaction,
isEthSign, isEthSign,
_v, _v,
_r, _r,
_s _s
) == Lib_SafeExecutionManagerWrapper.safeADDRESS(ovmExecutionManager), ) == Lib_SafeExecutionManagerWrapper.safeADDRESS(),
"Signature provided for EOA transaction execution is invalid." "Signature provided for EOA transaction execution is invalid."
); );
...@@ -68,16 +66,14 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { ...@@ -68,16 +66,14 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// Need to make sure that the transaction nonce is right. // Need to make sure that the transaction nonce is right.
Lib_SafeExecutionManagerWrapper.safeREQUIRE( Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender, decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(),
decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(ovmExecutionManager),
"Transaction nonce does not match the expected nonce." "Transaction nonce does not match the expected nonce."
); );
// Transfer fee to relayer. // Transfer fee to relayer.
address relayer = Lib_SafeExecutionManagerWrapper.safeCALLER(ovmExecutionManager); address relayer = Lib_SafeExecutionManagerWrapper.safeCALLER();
uint256 fee = decodedTx.gasLimit * decodedTx.gasPrice; uint256 fee = decodedTx.gasLimit * decodedTx.gasPrice;
Lib_SafeExecutionManagerWrapper.safeCALL( Lib_SafeExecutionManagerWrapper.safeCALL(
ovmExecutionManager,
gasleft(), gasleft(),
ETH_ERC20_ADDRESS, ETH_ERC20_ADDRESS,
abi.encodeWithSignature("transfer(address,uint256)", relayer, fee) abi.encodeWithSignature("transfer(address,uint256)", relayer, fee)
...@@ -86,7 +82,6 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { ...@@ -86,7 +82,6 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// Contract creations are signalled by sending a transaction to the zero address. // Contract creations are signalled by sending a transaction to the zero address.
if (decodedTx.to == address(0)) { if (decodedTx.to == address(0)) {
address created = Lib_SafeExecutionManagerWrapper.safeCREATE( address created = Lib_SafeExecutionManagerWrapper.safeCREATE(
ovmExecutionManager,
decodedTx.gasLimit - 2000, decodedTx.gasLimit - 2000,
decodedTx.data decodedTx.data
); );
...@@ -98,10 +93,9 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { ...@@ -98,10 +93,9 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// We only want to bump the nonce for `ovmCALL` because `ovmCREATE` automatically bumps // We only want to bump the nonce for `ovmCALL` because `ovmCREATE` automatically bumps
// the nonce of the calling account. Normally an EOA would bump the nonce for both // the nonce of the calling account. Normally an EOA would bump the nonce for both
// cases, but since this is a contract we'd end up bumping the nonce twice. // cases, but since this is a contract we'd end up bumping the nonce twice.
Lib_SafeExecutionManagerWrapper.safeSETNONCE(ovmExecutionManager, decodedTx.nonce + 1); Lib_SafeExecutionManagerWrapper.safeSETNONCE(decodedTx.nonce + 1);
return Lib_SafeExecutionManagerWrapper.safeCALL( return Lib_SafeExecutionManagerWrapper.safeCALL(
ovmExecutionManager,
decodedTx.gasLimit, decodedTx.gasLimit,
decodedTx.to, decodedTx.to,
decodedTx.data decodedTx.data
......
...@@ -30,7 +30,6 @@ contract OVM_ProxyEOA { ...@@ -30,7 +30,6 @@ contract OVM_ProxyEOA {
external external
{ {
(bool success, bytes memory returndata) = Lib_SafeExecutionManagerWrapper.safeDELEGATECALL( (bool success, bytes memory returndata) = Lib_SafeExecutionManagerWrapper.safeDELEGATECALL(
msg.sender,
gasleft(), gasleft(),
getImplementation(), getImplementation(),
msg.data msg.data
...@@ -42,7 +41,6 @@ contract OVM_ProxyEOA { ...@@ -42,7 +41,6 @@ contract OVM_ProxyEOA {
} }
} else { } else {
Lib_SafeExecutionManagerWrapper.safeREVERT( Lib_SafeExecutionManagerWrapper.safeREVERT(
msg.sender,
string(returndata) string(returndata)
); );
} }
...@@ -59,8 +57,7 @@ contract OVM_ProxyEOA { ...@@ -59,8 +57,7 @@ contract OVM_ProxyEOA {
external external
{ {
Lib_SafeExecutionManagerWrapper.safeREQUIRE( Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender, Lib_SafeExecutionManagerWrapper.safeADDRESS() == Lib_SafeExecutionManagerWrapper.safeCALLER(),
Lib_SafeExecutionManagerWrapper.safeADDRESS(msg.sender) == Lib_SafeExecutionManagerWrapper.safeCALLER(msg.sender),
"EOAs can only upgrade their own EOA implementation" "EOAs can only upgrade their own EOA implementation"
); );
...@@ -75,7 +72,6 @@ contract OVM_ProxyEOA { ...@@ -75,7 +72,6 @@ contract OVM_ProxyEOA {
{ {
return address(uint160(uint256( return address(uint160(uint256(
Lib_SafeExecutionManagerWrapper.safeSLOAD( Lib_SafeExecutionManagerWrapper.safeSLOAD(
msg.sender,
bytes32(uint256(0)) bytes32(uint256(0))
) )
))); )));
...@@ -91,7 +87,6 @@ contract OVM_ProxyEOA { ...@@ -91,7 +87,6 @@ contract OVM_ProxyEOA {
internal internal
{ {
Lib_SafeExecutionManagerWrapper.safeSSTORE( Lib_SafeExecutionManagerWrapper.safeSSTORE(
msg.sender,
bytes32(uint256(0)), bytes32(uint256(0)),
bytes32(uint256(uint160(_implementation))) bytes32(uint256(uint160(_implementation)))
); );
......
...@@ -16,7 +16,6 @@ contract OVM_ProxySequencerEntrypoint { ...@@ -16,7 +16,6 @@ contract OVM_ProxySequencerEntrypoint {
external external
{ {
Lib_SafeExecutionManagerWrapper.safeDELEGATECALL( Lib_SafeExecutionManagerWrapper.safeDELEGATECALL(
msg.sender,
gasleft(), gasleft(),
_getImplementation(), _getImplementation(),
msg.data msg.data
...@@ -35,7 +34,6 @@ contract OVM_ProxySequencerEntrypoint { ...@@ -35,7 +34,6 @@ contract OVM_ProxySequencerEntrypoint {
external external
{ {
Lib_SafeExecutionManagerWrapper.safeREQUIRE( Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender,
_getOwner() == address(0), _getOwner() == address(0),
"ProxySequencerEntrypoint has already been inited" "ProxySequencerEntrypoint has already been inited"
); );
...@@ -49,8 +47,7 @@ contract OVM_ProxySequencerEntrypoint { ...@@ -49,8 +47,7 @@ contract OVM_ProxySequencerEntrypoint {
external external
{ {
Lib_SafeExecutionManagerWrapper.safeREQUIRE( Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender, _getOwner() == Lib_SafeExecutionManagerWrapper.safeCALLER(),
_getOwner() == Lib_SafeExecutionManagerWrapper.safeCALLER(msg.sender),
"Only owner can upgrade the Entrypoint" "Only owner can upgrade the Entrypoint"
); );
...@@ -68,7 +65,6 @@ contract OVM_ProxySequencerEntrypoint { ...@@ -68,7 +65,6 @@ contract OVM_ProxySequencerEntrypoint {
internal internal
{ {
Lib_SafeExecutionManagerWrapper.safeSSTORE( Lib_SafeExecutionManagerWrapper.safeSSTORE(
msg.sender,
bytes32(uint256(0)), bytes32(uint256(0)),
bytes32(uint256(uint160(_implementation))) bytes32(uint256(uint160(_implementation)))
); );
...@@ -82,7 +78,6 @@ contract OVM_ProxySequencerEntrypoint { ...@@ -82,7 +78,6 @@ contract OVM_ProxySequencerEntrypoint {
{ {
return address(uint160(uint256( return address(uint160(uint256(
Lib_SafeExecutionManagerWrapper.safeSLOAD( Lib_SafeExecutionManagerWrapper.safeSLOAD(
msg.sender,
bytes32(uint256(0)) bytes32(uint256(0))
) )
))); )));
...@@ -94,7 +89,6 @@ contract OVM_ProxySequencerEntrypoint { ...@@ -94,7 +89,6 @@ contract OVM_ProxySequencerEntrypoint {
internal internal
{ {
Lib_SafeExecutionManagerWrapper.safeSSTORE( Lib_SafeExecutionManagerWrapper.safeSSTORE(
msg.sender,
bytes32(uint256(1)), bytes32(uint256(1)),
bytes32(uint256(uint160(_owner))) bytes32(uint256(uint160(_owner)))
); );
...@@ -108,7 +102,6 @@ contract OVM_ProxySequencerEntrypoint { ...@@ -108,7 +102,6 @@ contract OVM_ProxySequencerEntrypoint {
{ {
return address(uint160(uint256( return address(uint160(uint256(
Lib_SafeExecutionManagerWrapper.safeSLOAD( Lib_SafeExecutionManagerWrapper.safeSLOAD(
msg.sender,
bytes32(uint256(1)) bytes32(uint256(1))
) )
))); )));
......
...@@ -63,10 +63,10 @@ contract OVM_SequencerEntrypoint { ...@@ -63,10 +63,10 @@ contract OVM_SequencerEntrypoint {
s s
); );
if (Lib_SafeExecutionManagerWrapper.safeEXTCODESIZE(msg.sender, target) == 0) { if (Lib_SafeExecutionManagerWrapper.safeEXTCODESIZE(target) == 0) {
// ProxyEOA has not yet been deployed for this EOA. // ProxyEOA has not yet been deployed for this EOA.
bytes32 messageHash = Lib_ECDSAUtils.getMessageHash(encodedTx, isEthSignedMessage); bytes32 messageHash = Lib_ECDSAUtils.getMessageHash(encodedTx, isEthSignedMessage);
Lib_SafeExecutionManagerWrapper.safeCREATEEOA(msg.sender, messageHash, uint8(v), r, s); Lib_SafeExecutionManagerWrapper.safeCREATEEOA(messageHash, uint8(v), r, s);
} }
// ProxyEOA has been deployed for this EOA, continue to CALL. // ProxyEOA has been deployed for this EOA, continue to CALL.
...@@ -80,7 +80,6 @@ contract OVM_SequencerEntrypoint { ...@@ -80,7 +80,6 @@ contract OVM_SequencerEntrypoint {
); );
Lib_SafeExecutionManagerWrapper.safeCALL( Lib_SafeExecutionManagerWrapper.safeCALL(
msg.sender,
gasleft(), gasleft(),
target, target,
callbytes callbytes
...@@ -111,7 +110,6 @@ contract OVM_SequencerEntrypoint { ...@@ -111,7 +110,6 @@ contract OVM_SequencerEntrypoint {
return TransactionType.ETH_SIGNED_MESSAGE; return TransactionType.ETH_SIGNED_MESSAGE;
} else { } else {
Lib_SafeExecutionManagerWrapper.safeREVERT( Lib_SafeExecutionManagerWrapper.safeREVERT(
msg.sender,
"Transaction type must be 0 or 2" "Transaction type must be 0 or 2"
); );
} }
......
...@@ -12,7 +12,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -12,7 +12,6 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Makes an ovmCALL and performs all the necessary safety checks. * Makes an ovmCALL and performs all the necessary safety checks.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @param _gasLimit Gas limit for the call. * @param _gasLimit Gas limit for the call.
* @param _target Address to call. * @param _target Address to call.
* @param _calldata Data to send to the call. * @param _calldata Data to send to the call.
...@@ -20,7 +19,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -20,7 +19,6 @@ library Lib_SafeExecutionManagerWrapper {
* @return _returndata Data returned by the call. * @return _returndata Data returned by the call.
*/ */
function safeCALL( function safeCALL(
address _ovmExecutionManager,
uint256 _gasLimit, uint256 _gasLimit,
address _target, address _target,
bytes memory _calldata bytes memory _calldata
...@@ -32,7 +30,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -32,7 +30,6 @@ library Lib_SafeExecutionManagerWrapper {
) )
{ {
bytes memory returndata = _safeExecutionManagerInteraction( bytes memory returndata = _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmCALL(uint256,address,bytes)", "ovmCALL(uint256,address,bytes)",
_gasLimit, _gasLimit,
...@@ -46,7 +43,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -46,7 +43,6 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Makes an ovmCALL and performs all the necessary safety checks. * Makes an ovmCALL and performs all the necessary safety checks.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @param _gasLimit Gas limit for the call. * @param _gasLimit Gas limit for the call.
* @param _target Address to call. * @param _target Address to call.
* @param _calldata Data to send to the call. * @param _calldata Data to send to the call.
...@@ -54,7 +50,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -54,7 +50,6 @@ library Lib_SafeExecutionManagerWrapper {
* @return _returndata Data returned by the call. * @return _returndata Data returned by the call.
*/ */
function safeDELEGATECALL( function safeDELEGATECALL(
address _ovmExecutionManager,
uint256 _gasLimit, uint256 _gasLimit,
address _target, address _target,
bytes memory _calldata bytes memory _calldata
...@@ -66,7 +61,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -66,7 +61,6 @@ library Lib_SafeExecutionManagerWrapper {
) )
{ {
bytes memory returndata = _safeExecutionManagerInteraction( bytes memory returndata = _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmDELEGATECALL(uint256,address,bytes)", "ovmDELEGATECALL(uint256,address,bytes)",
_gasLimit, _gasLimit,
...@@ -80,13 +74,11 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -80,13 +74,11 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs an ovmCREATE and the necessary safety checks. * Performs an ovmCREATE and the necessary safety checks.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @param _gasLimit Gas limit for the creation. * @param _gasLimit Gas limit for the creation.
* @param _bytecode Code for the new contract. * @param _bytecode Code for the new contract.
* @return _contract Address of the created contract. * @return _contract Address of the created contract.
*/ */
function safeCREATE( function safeCREATE(
address _ovmExecutionManager,
uint256 _gasLimit, uint256 _gasLimit,
bytes memory _bytecode bytes memory _bytecode
) )
...@@ -96,7 +88,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -96,7 +88,6 @@ library Lib_SafeExecutionManagerWrapper {
) )
{ {
bytes memory returndata = _safeExecutionManagerInteraction( bytes memory returndata = _safeExecutionManagerInteraction(
_ovmExecutionManager,
_gasLimit, _gasLimit,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmCREATE(bytes)", "ovmCREATE(bytes)",
...@@ -109,12 +100,10 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -109,12 +100,10 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs an ovmEXTCODESIZE and the necessary safety checks. * Performs an ovmEXTCODESIZE and the necessary safety checks.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @param _contract Address of the contract to query the size of. * @param _contract Address of the contract to query the size of.
* @return _EXTCODESIZE Size of the requested contract in bytes. * @return _EXTCODESIZE Size of the requested contract in bytes.
*/ */
function safeEXTCODESIZE( function safeEXTCODESIZE(
address _ovmExecutionManager,
address _contract address _contract
) )
internal internal
...@@ -123,7 +112,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -123,7 +112,6 @@ library Lib_SafeExecutionManagerWrapper {
) )
{ {
bytes memory returndata = _safeExecutionManagerInteraction( bytes memory returndata = _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmEXTCODESIZE(address)", "ovmEXTCODESIZE(address)",
_contract _contract
...@@ -135,19 +123,15 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -135,19 +123,15 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs a safe ovmCHAINID call. * Performs a safe ovmCHAINID call.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @return _CHAINID Result of calling ovmCHAINID. * @return _CHAINID Result of calling ovmCHAINID.
*/ */
function safeCHAINID( function safeCHAINID()
address _ovmExecutionManager
)
internal internal
returns ( returns (
uint256 _CHAINID uint256 _CHAINID
) )
{ {
bytes memory returndata = _safeExecutionManagerInteraction( bytes memory returndata = _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmCHAINID()" "ovmCHAINID()"
) )
...@@ -158,19 +142,15 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -158,19 +142,15 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs a safe ovmCALLER call. * Performs a safe ovmCALLER call.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @return _CALLER Result of calling ovmCALLER. * @return _CALLER Result of calling ovmCALLER.
*/ */
function safeCALLER( function safeCALLER()
address _ovmExecutionManager
)
internal internal
returns ( returns (
address _CALLER address _CALLER
) )
{ {
bytes memory returndata = _safeExecutionManagerInteraction( bytes memory returndata = _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmCALLER()" "ovmCALLER()"
) )
...@@ -181,19 +161,15 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -181,19 +161,15 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs a safe ovmADDRESS call. * Performs a safe ovmADDRESS call.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @return _ADDRESS Result of calling ovmADDRESS. * @return _ADDRESS Result of calling ovmADDRESS.
*/ */
function safeADDRESS( function safeADDRESS()
address _ovmExecutionManager
)
internal internal
returns ( returns (
address _ADDRESS address _ADDRESS
) )
{ {
bytes memory returndata = _safeExecutionManagerInteraction( bytes memory returndata = _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmADDRESS()" "ovmADDRESS()"
) )
...@@ -204,19 +180,15 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -204,19 +180,15 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs a safe ovmGETNONCE call. * Performs a safe ovmGETNONCE call.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @return _nonce Result of calling ovmGETNONCE. * @return _nonce Result of calling ovmGETNONCE.
*/ */
function safeGETNONCE( function safeGETNONCE()
address _ovmExecutionManager
)
internal internal
returns ( returns (
uint256 _nonce uint256 _nonce
) )
{ {
bytes memory returndata = _safeExecutionManagerInteraction( bytes memory returndata = _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmGETNONCE()" "ovmGETNONCE()"
) )
...@@ -227,17 +199,14 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -227,17 +199,14 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs a safe ovmSETNONCE call. * Performs a safe ovmSETNONCE call.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @param _nonce New account nonce. * @param _nonce New account nonce.
*/ */
function safeSETNONCE( function safeSETNONCE(
address _ovmExecutionManager,
uint256 _nonce uint256 _nonce
) )
internal internal
{ {
_safeExecutionManagerInteraction( _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmSETNONCE(uint256)", "ovmSETNONCE(uint256)",
_nonce _nonce
...@@ -247,14 +216,12 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -247,14 +216,12 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs a safe ovmCREATEEOA call. * Performs a safe ovmCREATEEOA call.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @param _messageHash Message hash which was signed by EOA * @param _messageHash Message hash which was signed by EOA
* @param _v v value of signature (0 or 1) * @param _v v value of signature (0 or 1)
* @param _r r value of signature * @param _r r value of signature
* @param _s s value of signature * @param _s s value of signature
*/ */
function safeCREATEEOA( function safeCREATEEOA(
address _ovmExecutionManager,
bytes32 _messageHash, bytes32 _messageHash,
uint8 _v, uint8 _v,
bytes32 _r, bytes32 _r,
...@@ -263,7 +230,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -263,7 +230,6 @@ library Lib_SafeExecutionManagerWrapper {
internal internal
{ {
_safeExecutionManagerInteraction( _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmCREATEEOA(bytes32,uint8,bytes32,bytes32)", "ovmCREATEEOA(bytes32,uint8,bytes32,bytes32)",
_messageHash, _messageHash,
...@@ -276,17 +242,14 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -276,17 +242,14 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs a safe REVERT. * Performs a safe REVERT.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @param _reason String revert reason to pass along with the REVERT. * @param _reason String revert reason to pass along with the REVERT.
*/ */
function safeREVERT( function safeREVERT(
address _ovmExecutionManager,
string memory _reason string memory _reason
) )
internal internal
{ {
_safeExecutionManagerInteraction( _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmREVERT(bytes)", "ovmREVERT(bytes)",
bytes(_reason) bytes(_reason)
...@@ -296,12 +259,10 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -296,12 +259,10 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs a safe "require". * Performs a safe "require".
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @param _condition Boolean condition that must be true or will revert. * @param _condition Boolean condition that must be true or will revert.
* @param _reason String revert reason to pass along with the REVERT. * @param _reason String revert reason to pass along with the REVERT.
*/ */
function safeREQUIRE( function safeREQUIRE(
address _ovmExecutionManager,
bool _condition, bool _condition,
string memory _reason string memory _reason
) )
...@@ -309,7 +270,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -309,7 +270,6 @@ library Lib_SafeExecutionManagerWrapper {
{ {
if (!_condition) { if (!_condition) {
safeREVERT( safeREVERT(
_ovmExecutionManager,
_reason _reason
); );
} }
...@@ -319,7 +279,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -319,7 +279,6 @@ library Lib_SafeExecutionManagerWrapper {
* Performs a safe ovmSLOAD call. * Performs a safe ovmSLOAD call.
*/ */
function safeSLOAD( function safeSLOAD(
address _ovmExecutionManager,
bytes32 _key bytes32 _key
) )
internal internal
...@@ -328,7 +287,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -328,7 +287,6 @@ library Lib_SafeExecutionManagerWrapper {
) )
{ {
bytes memory returndata = _safeExecutionManagerInteraction( bytes memory returndata = _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmSLOAD(bytes32)", "ovmSLOAD(bytes32)",
_key _key
...@@ -342,14 +300,12 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -342,14 +300,12 @@ library Lib_SafeExecutionManagerWrapper {
* Performs a safe ovmSSTORE call. * Performs a safe ovmSSTORE call.
*/ */
function safeSSTORE( function safeSSTORE(
address _ovmExecutionManager,
bytes32 _key, bytes32 _key,
bytes32 _value bytes32 _value
) )
internal internal
{ {
_safeExecutionManagerInteraction( _safeExecutionManagerInteraction(
_ovmExecutionManager,
abi.encodeWithSignature( abi.encodeWithSignature(
"ovmSSTORE(bytes32,bytes32)", "ovmSSTORE(bytes32,bytes32)",
_key, _key,
...@@ -364,13 +320,11 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -364,13 +320,11 @@ library Lib_SafeExecutionManagerWrapper {
/** /**
* Performs an ovm interaction and the necessary safety checks. * Performs an ovm interaction and the necessary safety checks.
* @param _ovmExecutionManager Address of the OVM_ExecutionManager.
* @param _gasLimit Gas limit for the interaction. * @param _gasLimit Gas limit for the interaction.
* @param _calldata Data to send to the OVM_ExecutionManager (encoded with sighash). * @param _calldata Data to send to the OVM_ExecutionManager (encoded with sighash).
* @return _returndata Data sent back by the OVM_ExecutionManager. * @return _returndata Data sent back by the OVM_ExecutionManager.
*/ */
function _safeExecutionManagerInteraction( function _safeExecutionManagerInteraction(
address _ovmExecutionManager,
uint256 _gasLimit, uint256 _gasLimit,
bytes memory _calldata bytes memory _calldata
) )
...@@ -379,10 +333,11 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -379,10 +333,11 @@ library Lib_SafeExecutionManagerWrapper {
bytes memory _returndata bytes memory _returndata
) )
{ {
address ovmExecutionManager = msg.sender;
( (
bool success, bool success,
bytes memory returndata bytes memory returndata
) = _ovmExecutionManager.call{gas: _gasLimit}(_calldata); ) = ovmExecutionManager.call{gas: _gasLimit}(_calldata);
if (success == false) { if (success == false) {
assembly { assembly {
...@@ -398,7 +353,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -398,7 +353,6 @@ library Lib_SafeExecutionManagerWrapper {
} }
function _safeExecutionManagerInteraction( function _safeExecutionManagerInteraction(
address _ovmExecutionManager,
bytes memory _calldata bytes memory _calldata
) )
private private
...@@ -407,7 +361,6 @@ library Lib_SafeExecutionManagerWrapper { ...@@ -407,7 +361,6 @@ library Lib_SafeExecutionManagerWrapper {
) )
{ {
return _safeExecutionManagerInteraction( return _safeExecutionManagerInteraction(
_ovmExecutionManager,
gasleft(), gasleft(),
_calldata _calldata
); );
......
...@@ -43,21 +43,18 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { ...@@ -43,21 +43,18 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
bytes memory _returndata bytes memory _returndata
) )
{ {
address ovmExecutionManager = msg.sender;
bool isEthSign = _signatureType == Lib_OVMCodec.EOASignatureType.ETH_SIGNED_MESSAGE; bool isEthSign = _signatureType == Lib_OVMCodec.EOASignatureType.ETH_SIGNED_MESSAGE;
Lib_OVMCodec.EIP155Transaction memory decodedTx = Lib_OVMCodec.decodeEIP155Transaction(_transaction, isEthSign); Lib_OVMCodec.EIP155Transaction memory decodedTx = Lib_OVMCodec.decodeEIP155Transaction(_transaction, isEthSign);
// Need to make sure that the transaction nonce is right. // Need to make sure that the transaction nonce is right.
Lib_SafeExecutionManagerWrapper.safeREQUIRE( Lib_SafeExecutionManagerWrapper.safeREQUIRE(
msg.sender, decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(),
decodedTx.nonce == Lib_SafeExecutionManagerWrapper.safeGETNONCE(ovmExecutionManager),
"Transaction nonce does not match the expected nonce." "Transaction nonce does not match the expected nonce."
); );
// Contract creations are signalled by sending a transaction to the zero address. // Contract creations are signalled by sending a transaction to the zero address.
if (decodedTx.to == address(0)) { if (decodedTx.to == address(0)) {
address created = Lib_SafeExecutionManagerWrapper.safeCREATE( address created = Lib_SafeExecutionManagerWrapper.safeCREATE(
ovmExecutionManager,
decodedTx.gasLimit, decodedTx.gasLimit,
decodedTx.data decodedTx.data
); );
...@@ -68,10 +65,9 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { ...@@ -68,10 +65,9 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// We only want to bump the nonce for `ovmCALL` because `ovmCREATE` automatically bumps // We only want to bump the nonce for `ovmCALL` because `ovmCREATE` automatically bumps
// the nonce of the calling account. Normally an EOA would bump the nonce for both // the nonce of the calling account. Normally an EOA would bump the nonce for both
// cases, but since this is a contract we'd end up bumping the nonce twice. // cases, but since this is a contract we'd end up bumping the nonce twice.
Lib_SafeExecutionManagerWrapper.safeSETNONCE(ovmExecutionManager, decodedTx.nonce + 1); Lib_SafeExecutionManagerWrapper.safeSETNONCE(decodedTx.nonce + 1);
return Lib_SafeExecutionManagerWrapper.safeCALL( return Lib_SafeExecutionManagerWrapper.safeCALL(
ovmExecutionManager,
decodedTx.gasLimit, decodedTx.gasLimit,
decodedTx.to, decodedTx.to,
decodedTx.data decodedTx.data
...@@ -91,7 +87,6 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { ...@@ -91,7 +87,6 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
) )
{ {
return Lib_SafeExecutionManagerWrapper.safeCALL( return Lib_SafeExecutionManagerWrapper.safeCALL(
msg.sender,
_gasLimit, _gasLimit,
_to, _to,
_data _data
......
...@@ -65,7 +65,7 @@ const test_ovmCREATEEOA: TestDefinition = { ...@@ -65,7 +65,7 @@ const test_ovmCREATEEOA: TestDefinition = {
address: '0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff', address: '0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff',
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: 1638, expectedReturnValue: 1619,
}, },
], ],
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment