Add nonReentrant modifiers on functions that use getCurrentContextAddress only, add lockMutex modifier on functions that make external calls
This commit is contained in:
parent
6d0dedc62c
commit
c75212bef0
@ -56,6 +56,7 @@ contract MixinExchangeCore is
|
|||||||
/// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled.
|
/// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled.
|
||||||
function cancelOrdersUpTo(uint256 targetOrderEpoch)
|
function cancelOrdersUpTo(uint256 targetOrderEpoch)
|
||||||
external
|
external
|
||||||
|
nonReentrant
|
||||||
{
|
{
|
||||||
address makerAddress = getCurrentContextAddress();
|
address makerAddress = getCurrentContextAddress();
|
||||||
// If this function is called via `executeTransaction`, we only update the orderEpoch for the makerAddress/msg.sender combination.
|
// If this function is called via `executeTransaction`, we only update the orderEpoch for the makerAddress/msg.sender combination.
|
||||||
@ -88,7 +89,7 @@ contract MixinExchangeCore is
|
|||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
nonReentrant
|
lockMutex
|
||||||
returns (FillResults memory fillResults)
|
returns (FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
fillResults = fillOrderInternal(
|
fillResults = fillOrderInternal(
|
||||||
@ -104,6 +105,7 @@ contract MixinExchangeCore is
|
|||||||
/// @param order Order to cancel. Order must be OrderStatus.FILLABLE.
|
/// @param order Order to cancel. Order must be OrderStatus.FILLABLE.
|
||||||
function cancelOrder(Order memory order)
|
function cancelOrder(Order memory order)
|
||||||
public
|
public
|
||||||
|
nonReentrant
|
||||||
{
|
{
|
||||||
// Fetch current order status
|
// Fetch current order status
|
||||||
OrderInfo memory orderInfo = getOrderInfo(order);
|
OrderInfo memory orderInfo = getOrderInfo(order);
|
||||||
|
@ -50,7 +50,7 @@ contract MixinMatchOrders is
|
|||||||
bytes memory rightSignature
|
bytes memory rightSignature
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
nonReentrant
|
lockMutex
|
||||||
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
|
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
|
||||||
{
|
{
|
||||||
// We assume that rightOrder.takerAssetData == leftOrder.makerAssetData and rightOrder.makerAssetData == leftOrder.takerAssetData.
|
// We assume that rightOrder.takerAssetData == leftOrder.makerAssetData and rightOrder.makerAssetData == leftOrder.takerAssetData.
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
pragma solidity 0.4.24;
|
pragma solidity 0.4.24;
|
||||||
|
|
||||||
import "../../utils/LibBytes/LibBytes.sol";
|
import "../../utils/LibBytes/LibBytes.sol";
|
||||||
|
import "../../utils/ReentrancyGuard/ReentrancyGuard.sol";
|
||||||
import "./mixins/MSignatureValidator.sol";
|
import "./mixins/MSignatureValidator.sol";
|
||||||
import "./mixins/MTransactions.sol";
|
import "./mixins/MTransactions.sol";
|
||||||
import "./interfaces/IWallet.sol";
|
import "./interfaces/IWallet.sol";
|
||||||
@ -26,6 +27,7 @@ import "./interfaces/IValidator.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract MixinSignatureValidator is
|
contract MixinSignatureValidator is
|
||||||
|
ReentrancyGuard,
|
||||||
MSignatureValidator,
|
MSignatureValidator,
|
||||||
MTransactions
|
MTransactions
|
||||||
{
|
{
|
||||||
@ -69,6 +71,7 @@ contract MixinSignatureValidator is
|
|||||||
bool approval
|
bool approval
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
|
nonReentrant
|
||||||
{
|
{
|
||||||
address signerAddress = getCurrentContextAddress();
|
address signerAddress = getCurrentContextAddress();
|
||||||
allowedValidators[signerAddress][validatorAddress] = approval;
|
allowedValidators[signerAddress][validatorAddress] = approval;
|
||||||
|
@ -46,7 +46,7 @@ contract MixinWrapperFunctions is
|
|||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
nonReentrant
|
lockMutex
|
||||||
returns (FillResults memory fillResults)
|
returns (FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
fillResults = fillOrKillOrderInternal(
|
fillResults = fillOrKillOrderInternal(
|
||||||
@ -69,6 +69,7 @@ contract MixinWrapperFunctions is
|
|||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
|
nonReentrant
|
||||||
returns (FillResults memory fillResults)
|
returns (FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
// ABI encode calldata for `fillOrder`
|
// ABI encode calldata for `fillOrder`
|
||||||
@ -88,14 +89,7 @@ contract MixinWrapperFunctions is
|
|||||||
fillOrderCalldata, // write output over input
|
fillOrderCalldata, // write output over input
|
||||||
128 // output size is 128 bytes
|
128 // output size is 128 bytes
|
||||||
)
|
)
|
||||||
switch success
|
if success {
|
||||||
case 0 {
|
|
||||||
mstore(fillResults, 0)
|
|
||||||
mstore(add(fillResults, 32), 0)
|
|
||||||
mstore(add(fillResults, 64), 0)
|
|
||||||
mstore(add(fillResults, 96), 0)
|
|
||||||
}
|
|
||||||
case 1 {
|
|
||||||
mstore(fillResults, mload(fillOrderCalldata))
|
mstore(fillResults, mload(fillOrderCalldata))
|
||||||
mstore(add(fillResults, 32), mload(add(fillOrderCalldata, 32)))
|
mstore(add(fillResults, 32), mload(add(fillOrderCalldata, 32)))
|
||||||
mstore(add(fillResults, 64), mload(add(fillOrderCalldata, 64)))
|
mstore(add(fillResults, 64), mload(add(fillOrderCalldata, 64)))
|
||||||
@ -117,7 +111,7 @@ contract MixinWrapperFunctions is
|
|||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
nonReentrant
|
lockMutex
|
||||||
returns (FillResults memory totalFillResults)
|
returns (FillResults memory totalFillResults)
|
||||||
{
|
{
|
||||||
uint256 ordersLength = orders.length;
|
uint256 ordersLength = orders.length;
|
||||||
@ -144,7 +138,7 @@ contract MixinWrapperFunctions is
|
|||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
nonReentrant
|
lockMutex
|
||||||
returns (FillResults memory totalFillResults)
|
returns (FillResults memory totalFillResults)
|
||||||
{
|
{
|
||||||
uint256 ordersLength = orders.length;
|
uint256 ordersLength = orders.length;
|
||||||
@ -172,6 +166,7 @@ contract MixinWrapperFunctions is
|
|||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
|
nonReentrant
|
||||||
returns (FillResults memory totalFillResults)
|
returns (FillResults memory totalFillResults)
|
||||||
{
|
{
|
||||||
uint256 ordersLength = orders.length;
|
uint256 ordersLength = orders.length;
|
||||||
@ -197,7 +192,7 @@ contract MixinWrapperFunctions is
|
|||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
nonReentrant
|
lockMutex
|
||||||
returns (FillResults memory totalFillResults)
|
returns (FillResults memory totalFillResults)
|
||||||
{
|
{
|
||||||
bytes memory takerAssetData = orders[0].takerAssetData;
|
bytes memory takerAssetData = orders[0].takerAssetData;
|
||||||
@ -242,6 +237,7 @@ contract MixinWrapperFunctions is
|
|||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
|
nonReentrant
|
||||||
returns (FillResults memory totalFillResults)
|
returns (FillResults memory totalFillResults)
|
||||||
{
|
{
|
||||||
bytes memory takerAssetData = orders[0].takerAssetData;
|
bytes memory takerAssetData = orders[0].takerAssetData;
|
||||||
@ -285,7 +281,7 @@ contract MixinWrapperFunctions is
|
|||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
nonReentrant
|
lockMutex
|
||||||
returns (FillResults memory totalFillResults)
|
returns (FillResults memory totalFillResults)
|
||||||
{
|
{
|
||||||
bytes memory makerAssetData = orders[0].makerAssetData;
|
bytes memory makerAssetData = orders[0].makerAssetData;
|
||||||
@ -338,6 +334,7 @@ contract MixinWrapperFunctions is
|
|||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
|
nonReentrant
|
||||||
returns (FillResults memory totalFillResults)
|
returns (FillResults memory totalFillResults)
|
||||||
{
|
{
|
||||||
bytes memory makerAssetData = orders[0].makerAssetData;
|
bytes memory makerAssetData = orders[0].makerAssetData;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user