-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Import changes from deprecated contracts repo #476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
98097a5
220b80e
af9f9a6
d071f0f
1e3276d
3855dcd
93f81c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@eth-optimism/contracts": minor | ||
| --- | ||
|
|
||
| - Reduce nonce size to uint64 | ||
| - Ban ovmCALLER opcode when it would return ZERO | ||
| - Add value transfer in OVM_ECDSAContractAccount | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,13 +101,10 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { | |
| // Transfer fee to relayer. | ||
| address relayer = Lib_SafeExecutionManagerWrapper.safeCALLER(); | ||
| uint256 fee = Lib_SafeMathWrapper.mul(decodedTx.gasLimit, decodedTx.gasPrice); | ||
| (bool success, ) = Lib_SafeExecutionManagerWrapper.safeCALL( | ||
| gasleft(), | ||
| ETH_ERC20_ADDRESS, | ||
| abi.encodeWithSignature("transfer(address,uint256)", relayer, fee) | ||
| ); | ||
| Lib_SafeExecutionManagerWrapper.safeREQUIRE( | ||
| success == true, | ||
| _attemptETHTransfer( | ||
| relayer, fee | ||
| ), | ||
| "Fee was not transferred to relayer." | ||
| ); | ||
|
|
||
|
|
@@ -130,11 +127,50 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount { | |
| // cases, but since this is a contract we'd end up bumping the nonce twice. | ||
| Lib_SafeExecutionManagerWrapper.safeINCREMENTNONCE(); | ||
|
|
||
| return Lib_SafeExecutionManagerWrapper.safeCALL( | ||
| gasleft(), | ||
| decodedTx.to, | ||
| decodedTx.data | ||
| ); | ||
| if (decodedTx.value > 0) { | ||
| Lib_SafeExecutionManagerWrapper.safeREQUIRE( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? Was it the case before, was it a bug? Also, it seems like integration tests are failing, did you run them locally? |
||
| decodedTx.data.length == 0, | ||
| "Sending ETH with data is currently unsupported." | ||
| ); | ||
|
|
||
| return ( | ||
| _attemptETHTransfer(decodedTx.to, decodedTx.value), | ||
| bytes('') | ||
| ); | ||
| } else { | ||
| return Lib_SafeExecutionManagerWrapper.safeCALL( | ||
| gasleft(), | ||
| decodedTx.to, | ||
| decodedTx.data | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Attempts to tansfer OVM_ETH. | ||
| * @param _to Address to send the L2 ETH to. | ||
| * @param _value Amount of L2 ETH to send. | ||
| * @return Whether the transfer was successful. | ||
| */ | ||
| function _attemptETHTransfer( | ||
| address _to, | ||
| uint256 _value | ||
| ) | ||
| internal | ||
| returns( | ||
| bool | ||
| ) | ||
| { | ||
| (bool success, ) = Lib_SafeExecutionManagerWrapper.safeCALL( | ||
| gasleft(), | ||
| ETH_ERC20_ADDRESS, | ||
| abi.encodeWithSignature( | ||
| "transfer(address,uint256)", | ||
| _to, | ||
| _value | ||
| ) | ||
| ); | ||
| return success; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -460,7 +460,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { | |
| override | ||
| public | ||
| returns ( | ||
| uint256 _nonce | ||
| uint64 _nonce | ||
| ) | ||
| { | ||
| return _getAccountNonce(ovmADDRESS()); | ||
|
|
@@ -475,7 +475,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { | |
| notStatic | ||
| { | ||
| address account = ovmADDRESS(); | ||
| uint256 nonce = _getAccountNonce(account); | ||
| uint64 nonce = _getAccountNonce(account); | ||
|
|
||
| // Prevent overflow. | ||
| if (nonce + 1 > nonce) { | ||
|
|
@@ -1050,15 +1050,15 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { | |
| * This function sanitizes the return types for creation messages to match calls (bool, bytes), | ||
| * by being an external function which the EM can call, that mimics the success/fail case of the CREATE. | ||
| * This allows for consistent handling of both types of messages in _handleExternalMessage(). | ||
| * Having this step occur as a separate call frame also allows us to easily revert the | ||
| * Having this step occur as a separate call frame also allows us to easily revert the | ||
| * contract deployment in the event that the code is unsafe. | ||
| * | ||
| * @param _gasLimit Amount of gas to be passed into this creation. | ||
| * | ||
| * param _gasLimit Amount of gas to be passed into this creation. | ||
| * @param _creationCode Code to pass into CREATE for deployment. | ||
| * @param _address OVM address being deployed to. | ||
| */ | ||
| function safeCREATE( | ||
| uint _gasLimit, | ||
| uint, // _gasLimit | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, I think this was me, but I think Kelvin would want to remove this param internally to be more consistent with the EVM, so cc @smartcontracts |
||
| bytes memory _creationCode, | ||
| address _address | ||
| ) | ||
|
|
@@ -1097,7 +1097,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { | |
| if (ethAddress == address(0)) { | ||
| // If the creation fails, the EVM lets us grab its revert data. This may contain a revert flag | ||
| // to be used above in _handleExternalMessage, so we pass the revert data back up unmodified. | ||
| assembly { | ||
| assembly { | ||
| returndatacopy(0,0,returndatasize()) | ||
| revert(0, returndatasize()) | ||
| } | ||
|
|
@@ -1167,7 +1167,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { | |
| */ | ||
| function _setAccountNonce( | ||
| address _address, | ||
| uint256 _nonce | ||
| uint64 _nonce | ||
| ) | ||
| internal | ||
| { | ||
|
|
@@ -1185,7 +1185,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { | |
| ) | ||
| internal | ||
| returns ( | ||
| uint256 _nonce | ||
| uint64 _nonce | ||
| ) | ||
| { | ||
| _checkAccountLoad(_address); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -425,6 +425,28 @@ library Lib_RLPReader { | |
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Reads an RLP Uint64 value into a uint64. | ||
| * @param _in RLP uint64 value. | ||
| * @return Decoded uint64. | ||
| */ | ||
| function readUint64( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this used anywhere? |
||
| RLPItem memory _in | ||
| ) | ||
| internal | ||
| pure | ||
| returns ( | ||
| uint64 | ||
| ) | ||
| { | ||
| require( | ||
| _in.length <= 9, | ||
| "Invalid RLP uint64 value." | ||
| ); | ||
|
|
||
| return uint64(readUint256(_in)); | ||
| } | ||
|
|
||
| /** | ||
| * Reads the raw bytes of an RLP item. | ||
| * @param _in RLP item to read. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -744,6 +744,24 @@ const test_ovmCREATE: TestDefinition = { | |
| }, | ||
| ], | ||
| }, | ||
| { | ||
| name: 'ovmCREATE(UNSAFE_CODE)', | ||
| steps: [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was already the case right? This test does not seem to be accompanied by any extra code in the safety checker. |
||
| { | ||
| functionName: 'ovmCREATE', | ||
| functionParams: { | ||
| bytecode: UNSAFE_BYTECODE, | ||
| }, | ||
| expectedReturnStatus: true, | ||
| expectedReturnValue: { | ||
| address: constants.AddressZero, | ||
| revertData: encodeSolidityError( | ||
| 'Constructor attempted to deploy unsafe bytecode.' | ||
| ), | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| subTests: [ | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.