-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* decompression (not working) * start EIP155 serialization * working decompressor * working CreateEOA, working native EIP155tx * all three tx types working * remove only * fix ECDSAUtil tests * restore original version of smock * add proxys * clean up tests * clean up decompressor tests * clean up ProxyDecompressor * clean up decompressor tests * add CREATEEOA, SETNONCE, GETNONCE tests * working ECDSAContractAccount * fix decompressor * renaming, add deploy * add proxyeoa test, cleanup * remove createEOA type, add extcodesize check * fix decompressor test * support create txs * Decompressor -> Entrypoint * use safeREVERT instead of requires * add isAuthenticated state manager test * update smock * fix sequencerEntrypoint test * add isAuthenticated * Revert "update smock" This reverts commit 286a222414accf9387dcd12ecbed0a66be586bc8. * fix test * Updates to EM * removed kall from contract account * Fixed SSLOAD and SSTORE problems * Fix some broken tests * Fix more bugs & rename to ProxyEOA * WIP fix call test * fix all tests * add gas check * update tests * lint and remove 2000 gas check * Add fees to default EOA (#56) Co-authored-by: Kelvin Fichter <[email protected]> Co-authored-by: Karl Floersch <[email protected]>
- Loading branch information
1 parent
21b3e5a
commit f06c865
Showing
33 changed files
with
1,991 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
packages/contracts/contracts/optimistic-ethereum/OVM/accounts/OVM_ProxyEOA.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
pragma solidity ^0.7.0; | ||
|
||
/* Library Imports */ | ||
import { Lib_BytesUtils } from "../../libraries/utils/Lib_BytesUtils.sol"; | ||
import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; | ||
import { Lib_ECDSAUtils } from "../../libraries/utils/Lib_ECDSAUtils.sol"; | ||
import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; | ||
|
||
/** | ||
* @title OVM_ProxyEOA | ||
*/ | ||
contract OVM_ProxyEOA { | ||
|
||
/*************** | ||
* Constructor * | ||
***************/ | ||
|
||
constructor( | ||
address _implementation | ||
) { | ||
_setImplementation(_implementation); | ||
} | ||
|
||
|
||
/********************* | ||
* Fallback Function * | ||
*********************/ | ||
|
||
fallback() | ||
external | ||
{ | ||
(bool success, bytes memory returndata) = Lib_SafeExecutionManagerWrapper.safeDELEGATECALL( | ||
msg.sender, | ||
gasleft(), | ||
getImplementation(), | ||
msg.data | ||
); | ||
|
||
if (success) { | ||
assembly { | ||
return(add(returndata, 0x20), mload(returndata)) | ||
} | ||
} else { | ||
Lib_SafeExecutionManagerWrapper.safeREVERT( | ||
msg.sender, | ||
string(returndata) | ||
); | ||
} | ||
} | ||
|
||
|
||
/******************** | ||
* Public Functions * | ||
********************/ | ||
|
||
function upgrade( | ||
address _implementation | ||
) | ||
external | ||
{ | ||
Lib_SafeExecutionManagerWrapper.safeREQUIRE( | ||
msg.sender, | ||
Lib_SafeExecutionManagerWrapper.safeADDRESS(msg.sender) == Lib_SafeExecutionManagerWrapper.safeCALLER(msg.sender), | ||
"EOAs can only upgrade their own EOA implementation" | ||
); | ||
|
||
_setImplementation(_implementation); | ||
} | ||
|
||
function getImplementation() | ||
public | ||
returns ( | ||
address _implementation | ||
) | ||
{ | ||
return address(uint160(uint256( | ||
Lib_SafeExecutionManagerWrapper.safeSLOAD( | ||
msg.sender, | ||
bytes32(uint256(0)) | ||
) | ||
))); | ||
} | ||
|
||
/********************** | ||
* Internal Functions * | ||
**********************/ | ||
|
||
function _setImplementation( | ||
address _implementation | ||
) | ||
internal | ||
{ | ||
Lib_SafeExecutionManagerWrapper.safeSSTORE( | ||
msg.sender, | ||
bytes32(uint256(0)), | ||
bytes32(uint256(uint160(_implementation))) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
.../contracts/contracts/optimistic-ethereum/OVM/precompiles/OVM_ProxySequencerEntrypoint.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
pragma solidity ^0.7.0; | ||
|
||
/* Library Imports */ | ||
import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; | ||
|
||
/** | ||
* @title OVM_ProxySequencerEntrypoint | ||
*/ | ||
contract OVM_ProxySequencerEntrypoint { | ||
|
||
/********************* | ||
* Fallback Function * | ||
*********************/ | ||
|
||
fallback() | ||
external | ||
{ | ||
Lib_SafeExecutionManagerWrapper.safeDELEGATECALL( | ||
msg.sender, | ||
gasleft(), | ||
_getImplementation(), | ||
msg.data | ||
); | ||
} | ||
|
||
|
||
/******************** | ||
* Public Functions * | ||
********************/ | ||
|
||
function init( | ||
address _implementation, | ||
address _owner | ||
) | ||
external | ||
{ | ||
Lib_SafeExecutionManagerWrapper.safeREQUIRE( | ||
msg.sender, | ||
_getOwner() == address(0), | ||
"ProxySequencerEntrypoint has already been inited" | ||
); | ||
_setOwner(_owner); | ||
_setImplementation(_implementation); | ||
} | ||
|
||
function upgrade( | ||
address _implementation | ||
) | ||
external | ||
{ | ||
Lib_SafeExecutionManagerWrapper.safeREQUIRE( | ||
msg.sender, | ||
_getOwner() == Lib_SafeExecutionManagerWrapper.safeCALLER(msg.sender), | ||
"Only owner can upgrade the Entrypoint" | ||
); | ||
|
||
_setImplementation(_implementation); | ||
} | ||
|
||
|
||
/********************** | ||
* Internal Functions * | ||
**********************/ | ||
|
||
function _setImplementation( | ||
address _implementation | ||
) | ||
internal | ||
{ | ||
Lib_SafeExecutionManagerWrapper.safeSSTORE( | ||
msg.sender, | ||
bytes32(uint256(0)), | ||
bytes32(uint256(uint160(_implementation))) | ||
); | ||
} | ||
|
||
function _getImplementation() | ||
internal | ||
returns ( | ||
address _implementation | ||
) | ||
{ | ||
return address(uint160(uint256( | ||
Lib_SafeExecutionManagerWrapper.safeSLOAD( | ||
msg.sender, | ||
bytes32(uint256(0)) | ||
) | ||
))); | ||
} | ||
|
||
function _setOwner( | ||
address _owner | ||
) | ||
internal | ||
{ | ||
Lib_SafeExecutionManagerWrapper.safeSSTORE( | ||
msg.sender, | ||
bytes32(uint256(1)), | ||
bytes32(uint256(uint160(_owner))) | ||
); | ||
} | ||
|
||
function _getOwner() | ||
internal | ||
returns ( | ||
address _owner | ||
) | ||
{ | ||
return address(uint160(uint256( | ||
Lib_SafeExecutionManagerWrapper.safeSLOAD( | ||
msg.sender, | ||
bytes32(uint256(1)) | ||
) | ||
))); | ||
} | ||
} |
Oops, something went wrong.