Commit d824abcc authored by ben-chain's avatar ben-chain Committed by GitHub

simplify logic, fix tests (#78)

parent 0c3c6501
...@@ -861,8 +861,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -861,8 +861,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
"safeCREATE(address,bytes)", "safeCREATE(address,bytes)",
_contractAddress, _contractAddress,
_bytecode _bytecode
), )
false
); );
// Need to make sure that this flag is reset so that it isn't propagated to creations in // Need to make sure that this flag is reset so that it isn't propagated to creations in
...@@ -906,8 +905,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -906,8 +905,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
_nextMessageContext, _nextMessageContext,
_gasLimit, _gasLimit,
codeContractAddress, codeContractAddress,
_calldata, _calldata
_isStaticEntrypoint
); );
} }
...@@ -917,7 +915,6 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -917,7 +915,6 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
* @param _gasLimit Amount of gas to be passed into this call. * @param _gasLimit Amount of gas to be passed into this call.
* @param _target Address of the contract to call. * @param _target Address of the contract to call.
* @param _data Data to send along with the call. * @param _data Data to send along with the call.
* @param _isStaticEntrypoint Whether or not this is coming from ovmSTATICCALL.
* @return _success Whether or not the call returned (rather than reverted). * @return _success Whether or not the call returned (rather than reverted).
* @return _returndata Data returned by the call. * @return _returndata Data returned by the call.
*/ */
...@@ -925,8 +922,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -925,8 +922,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
MessageContext memory _nextMessageContext, MessageContext memory _nextMessageContext,
uint256 _gasLimit, uint256 _gasLimit,
address _target, address _target,
bytes memory _data, bytes memory _data
bool _isStaticEntrypoint
) )
internal internal
returns ( returns (
...@@ -977,21 +973,13 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver { ...@@ -977,21 +973,13 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
_revertWithFlag(flag); _revertWithFlag(flag);
} }
// STATIC_VIOLATION should be passed all the way back up to the previous ovmSTATICCALL // INTENTIONAL_REVERT, UNSAFE_BYTECODE, and STATIC_VIOLATION aren't dependent on the
// in the call stack. // input state, so we can just handle them like standard reverts. Our only change here
if ( // is to record the gas refund reported by the call (enforced by safety checking).
flag == RevertFlag.STATIC_VIOLATION
&& _isStaticEntrypoint == false
) {
_revertWithFlag(flag);
}
// INTENTIONAL_REVERT and UNSAFE_BYTECODE aren't dependent on the input state, so we
// can just handle them like standard reverts. Our only change here is to record the
// gas refund reported by the call (enforced by safety checking).
if ( if (
flag == RevertFlag.INTENTIONAL_REVERT flag == RevertFlag.INTENTIONAL_REVERT
|| flag == RevertFlag.UNSAFE_BYTECODE || flag == RevertFlag.UNSAFE_BYTECODE
|| flag == RevertFlag.STATIC_VIOLATION
) { ) {
transactionRecord.ovmGasRefund = ovmGasRefund; transactionRecord.ovmGasRefund = ovmGasRefund;
} }
......
...@@ -226,14 +226,10 @@ const test_ovmSTATICCALL: TestDefinition = { ...@@ -226,14 +226,10 @@ const test_ovmSTATICCALL: TestDefinition = {
], ],
}, },
expectedReturnStatus: false, expectedReturnStatus: false,
expectedReturnValue: {
flag: REVERT_FLAGS.STATIC_VIOLATION,
nuisanceGasLeft: OVM_TX_GAS_LIMIT / 2,
},
}, },
], ],
}, },
expectedReturnStatus: false, expectedReturnStatus: true,
}, },
], ],
}, },
...@@ -321,14 +317,10 @@ const test_ovmSTATICCALL: TestDefinition = { ...@@ -321,14 +317,10 @@ const test_ovmSTATICCALL: TestDefinition = {
], ],
}, },
expectedReturnStatus: false, expectedReturnStatus: false,
expectedReturnValue: {
flag: REVERT_FLAGS.STATIC_VIOLATION,
nuisanceGasLeft: OVM_TX_GAS_LIMIT / 2,
},
}, },
], ],
}, },
expectedReturnStatus: false, expectedReturnStatus: true,
}, },
], ],
}, },
......
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