mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-11-22 09:47:13 +01:00
nonReentrant guards
This commit is contained in:
parent
e6cce0c7ce
commit
83c9ba7296
@ -26,12 +26,12 @@ contract ERC20Mixer is Mixer {
|
|||||||
token = _token;
|
token = _token;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _processDeposit() internal {
|
function _processDeposit() internal nonReentrant {
|
||||||
require(msg.value == 0, "ETH value is supposed to be 0 for ETH mixer");
|
require(msg.value == 0, "ETH value is supposed to be 0 for ETH mixer");
|
||||||
_safeErc20TransferFrom(msg.sender, address(this), denomination);
|
_safeErc20TransferFrom(msg.sender, address(this), denomination);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal {
|
function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal nonReentrant {
|
||||||
require(msg.value == _refund, "Incorrect refund amount received by the contract");
|
require(msg.value == _refund, "Incorrect refund amount received by the contract");
|
||||||
|
|
||||||
_safeErc20Transfer(_recipient, denomination - _fee);
|
_safeErc20Transfer(_recipient, denomination - _fee);
|
||||||
|
@ -22,11 +22,11 @@ contract ETHMixer is Mixer {
|
|||||||
) Mixer(_verifier, _denomination, _merkleTreeHeight, _operator) public {
|
) Mixer(_verifier, _denomination, _merkleTreeHeight, _operator) public {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _processDeposit() internal {
|
function _processDeposit() internal nonReentrant {
|
||||||
require(msg.value == denomination, "Please send `mixDenomination` ETH along with transaction");
|
require(msg.value == denomination, "Please send `mixDenomination` ETH along with transaction");
|
||||||
}
|
}
|
||||||
|
|
||||||
function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal {
|
function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal nonReentrant {
|
||||||
// sanity checks
|
// sanity checks
|
||||||
require(msg.value == 0, "Message value is supposed to be zero for ETH mixer");
|
require(msg.value == 0, "Message value is supposed to be zero for ETH mixer");
|
||||||
require(_refund == 0, "Refund value is supposed to be zero for ETH mixer");
|
require(_refund == 0, "Refund value is supposed to be zero for ETH mixer");
|
||||||
|
@ -12,12 +12,13 @@
|
|||||||
pragma solidity ^0.5.8;
|
pragma solidity ^0.5.8;
|
||||||
|
|
||||||
import "./MerkleTreeWithHistory.sol";
|
import "./MerkleTreeWithHistory.sol";
|
||||||
|
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
|
||||||
|
|
||||||
contract IVerifier {
|
contract IVerifier {
|
||||||
function verifyProof(bytes memory _proof, uint256[6] memory _input) public returns(bool);
|
function verifyProof(bytes memory _proof, uint256[6] memory _input) public returns(bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
contract Mixer is MerkleTreeWithHistory {
|
contract Mixer is MerkleTreeWithHistory, ReentrancyGuard {
|
||||||
uint256 public denomination;
|
uint256 public denomination;
|
||||||
mapping(bytes32 => bool) public nullifierHashes;
|
mapping(bytes32 => bool) public nullifierHashes;
|
||||||
// we store all commitments just to prevent accidental deposits with the same commitment
|
// we store all commitments just to prevent accidental deposits with the same commitment
|
||||||
|
Loading…
Reference in New Issue
Block a user