Skip to content
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

fix: checks address proposer #49

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion solidity/contracts/modules/dispute/BondedDisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract BondedDisputeModule is Module, IBondedDisputeModule {
function onDisputeStatusChange(
bytes32 _disputeId,
IOracle.Request calldata _request,
IOracle.Response calldata, /* _response */
IOracle.Response calldata _response, /* _response */
IOracle.Dispute calldata _dispute
) external onlyOracle {
RequestParameters memory _params = decodeRequestData(_request.disputeModuleData);
Expand All @@ -70,6 +70,7 @@ contract BondedDisputeModule is Module, IBondedDisputeModule {
_amount: _params.bondSize
});
} else if (_status == IOracle.DisputeStatus.Won) {
if (_dispute.proposer != _response.proposer) revert BondedDisputeModule_SelfDispute();
// Disputer won, we pay the disputer and release their bond
_params.accountingExtension.pay({
_requestId: _dispute.requestId,
Expand Down
8 changes: 8 additions & 0 deletions solidity/interfaces/modules/dispute/IBondedDisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ import {IAccountingExtension} from '../../extensions/IAccountingExtension.sol';
* the tokens are either returned to the disputer or to the proposer.
*/
interface IBondedDisputeModule is IDisputeModule {
/*///////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/

/**
* @notice Thrown when the response proposer tries to dispute the response
*/
error BondedDisputeModule_SelfDispute();
/*///////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
Expand Down
26 changes: 26 additions & 0 deletions solidity/test/unit/modules/dispute/BondedDisputeModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,32 @@ contract BondedDisputeModule_Unit_OnDisputeStatusChange is BaseTest {
}
}

/**
* @notice Test if onDisputeStatusChange reverts when the dispute is self-disputed
*/
function test_revertIfSelfDispute(uint256 _bondSize, IERC20 _token) public {
mockRequest.disputeModuleData =
abi.encode(IBondedDisputeModule.RequestParameters(accountingExtension, _token, _bondSize));
bytes32 _requestId = _getId(mockRequest);
mockDispute.requestId = _requestId;
bytes32 _disputeId = _getId(mockDispute);

// Mock and expect IOracle.disputeStatus to be called
_mockAndExpect(
address(oracle), abi.encodeCall(oracle.disputeStatus, (_disputeId)), abi.encode(IOracle.DisputeStatus.Won)
);

// Change the proposer to the disputer
mockDispute.proposer = makeAddr('newProposer');

// Check: revert if self-dispute
vm.expectRevert(IBondedDisputeModule.BondedDisputeModule_SelfDispute.selector);

// Test: call disputeResponse with self-dispute
vm.prank(address(oracle));
bondedDisputeModule.onDisputeStatusChange(_disputeId, mockRequest, mockResponse, mockDispute);
}

/**
* @notice Test if onDisputeStatusChange reverts when called by caller who's not the oracle
*/
Expand Down
Loading