Skip to content

Commit bd697a6

Browse files
author
cwsnt
committed
1/ address comment
remove unused test instruction
1 parent 8749bf1 commit bd697a6

4 files changed

Lines changed: 430 additions & 433 deletions

File tree

contracts/BorrowerOperations.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,20 @@ contract BorrowerOperations is
159159
}
160160

161161
/*
162-
* @notice set the user's block number for opening, and do check & reset to 0 for closing
162+
* @notice set the user's block number for opening or increasing LoCs, and do check & reset to 0 for closing or decreasing
163163
*
164164
* @dev This is the function will be called by the open, close, increase, decrease trove function
165165
*/
166-
function notInTheSameBlockHandler(bool _isOpening) private {
167-
if(_isOpening) {
168-
userBlockNumber[tx.origin] = block.number;
166+
function recoveryModeMutexHandler(bool _openOrIncrease) private {
167+
if(_openOrIncrease) {
168+
recoveryModeMutex[msg.sender] = block.number;
169169
} else {
170-
if(userBlockNumber[tx.origin] > 0) {
171-
if(userBlockNumber[tx.origin] == block.number) {
172-
revert("ZeroProtocolMutex: mutex locked");
170+
if(recoveryModeMutex[msg.sender] > 0) {
171+
if(recoveryModeMutex[msg.sender] == block.number) {
172+
revert("Recovery mode mutex locked. Try in another block");
173173
}
174174

175-
userBlockNumber[tx.origin] = 0;
175+
recoveryModeMutex[msg.sender] = 0;
176176
}
177177
}
178178
}
@@ -221,7 +221,7 @@ contract BorrowerOperations is
221221
vars.price = priceFeed.fetchPrice();
222222
bool isRecoveryMode = _checkRecoveryMode(vars.price);
223223

224-
if(isRecoveryMode) notInTheSameBlockHandler(true);
224+
if(isRecoveryMode) recoveryModeMutexHandler(true);
225225

226226
_requireValidMaxFeePercentage(_maxFeePercentage, isRecoveryMode);
227227
_requireTroveisNotActive(contractsCache.troveManager, msg.sender);
@@ -606,7 +606,7 @@ contract BorrowerOperations is
606606
vars.isRecoveryMode = _checkRecoveryMode(vars.price);
607607

608608
if(vars.isRecoveryMode) {
609-
notInTheSameBlockHandler(_isDebtIncrease);
609+
recoveryModeMutexHandler(_isDebtIncrease);
610610
}
611611

612612
if (_isDebtIncrease) {

contracts/BorrowerOperationsStorage.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ contract BorrowerOperationsStorage is Ownable {
3838
IFeeDistributor public feeDistributor;
3939

4040
/*
41-
* to store the user's block number
41+
* Store the LoC block number on open/increase when in the Recovery mode
4242
*/
43-
mapping(address => uint256) public userBlockNumber;
43+
mapping(address => uint256) public recoveryModeMutex;
4444
}

contracts/TestContracts/BorrowerOperationsCrossReentrancy.sol

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ contract BorrowerOperationsCrossReentrancy {
3232
_lowerHint
3333
);
3434

35-
// manipulate the price so that the recovery mode will be triggered
36-
IPriceFeedTestnet(_priceFeed).setPrice(1e8);
37-
3835
// // should revert due to reentrancy violation
3936
borrowerOperations.addColl(_upperHint, _lowerHint);
4037
}

0 commit comments

Comments
 (0)