-
Notifications
You must be signed in to change notification settings - Fork 2
[SOV-4416] apply reentrancy guard zero #7
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
base: development
Are you sure you want to change the base?
Changes from 4 commits
c9079ce
be677f9
55c2b84
8a3e4f5
8749bf1
bd697a6
9c5e883
8b70023
87907c7
a55672a
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,4 @@ | ||||||||||
| // SPDX-License-Identifier: MIT | ||||||||||
|
|
||||||||||
| pragma solidity 0.6.11; | ||||||||||
| pragma experimental ABIEncoderV2; | ||||||||||
|
|
||||||||||
|
|
@@ -159,6 +158,25 @@ contract BorrowerOperations is | |||||||||
| emit ZEROStakingAddressChanged(_zeroStakingAddress); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /* | ||||||||||
| * @notice set the user's block number for opening, and do check & reset to 0 for closing | ||||||||||
| * | ||||||||||
| * @dev This is the function will be called by the open, close, increase, decrease trove function | ||||||||||
| */ | ||||||||||
| function notInTheSameBlockHandler(bool _isOpening) private { | ||||||||||
|
||||||||||
| function notInTheSameBlockHandler(bool _isOpening) private { | |
| function recoveryModeMutexHandler(bool _isOpening) private { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| function notInTheSameBlockHandler(bool _isOpening) private { | |
| if(_isOpening) { | |
| function notInTheSameBlockHandler(bool _openOrIncrease) private { | |
| if(_openOrIncrease) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| revert("ZeroProtocolMutex: mutex locked"); | |
| revert("Recovery mode mutex locked. Try in another block"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,4 +36,9 @@ contract BorrowerOperationsStorage is Ownable { | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| IMassetManager public massetManager; | ||||||||||||||||||||||
| IFeeDistributor public feeDistributor; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /* | ||||||||||||||||||||||
| * to store the user's block number | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| mapping(address => uint256) public userBlockNumber; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
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.
Suggested change
Contributor
Author
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. |
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.6.11; | ||
|
|
||
| import "../Interfaces/IBorrowerOperations.sol"; | ||
|
|
||
| interface IPriceFeedTestnet { | ||
| function setPrice(uint256 price) external returns (bool); | ||
| } | ||
|
|
||
| contract BorrowerOperationsCrossReentrancy { | ||
| IBorrowerOperations public borrowerOperations; | ||
|
|
||
| constructor( | ||
| IBorrowerOperations _borrowerOperations | ||
| ) public { | ||
| borrowerOperations = _borrowerOperations; | ||
| } | ||
|
|
||
| fallback() external payable {} | ||
|
|
||
| function testCrossReentrancy( | ||
| uint256 _maxFeePercentage, | ||
| uint256 _ZUSDAmount, | ||
| address _upperHint, | ||
| address _lowerHint, | ||
| address _priceFeed | ||
| ) public payable { | ||
| borrowerOperations.openTrove{value: msg.value}( | ||
| _maxFeePercentage, | ||
| _ZUSDAmount, | ||
| _upperHint, | ||
| _lowerHint | ||
| ); | ||
|
|
||
| // manipulate the price so that the recovery mode will be triggered | ||
| IPriceFeedTestnet(_priceFeed).setPrice(1e8); | ||
|
|
||
| // // should revert due to reentrancy violation | ||
| borrowerOperations.addColl(_upperHint, _lowerHint); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated