diff --git a/solidity/contracts/modules/dispute/BondEscalationModule.sol b/solidity/contracts/modules/dispute/BondEscalationModule.sol index f8be387..207e30d 100644 --- a/solidity/contracts/modules/dispute/BondEscalationModule.sol +++ b/solidity/contracts/modules/dispute/BondEscalationModule.sol @@ -14,15 +14,16 @@ import {ModuleTypehash} from '../../utils/ModuleTypehash.sol'; contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { /// @inheritdoc IBondEscalationModule - mapping(bytes32 _requestId => mapping(address _pledger => uint256 pledges)) public pledgesForDispute; + mapping(bytes32 _disputeId => mapping(address _pledger => uint256 pledges)) public pledgesForDispute; /// @inheritdoc IBondEscalationModule - mapping(bytes32 _requestId => mapping(address _pledger => uint256 pledges)) public pledgesAgainstDispute; + mapping(bytes32 _disputeId => mapping(address _pledger => uint256 pledges)) public pledgesAgainstDispute; /** * @notice Struct containing all the data for a given escalation. */ - mapping(bytes32 _requestId => BondEscalation) internal _escalations; + // mapping(bytes32 _requestId => BondEscalation) internal _escalations; + mapping(bytes32 _disputeId => BondEscalation) internal _escalations; constructor(IOracle _oracle) ModuleAccessController(_oracle) {} @@ -39,7 +40,7 @@ contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { ) external onlyOracle { bytes32 _disputeId = _getId(_dispute); RequestParameters memory _params = decodeRequestData(_request.disputeModuleData); - BondEscalation storage _escalation = _escalations[_dispute.requestId]; + BondEscalation storage _escalation = _escalations[_disputeId]; if (block.timestamp >= ORACLE.responseCreatedAt(_dispute.responseId) + _params.disputeWindow) { revert BondEscalationModule_DisputeWindowOver(); @@ -78,128 +79,85 @@ contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { IOracle.Dispute calldata _dispute ) external onlyOracle { RequestParameters memory _params = decodeRequestData(_request.disputeModuleData); - BondEscalation storage _escalation = _escalations[_dispute.requestId]; + BondEscalation storage _escalation = _escalations[_disputeId]; IOracle.DisputeStatus _disputeStatus = ORACLE.disputeStatus(_disputeId); BondEscalationStatus _newStatus; - if (_disputeId == _escalation.disputeId) { - // The bond escalated (first) dispute has been updated - if (_disputeStatus == IOracle.DisputeStatus.Escalated) { - // The dispute has been escalated to the Resolution module - // Make sure the bond escalation deadline has passed and update the status - if (block.timestamp < ORACLE.disputeCreatedAt(_disputeId) + _params.bondEscalationDeadline) { - revert BondEscalationModule_BondEscalationNotOver(); - } - - if ( - _escalation.status != BondEscalationStatus.Active - || _escalation.amountOfPledgesForDispute != _escalation.amountOfPledgesAgainstDispute - ) { - revert BondEscalationModule_NotEscalatable(); - } - - _newStatus = BondEscalationStatus.Escalated; - } else if (_disputeStatus == IOracle.DisputeStatus.NoResolution) { - // The resolution module failed to reach a resolution - // Refund the disputer and all pledgers, the bond escalation escalation status stays Escalated - _newStatus = BondEscalationStatus.Escalated; - - if (_escalation.amountOfPledgesForDispute + _escalation.amountOfPledgesAgainstDispute > 0) { - _params.accountingExtension.onSettleBondEscalation({ - _request: _request, - _dispute: _dispute, - _token: _params.bondToken, - _amountPerPledger: _params.bondSize, - _winningPledgersLength: _escalation.amountOfPledgesForDispute + _escalation.amountOfPledgesAgainstDispute - }); - } + // The bond escalated (first) dispute has been updated + if (_disputeStatus == IOracle.DisputeStatus.Escalated) { + // The dispute has been escalated to the Resolution module + // Make sure the bond escalation deadline has passed and update the status + if (block.timestamp < ORACLE.disputeCreatedAt(_disputeId) + _params.bondEscalationDeadline) { + revert BondEscalationModule_BondEscalationNotOver(); + } - _params.accountingExtension.release({ - _requestId: _dispute.requestId, - _bonder: _dispute.disputer, - _token: _params.bondToken, - _amount: _params.bondSize - }); - } else { - // One of the sides won - // Pay the winner (proposer/disputer) and the pledgers, the bond escalation status changes to DisputerWon/DisputerLost - bool _won = _disputeStatus == IOracle.DisputeStatus.Won; - _newStatus = _won ? BondEscalationStatus.DisputerWon : BondEscalationStatus.DisputerLost; - - uint256 _pledgesForDispute = _escalation.amountOfPledgesForDispute; - uint256 _pledgesAgainstDispute = _escalation.amountOfPledgesAgainstDispute; - - if (_pledgesAgainstDispute > 0 || _pledgesForDispute > 0) { - uint256 _amountToPay = _won - ? _params.bondSize - + FixedPointMathLib.mulDivDown(_pledgesAgainstDispute, _params.bondSize, _pledgesForDispute) - : _params.bondSize - + FixedPointMathLib.mulDivDown(_pledgesForDispute, _params.bondSize, _pledgesAgainstDispute); - - _params.accountingExtension.onSettleBondEscalation({ - _request: _request, - _dispute: _dispute, - _token: _params.bondToken, - _amountPerPledger: _amountToPay, - _winningPledgersLength: _won ? _pledgesForDispute : _pledgesAgainstDispute - }); - } - - _params.accountingExtension.pay({ - _requestId: _dispute.requestId, - _payer: _won ? _dispute.proposer : _dispute.disputer, - _receiver: _won ? _dispute.disputer : _dispute.proposer, + if ( + _escalation.status != BondEscalationStatus.Active + || _escalation.amountOfPledgesForDispute != _escalation.amountOfPledgesAgainstDispute + ) { + revert BondEscalationModule_NotEscalatable(); + } + + _newStatus = BondEscalationStatus.Escalated; + } else if (_disputeStatus == IOracle.DisputeStatus.NoResolution) { + // The resolution module failed to reach a resolution + // Refund the disputer and all pledgers, the bond escalation escalation status stays Escalated + _newStatus = BondEscalationStatus.Escalated; + + if (_escalation.amountOfPledgesForDispute + _escalation.amountOfPledgesAgainstDispute > 0) { + _params.accountingExtension.onSettleBondEscalation({ + _request: _request, + _dispute: _dispute, _token: _params.bondToken, - _amount: _params.bondSize + _amountPerPledger: _params.bondSize, + _winningPledgersLength: _escalation.amountOfPledgesForDispute + _escalation.amountOfPledgesAgainstDispute }); - - if (_won) { - _params.accountingExtension.release({ - _requestId: _dispute.requestId, - _bonder: _dispute.disputer, - _token: _params.bondToken, - _amount: _params.bondSize - }); - } } + + _params.accountingExtension.release({ + _requestId: _dispute.requestId, + _bonder: _dispute.disputer, + _token: _params.bondToken, + _amount: _params.bondSize + }); } else { - // The non-bond escalated (second and subsequent) dispute has been updated - if (_disputeStatus == IOracle.DisputeStatus.Escalated) { - // The dispute has been escalated to the Resolution module - // Update the bond escalation status to Escalated - _newStatus = BondEscalationStatus.Escalated; - } else if (_disputeStatus == IOracle.DisputeStatus.NoResolution) { - // The resolution module failed to reach a resolution - // Refund the disputer, the bond escalation status stays Escalated - _newStatus = BondEscalationStatus.Escalated; - _params.accountingExtension.release({ - _bonder: _dispute.disputer, - _requestId: _dispute.requestId, + // One of the sides won + // Pay the winner (proposer/disputer) and the pledgers, the bond escalation status changes to DisputerWon/DisputerLost + bool _won = _disputeStatus == IOracle.DisputeStatus.Won; + _newStatus = _won ? BondEscalationStatus.DisputerWon : BondEscalationStatus.DisputerLost; + + uint256 _pledgesForDispute = _escalation.amountOfPledgesForDispute; + uint256 _pledgesAgainstDispute = _escalation.amountOfPledgesAgainstDispute; + + if (_pledgesAgainstDispute > 0 || _pledgesForDispute > 0) { + uint256 _amountToPay = _won + ? _params.bondSize + FixedPointMathLib.mulDivDown(_pledgesAgainstDispute, _params.bondSize, _pledgesForDispute) + : _params.bondSize + FixedPointMathLib.mulDivDown(_pledgesForDispute, _params.bondSize, _pledgesAgainstDispute); + + _params.accountingExtension.onSettleBondEscalation({ + _request: _request, + _dispute: _dispute, _token: _params.bondToken, - _amount: _params.bondSize + _amountPerPledger: _amountToPay, + _winningPledgersLength: _won ? _pledgesForDispute : _pledgesAgainstDispute }); - } else { - // One of the sides won - // Pay the winner (proposer/disputer), the bond escalation status changes to DisputerWon/DisputerLost - bool _won = _disputeStatus == IOracle.DisputeStatus.Won; - _newStatus = _won ? BondEscalationStatus.DisputerWon : BondEscalationStatus.DisputerLost; + } + + _params.accountingExtension.pay({ + _requestId: _dispute.requestId, + _payer: _won ? _dispute.proposer : _dispute.disputer, + _receiver: _won ? _dispute.disputer : _dispute.proposer, + _token: _params.bondToken, + _amount: _params.bondSize + }); - _params.accountingExtension.pay({ + if (_won) { + _params.accountingExtension.release({ _requestId: _dispute.requestId, - _payer: _won ? _dispute.proposer : _dispute.disputer, - _receiver: _won ? _dispute.disputer : _dispute.proposer, + _bonder: _dispute.disputer, _token: _params.bondToken, _amount: _params.bondSize }); - - if (_won) { - _params.accountingExtension.release({ - _requestId: _dispute.requestId, - _bonder: _dispute.disputer, - _token: _params.bondToken, - _amount: _params.bondSize - }); - } } } @@ -231,8 +189,8 @@ contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { address _pledger = _accessControl.user; - _escalations[_dispute.requestId].amountOfPledgesForDispute += 1; - pledgesForDispute[_dispute.requestId][_pledger] += 1; + _escalations[_disputeId].amountOfPledgesForDispute += 1; + pledgesForDispute[_disputeId][_pledger] += 1; _params.accountingExtension.pledge({ _pledger: _pledger, _request: _request, @@ -263,8 +221,8 @@ contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { address _pledger = _accessControl.user; - _escalations[_dispute.requestId].amountOfPledgesAgainstDispute += 1; - pledgesAgainstDispute[_dispute.requestId][_pledger] += 1; + _escalations[_disputeId].amountOfPledgesAgainstDispute += 1; + pledgesAgainstDispute[_disputeId][_pledger] += 1; _params.accountingExtension.pledge({ _pledger: _pledger, _request: _request, @@ -284,7 +242,7 @@ contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { ) external { (, bytes32 _disputeId) = _validateResponseAndDispute(_request, _response, _dispute); RequestParameters memory _params = decodeRequestData(_request.disputeModuleData); - BondEscalation storage _escalation = _escalations[_dispute.requestId]; + BondEscalation storage _escalation = _escalations[_disputeId]; uint256 _disputeCreatedAt = ORACLE.disputeCreatedAt(_disputeId); if (block.timestamp < _disputeCreatedAt + _params.bondEscalationDeadline + _params.tyingBuffer) { @@ -329,7 +287,7 @@ contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { ) internal view returns (RequestParameters memory _params) { bytes32 _disputeId = _validateDispute(_request, _dispute); - BondEscalation memory _escalation = _escalations[_dispute.requestId]; + BondEscalation memory _escalation = _escalations[_disputeId]; if (_disputeId != _escalation.disputeId) { revert BondEscalationModule_InvalidDispute(); @@ -375,8 +333,8 @@ contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { } /// @inheritdoc IBondEscalationModule - function getEscalation(bytes32 _requestId) public view returns (BondEscalation memory _escalation) { - _escalation = _escalations[_requestId]; + function getEscalation(bytes32 _disputeId) public view returns (BondEscalation memory _escalation) { + _escalation = _escalations[_disputeId]; } /// @inheritdoc IModule diff --git a/solidity/test/integration/EscalateDispute.t.sol b/solidity/test/integration/EscalateDispute.t.sol index d707a77..69c6650 100644 --- a/solidity/test/integration/EscalateDispute.t.sol +++ b/solidity/test/integration/EscalateDispute.t.sol @@ -109,10 +109,10 @@ contract Integration_EscalateDispute is IntegrationBase { _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl()); // Get the bond escalation - IBondEscalationModule.BondEscalation memory _bondEscalation = _bondEscalationModule.getEscalation(_requestId); + IBondEscalationModule.BondEscalation memory _bondEscalation = _bondEscalationModule.getEscalation(_disputeId); // Check that the pledge was registered - assertEq(_bondEscalationModule.pledgesAgainstDispute(_requestId, proposer), 1); + assertEq(_bondEscalationModule.pledgesAgainstDispute(_disputeId, proposer), 1); assertEq(_bondEscalation.amountOfPledgesAgainstDispute, 1); vm.startPrank(disputer); @@ -138,10 +138,10 @@ contract Integration_EscalateDispute is IntegrationBase { _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl()); // Get the bond escalation - _bondEscalation = _bondEscalationModule.getEscalation(_requestId); + _bondEscalation = _bondEscalationModule.getEscalation(_disputeId); // Check that the pledge was registered - uint256 _pledgesForDispute = _bondEscalationModule.pledgesForDispute(_requestId, disputer); + uint256 _pledgesForDispute = _bondEscalationModule.pledgesForDispute(_disputeId, disputer); assertEq(_pledgesForDispute, 2); assertEq(_bondEscalation.amountOfPledgesForDispute, 2); @@ -183,7 +183,7 @@ contract Integration_EscalateDispute is IntegrationBase { assertTrue(IOracle.DisputeStatus.Won == oracle.disputeStatus(_disputeId)); // //The new bond escalation should have the status DisputerWon - _bondEscalation = _bondEscalationModule.getEscalation(_requestId); + _bondEscalation = _bondEscalationModule.getEscalation(_disputeId); assertTrue(_bondEscalation.status == IBondEscalationModule.BondEscalationStatus.DisputerWon); } @@ -218,10 +218,10 @@ contract Integration_EscalateDispute is IntegrationBase { _bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _createAccessControl()); // Get the bond escalation - IBondEscalationModule.BondEscalation memory _bondEscalation = _bondEscalationModule.getEscalation(_requestId); + IBondEscalationModule.BondEscalation memory _bondEscalation = _bondEscalationModule.getEscalation(_disputeId); // Check that the pledge was registered - assertEq(_bondEscalationModule.pledgesForDispute(_requestId, disputer), 1); + assertEq(_bondEscalationModule.pledgesForDispute(_disputeId, disputer), 1); assertEq(_bondEscalation.amountOfPledgesForDispute, 1); // Pledge revert if the maximum number of escalations is reached @@ -231,10 +231,10 @@ contract Integration_EscalateDispute is IntegrationBase { _bondEscalationModule.pledgeAgainstDispute(mockRequest, mockDispute, _createAccessControl()); // Get the bond escalation - _bondEscalation = _bondEscalationModule.getEscalation(_requestId); + _bondEscalation = _bondEscalationModule.getEscalation(_disputeId); // Check that the pledge was registered - uint256 _pledgesAgainstDispute = _bondEscalationModule.pledgesAgainstDispute(_requestId, proposer); + uint256 _pledgesAgainstDispute = _bondEscalationModule.pledgesAgainstDispute(_disputeId, proposer); assertEq(_pledgesAgainstDispute, 2); assertEq(_bondEscalation.amountOfPledgesAgainstDispute, 2); @@ -277,7 +277,7 @@ contract Integration_EscalateDispute is IntegrationBase { assertTrue(IOracle.DisputeStatus.Lost == oracle.disputeStatus(_disputeId)); // //The new bond escalation should have the status DisputerLost - _bondEscalation = _bondEscalationModule.getEscalation(_requestId); + _bondEscalation = _bondEscalationModule.getEscalation(_disputeId); assertTrue(_bondEscalation.status == IBondEscalationModule.BondEscalationStatus.DisputerLost); } @@ -297,7 +297,7 @@ contract Integration_EscalateDispute is IntegrationBase { // Check that the dispute is active assertTrue( - _bondEscalationModule.getEscalation(_requestId).status == IBondEscalationModule.BondEscalationStatus.Active + _bondEscalationModule.getEscalation(_disputeId).status == IBondEscalationModule.BondEscalationStatus.Active ); // Pledge for dispute @@ -357,7 +357,7 @@ contract Integration_EscalateDispute is IntegrationBase { assertTrue(_disputeStatus == IOracle.DisputeStatus.Escalated); // The BondEscalationModule should now have the escalation status escalated - _bondEscalation = _bondEscalationModule.getEscalation(_requestId); + _bondEscalation = _bondEscalationModule.getEscalation(_disputeId); assertTrue(_bondEscalation.status == IBondEscalationModule.BondEscalationStatus.Escalated); // The ArbitratorModule should have updated the status of the dispute @@ -390,7 +390,7 @@ contract Integration_EscalateDispute is IntegrationBase { // The BondEscalationModule should have updated the status of the escalation assertTrue( - _bondEscalationModule.getEscalation(_requestId).status == IBondEscalationModule.BondEscalationStatus.Escalated + _bondEscalationModule.getEscalation(_disputeId).status == IBondEscalationModule.BondEscalationStatus.Escalated ); // Oracle should have updated the status of the dispute @@ -431,7 +431,7 @@ contract Integration_EscalateDispute is IntegrationBase { assertTrue(_disputeStatus == IOracle.DisputeStatus.Escalated); // The BondEscalationModule should now have the escalation status escalated - _bondEscalation = _bondEscalationModule.getEscalation(_requestId); + _bondEscalation = _bondEscalationModule.getEscalation(_disputeId); assertTrue(_bondEscalation.status == IBondEscalationModule.BondEscalationStatus.Escalated); } @@ -465,7 +465,7 @@ contract Integration_EscalateDispute is IntegrationBase { assertTrue(_disputeStatus == IOracle.DisputeStatus.Escalated); // The BondEscalationModule should now have the escalation status escalated - IBondEscalationModule.BondEscalation memory _bondEscalation = _bondEscalationModule.getEscalation(_requestId); + IBondEscalationModule.BondEscalation memory _bondEscalation = _bondEscalationModule.getEscalation(_disputeId); assertTrue(_bondEscalation.status == IBondEscalationModule.BondEscalationStatus.Escalated); // The ArbitratorModule should have updated the status of the dispute @@ -489,7 +489,7 @@ contract Integration_EscalateDispute is IntegrationBase { // The BondEscalationModule should have updated the status of the escalation assertTrue( - _bondEscalationModule.getEscalation(_requestId).status == IBondEscalationModule.BondEscalationStatus.DisputerLost + _bondEscalationModule.getEscalation(_disputeId).status == IBondEscalationModule.BondEscalationStatus.DisputerLost ); // Oracle should have updated the status of the dispute @@ -526,7 +526,7 @@ contract Integration_EscalateDispute is IntegrationBase { assertTrue(_disputeStatus == IOracle.DisputeStatus.Escalated); // The BondEscalationModule should now have the escalation status escalated - IBondEscalationModule.BondEscalation memory _bondEscalation = _bondEscalationModule.getEscalation(_requestId); + IBondEscalationModule.BondEscalation memory _bondEscalation = _bondEscalationModule.getEscalation(_disputeId); assertTrue(_bondEscalation.status == IBondEscalationModule.BondEscalationStatus.Escalated); // The ArbitratorModule should have updated the status of the dispute @@ -558,7 +558,7 @@ contract Integration_EscalateDispute is IntegrationBase { // The BondEscalationModule should have updated the status of the escalation assertTrue( - _bondEscalationModule.getEscalation(_requestId).status == IBondEscalationModule.BondEscalationStatus.DisputerWon + _bondEscalationModule.getEscalation(_disputeId).status == IBondEscalationModule.BondEscalationStatus.DisputerWon ); // Oracle should have updated the status of the dispute diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index 79f99c4..3682e8c 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -31,31 +31,31 @@ contract ForTest_BondEscalationModule is BondEscalationModule { constructor(IOracle _oracle) BondEscalationModule(_oracle) {} function forTest_setBondEscalation( - bytes32 _requestId, + bytes32 _disputeId, address[] memory _pledgersForDispute, address[] memory _pledgersAgainstDispute ) public { for (uint256 _i; _i < _pledgersForDispute.length; _i++) { - pledgesForDispute[_requestId][_pledgersForDispute[_i]] += 1; + pledgesForDispute[_disputeId][_pledgersForDispute[_i]] += 1; } for (uint256 _i; _i < _pledgersAgainstDispute.length; _i++) { - pledgesAgainstDispute[_requestId][_pledgersAgainstDispute[_i]] += 1; + pledgesAgainstDispute[_disputeId][_pledgersAgainstDispute[_i]] += 1; } - _escalations[_requestId].amountOfPledgesForDispute += _pledgersForDispute.length; - _escalations[_requestId].amountOfPledgesAgainstDispute += _pledgersAgainstDispute.length; + _escalations[_disputeId].amountOfPledgesForDispute += _pledgersForDispute.length; + _escalations[_disputeId].amountOfPledgesAgainstDispute += _pledgersAgainstDispute.length; } function forTest_setBondEscalationStatus( - bytes32 _requestId, + bytes32 _disputeId, BondEscalationModule.BondEscalationStatus _bondEscalationStatus ) public { - _escalations[_requestId].status = _bondEscalationStatus; + _escalations[_disputeId].status = _bondEscalationStatus; } - function forTest_setEscalatedDispute(bytes32 _requestId, bytes32 _disputeId) public { - _escalations[_requestId].disputeId = _disputeId; + function forTest_setEscalatedDispute(bytes32 _disputeId) public { + _escalations[_disputeId].disputeId = _disputeId; } } @@ -140,7 +140,7 @@ contract BaseTest is Test, Helpers { } function _setBondEscalation( - bytes32 _requestId, + bytes32 _disputeId, uint256 _numForPledgers, uint256 _numAgainstPledgers ) internal returns (address[] memory _forPledgers, address[] memory _againstPledgers) { @@ -159,7 +159,7 @@ contract BaseTest is Test, Helpers { _againstPledgers[_j] = _againstPledger; } - bondEscalationModule.forTest_setBondEscalation(_requestId, _forPledgers, _againstPledgers); + bondEscalationModule.forTest_setBondEscalation(_disputeId, _forPledgers, _againstPledgers); return (_forPledgers, _againstPledgers); } @@ -241,7 +241,7 @@ contract BondEscalationModule_Unit_EscalateDispute is BaseTest { // Setting this dispute as the one going through the bond escalation process, as the user can only // dispute once before the bond escalation deadline is over, and that dispute goes through the escalation module. - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); vm.warp(disputeCreatedAt + _params.bondEscalationDeadline - 1); @@ -293,7 +293,7 @@ contract BondEscalationModule_Unit_EscalateDispute is BaseTest { ); // Set the dispute to be the one that went through the bond escalation process for the given requestId - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); vm.warp(disputeCreatedAt + _params.bondEscalationDeadline + 1); @@ -335,13 +335,13 @@ contract BondEscalationModule_Unit_EscalateDispute is BaseTest { vm.warp(disputeCreatedAt + _params.bondEscalationDeadline + _params.tyingBuffer + 1); // Set the bond escalation status of the given requestId to Active - bondEscalationModule.forTest_setBondEscalationStatus(_requestId, IBondEscalationModule.BondEscalationStatus.Active); + bondEscalationModule.forTest_setBondEscalationStatus(_disputeId, IBondEscalationModule.BondEscalationStatus.Active); // Set the dispute to be the one that went through the bond escalation process for the given requestId - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); // Set the number of pledgers for both sides - _setBondEscalation(_requestId, _numForPledgers, _numAgainstPledgers); + _setBondEscalation(_disputeId, _numForPledgers, _numAgainstPledgers); _mockAndExpect( address(oracle), abi.encodeCall(IOracle.disputeCreatedAt, (_disputeId)), abi.encode(disputeCreatedAt) @@ -398,13 +398,13 @@ contract BondEscalationModule_Unit_EscalateDispute is BaseTest { vm.warp(disputeCreatedAt + _params.bondEscalationDeadline + _params.tyingBuffer); // Set the bond escalation status of the given requestId to Active - bondEscalationModule.forTest_setBondEscalationStatus(_requestId, IBondEscalationModule.BondEscalationStatus.Active); + bondEscalationModule.forTest_setBondEscalationStatus(_disputeId, IBondEscalationModule.BondEscalationStatus.Active); // Set the dispute to be the one that went through the bond escalation process for the given requestId - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); // Set the number of pledgers for both sides - _setBondEscalation(_requestId, _numForPledgers, _numAgainstPledgers); + _setBondEscalation(_disputeId, _numForPledgers, _numAgainstPledgers); // Check: is the event emitted? vm.expectEmit(true, true, true, true, address(bondEscalationModule)); @@ -422,7 +422,7 @@ contract BondEscalationModule_Unit_EscalateDispute is BaseTest { vm.prank(address(oracle)); bondEscalationModule.onDisputeStatusChange(_disputeId, mockRequest, mockResponse, mockDispute); - IBondEscalationModule.BondEscalation memory _escalation = bondEscalationModule.getEscalation(_requestId); + IBondEscalationModule.BondEscalation memory _escalation = bondEscalationModule.getEscalation(_disputeId); // Check: is the bond escalation status properly updated? assertEq(uint256(_escalation.status), uint256(IBondEscalationModule.BondEscalationStatus.Escalated)); } @@ -527,12 +527,12 @@ contract BondEscalationModule_Unit_DisputeResponse is BaseTest { // Check: is the bond escalation status now active? assertEq( - uint256(bondEscalationModule.getEscalation(_requestId).status), + uint256(bondEscalationModule.getEscalation(_disputeId).status), uint256(IBondEscalationModule.BondEscalationStatus.Active) ); // Check: is the dispute assigned to the bond escalation process? - assertEq(bondEscalationModule.getEscalation(_requestId).disputeId, _disputeId); + assertEq(bondEscalationModule.getEscalation(_disputeId).disputeId, _disputeId); } function test_emitsEvent( @@ -732,13 +732,13 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { uint256 _numAgainstPledgers = 0; // Set bond escalation data to have no pledgers - _setBondEscalation(_requestId, _numForPledgers, _numAgainstPledgers); + _setBondEscalation(_disputeId, _numForPledgers, _numAgainstPledgers); // Set this dispute to have gone through the bond escalation process - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); // Set the bond escalation status to Active, which is the only possible one for this function - bondEscalationModule.forTest_setBondEscalationStatus(_requestId, IBondEscalationModule.BondEscalationStatus.Active); + bondEscalationModule.forTest_setBondEscalationStatus(_disputeId, IBondEscalationModule.BondEscalationStatus.Active); // Mock and expect IOracle.disputeStatus to be called _mockAndExpect( @@ -769,7 +769,7 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { // Check: is the bond escalation status properly updated? assertEq( - uint256(bondEscalationModule.getEscalation(_requestId).status), + uint256(bondEscalationModule.getEscalation(_disputeId).status), uint256(IBondEscalationModule.BondEscalationStatus.DisputerWon) ); } @@ -796,14 +796,14 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { bytes32 _disputeId = _getId(mockDispute); // Set bond escalation data to have pledgers and to return the winning for pledgers as in this case they won the escalation - _setBondEscalation(_requestId, _numPledgers, _numPledgers); + _setBondEscalation(_disputeId, _numPledgers, _numPledgers); // Set this dispute to have gone through the bond escalation process - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); // Set the bond escalation status to Escalated, which is the only possible one for this function bondEscalationModule.forTest_setBondEscalationStatus( - _requestId, IBondEscalationModule.BondEscalationStatus.Escalated + _disputeId, IBondEscalationModule.BondEscalationStatus.Escalated ); // Mock and expect IOracle.disputeStatus to be called @@ -847,7 +847,7 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { // Check: is the bond escalation status properly updated? assertEq( - uint256(bondEscalationModule.getEscalation(_requestId).status), + uint256(bondEscalationModule.getEscalation(_disputeId).status), uint256(IBondEscalationModule.BondEscalationStatus.DisputerWon) ); } @@ -875,14 +875,14 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { bytes32 _disputeId = _getId(mockDispute); // Set bond escalation data to have pledgers and to return the winning for pledgers as in this case they won the escalation - _setBondEscalation(_requestId, _numPledgers, _numPledgers); + _setBondEscalation(_disputeId, _numPledgers, _numPledgers); // Set this dispute to have gone through the bond escalation process - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); // Set the bond escalation status to Escalated, which is the only possible one for this function bondEscalationModule.forTest_setBondEscalationStatus( - _requestId, IBondEscalationModule.BondEscalationStatus.Escalated + _disputeId, IBondEscalationModule.BondEscalationStatus.Escalated ); // Mock and expect IOracle.disputeStatus to be called @@ -917,7 +917,7 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { // Check: is the bond escalation status properly updated? assertEq( - uint256(bondEscalationModule.getEscalation(_requestId).status), + uint256(bondEscalationModule.getEscalation(_disputeId).status), uint256(IBondEscalationModule.BondEscalationStatus.DisputerLost) ); } @@ -961,7 +961,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); vm.warp(disputeCreatedAt + _params.bondEscalationDeadline + _params.tyingBuffer + 1); @@ -987,7 +987,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 2; uint256 _numAgainstPledgers = _numForPledgers; @@ -1015,7 +1015,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { (, IOracle.Dispute memory _dispute) = _getResponseAndDispute(oracle); bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 2; uint256 _numAgainstPledgers = _numForPledgers - 1; @@ -1045,7 +1045,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 2; uint256 _numAgainstPledgers = _numForPledgers; @@ -1078,7 +1078,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { bytes32 _disputeId = _getId(_dispute); // Mock and expect - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 2; uint256 _numAgainstPledgers = _numForPledgers + 1; @@ -1109,7 +1109,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { bytes32 _disputeId = _getId(_dispute); // Mock and expect - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 2; uint256 _numAgainstPledgers = _numForPledgers + 1; @@ -1131,7 +1131,7 @@ contract BondEscalationModule_Unit_PledgeForDispute is BaseTest { bondEscalationModule.pledgeForDispute(mockRequest, _dispute, _createAccessControl(address(this))); - uint256 _pledgesForDispute = bondEscalationModule.getEscalation(_requestId).amountOfPledgesForDispute; + uint256 _pledgesForDispute = bondEscalationModule.getEscalation(_disputeId).amountOfPledgesForDispute; // Check: is the number of pledges for the dispute properly updated? assertEq(_pledgesForDispute, _numForPledgers + 1); @@ -1179,7 +1179,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); vm.warp(disputeCreatedAt + _params.bondEscalationDeadline + _params.tyingBuffer + 1); @@ -1205,7 +1205,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 2; uint256 _numAgainstPledgers = _numForPledgers; @@ -1236,7 +1236,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numAgainstPledgers = 2; uint256 _numForPledgers = _numAgainstPledgers - 1; @@ -1268,7 +1268,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 2; uint256 _numAgainstPledgers = _numForPledgers; @@ -1300,7 +1300,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { bytes32 _disputeId = _getId(_dispute); // Mock and expect - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 2; uint256 _numAgainstPledgers = _numForPledgers + 1; @@ -1330,7 +1330,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numAgainstPledgers = 2; uint256 _numForPledgers = _numAgainstPledgers + 1; @@ -1351,7 +1351,7 @@ contract BondEscalationModule_Unit_PledgeAgainstDispute is BaseTest { bondEscalationModule.pledgeAgainstDispute(mockRequest, _dispute, _createAccessControl(address(this))); - uint256 _pledgesForDispute = bondEscalationModule.getEscalation(_requestId).amountOfPledgesAgainstDispute; + uint256 _pledgesForDispute = bondEscalationModule.getEscalation(_disputeId).amountOfPledgesAgainstDispute; // Check: is the number of pledges for the dispute properly updated? assertEq(_pledgesForDispute, _numAgainstPledgers + 1); @@ -1459,7 +1459,7 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { vm.warp(disputeCreatedAt + _params.bondEscalationDeadline + _params.tyingBuffer + 1); bondEscalationModule.forTest_setBondEscalationStatus(_requestId, IBondEscalationModule.BondEscalationStatus.Active); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 5; uint256 _numAgainstPledgers = _numForPledgers; @@ -1494,7 +1494,7 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { vm.warp(disputeCreatedAt + _params.bondEscalationDeadline + _params.tyingBuffer + 1); bondEscalationModule.forTest_setBondEscalationStatus(_requestId, IBondEscalationModule.BondEscalationStatus.Active); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 2; uint256 _numAgainstPledgers = _numForPledgers - 1; @@ -1514,7 +1514,7 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { bondEscalationModule.settleBondEscalation(mockRequest, _response, _dispute); // Check: is the bond escalation status properly updated? assertEq( - uint256(bondEscalationModule.getEscalation(_requestId).status), + uint256(bondEscalationModule.getEscalation(_disputeId).status), uint256(IBondEscalationModule.BondEscalationStatus.DisputerWon) ); } @@ -1539,7 +1539,7 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { vm.warp(disputeCreatedAt + _params.bondEscalationDeadline + _params.tyingBuffer + 1); bondEscalationModule.forTest_setBondEscalationStatus(_requestId, IBondEscalationModule.BondEscalationStatus.Active); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numAgainstPledgers = 2; uint256 _numForPledgers = _numAgainstPledgers - 1; @@ -1559,7 +1559,7 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { bondEscalationModule.settleBondEscalation(mockRequest, _response, _dispute); // Check: is the bond escalation status properly updated? assertEq( - uint256(bondEscalationModule.getEscalation(_requestId).status), + uint256(bondEscalationModule.getEscalation(_disputeId).status), uint256(IBondEscalationModule.BondEscalationStatus.DisputerLost) ); } @@ -1592,7 +1592,7 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numForPledgers = 2; uint256 _numAgainstPledgers = _numForPledgers + 1; @@ -1678,7 +1678,7 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { bytes32 _requestId = _getId(mockRequest); bytes32 _disputeId = _getId(_dispute); - bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId); + bondEscalationModule.forTest_setEscalatedDispute(_disputeId); uint256 _numAgainstPledgers = 2; uint256 _numForPledgers = _numAgainstPledgers + 1;