Merge pull request #2228 from 0xProject/fix/3.0/refundFinalBalanceNoReentry

refundFinalBalanceNoReentry
This commit is contained in:
mzhu25 2019-10-06 13:39:04 -07:00 committed by GitHub
commit ee508f70bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 31 deletions

View File

@ -61,8 +61,7 @@ contract MixinExchangeCore is
function cancelOrdersUpTo(uint256 targetOrderEpoch)
external
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
{
address makerAddress = _getCurrentContextAddress();
// If this function is called via `executeTransaction`, we only update the orderEpoch for the makerAddress/msg.sender combination.
@ -103,8 +102,7 @@ contract MixinExchangeCore is
)
public
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
returns (LibFillResults.FillResults memory fillResults)
{
fillResults = _fillOrder(
@ -120,8 +118,7 @@ contract MixinExchangeCore is
function cancelOrder(LibOrder.Order memory order)
public
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
{
_cancelOrder(order);
}

View File

@ -51,8 +51,7 @@ contract MixinMatchOrders is
)
public
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
returns (LibFillResults.BatchMatchedFillResults memory batchMatchedFillResults)
{
return _batchMatchOrders(
@ -81,8 +80,7 @@ contract MixinMatchOrders is
)
public
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
returns (LibFillResults.BatchMatchedFillResults memory batchMatchedFillResults)
{
return _batchMatchOrders(
@ -111,8 +109,7 @@ contract MixinMatchOrders is
)
public
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
{
return _matchOrders(
@ -141,8 +138,7 @@ contract MixinMatchOrders is
)
public
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
{
return _matchOrders(

View File

@ -22,7 +22,6 @@ pragma experimental ABIEncoderV2;
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/LibEIP1271.sol";
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
@ -35,7 +34,6 @@ import "./MixinTransactions.sol";
contract MixinSignatureValidator is
ReentrancyGuard,
LibEIP712ExchangeDomain,
LibEIP1271,
ISignatureValidator,
@ -61,8 +59,7 @@ contract MixinSignatureValidator is
function preSign(bytes32 hash)
external
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
{
address signerAddress = _getCurrentContextAddress();
preSigned[hash][signerAddress] = true;
@ -78,8 +75,7 @@ contract MixinSignatureValidator is
)
external
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
{
address signerAddress = _getCurrentContextAddress();
allowedValidators[signerAddress][validatorAddress] = approval;

View File

@ -47,8 +47,7 @@ contract MixinWrapperFunctions is
)
public
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
returns (LibFillResults.FillResults memory fillResults)
{
fillResults = _fillOrKillOrder(
@ -71,8 +70,7 @@ contract MixinWrapperFunctions is
)
public
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
returns (LibFillResults.FillResults[] memory fillResults)
{
uint256 ordersLength = orders.length;
@ -99,8 +97,7 @@ contract MixinWrapperFunctions is
)
public
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
returns (LibFillResults.FillResults[] memory fillResults)
{
uint256 ordersLength = orders.length;
@ -287,8 +284,7 @@ contract MixinWrapperFunctions is
function batchCancelOrders(LibOrder.Order[] memory orders)
public
payable
nonReentrant
refundFinalBalance
refundFinalBalanceNoReentry
{
uint256 ordersLength = orders.length;
for (uint256 i = 0; i != ordersLength; i++) {

View File

@ -18,8 +18,12 @@
pragma solidity ^0.5.9;
import "./ReentrancyGuard.sol";
contract Refundable {
contract Refundable is
ReentrancyGuard
{
// This bool is used by the refund modifier to allow for lazily evaluated refunds.
bool internal _shouldNotRefund;
@ -29,6 +33,13 @@ contract Refundable {
_refundNonZeroBalanceIfEnabled();
}
modifier refundFinalBalanceNoReentry {
_lockMutexOrThrowIfAlreadyLocked();
_;
_refundNonZeroBalanceIfEnabled();
_unlockMutex();
}
modifier disableRefundUntilEnd {
if (_areRefundsDisabled()) {
_;