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: incorrect validation in bond escalation #69

Merged
merged 1 commit into from
Oct 21, 2024
Merged
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@
"solhint-plugin-defi-wonderland": "1.1.2",
"sort-package-json": "2.4.1",
"standard-version": "9.5.0"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
3 changes: 0 additions & 3 deletions solidity/contracts/modules/dispute/BondEscalationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ contract BondEscalationModule is Module, IBondEscalationModule {
// Only the first dispute of a request should go through the bond escalation
// Consecutive disputes should be handled by the resolution module
if (_escalation.status == BondEscalationStatus.None) {
if (block.timestamp > ORACLE.disputeCreatedAt(_disputeId) + _params.bondEscalationDeadline) {
revert BondEscalationModule_BondEscalationOver();
}
_escalation.status = BondEscalationStatus.Active;
_escalation.disputeId = _disputeId;
emit BondEscalationStatusUpdated(_dispute.requestId, _disputeId, BondEscalationStatus.Active);
Expand Down
58 changes: 0 additions & 58 deletions solidity/test/unit/modules/dispute/BondEscalationModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -464,55 +464,6 @@ contract BondEscalationModule_Unit_DisputeResponse is BaseTest {
bondEscalationModule.disputeResponse(mockRequest, mockResponse, mockDispute);
}

/**
* @notice Tests that disputeResponse succeeds if someone dispute after the bond escalation deadline is over
*/
function test_succeedIfDisputeAfterBondingEscalationDeadline(
uint256 _timestamp,
IBondEscalationModule.RequestParameters memory _params
) public assumeFuzzable(address(_params.accountingExtension)) {
_timestamp = bound(_timestamp, block.timestamp, type(uint128).max);

// update mock timestamp
responseCreatedAt = _timestamp;

// Set deadline to timestamp so we are still in the bond escalation period
_params.bondEscalationDeadline = 3 days;
_params.disputeWindow = 5 days;
mockRequest.disputeModuleData = abi.encode(_params);

bytes32 _requestId = _getId(mockRequest);
mockResponse.requestId = _requestId;

bytes32 _responseId = _getId(mockResponse);
mockDispute.responseId = _responseId;
mockDispute.requestId = _requestId;

// Mock and expect IOracle.responseCreatedAt to be called
_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_responseId)), abi.encode(responseCreatedAt)
);
_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.disputeCreatedAt, (_getId(mockDispute))), abi.encode(_timestamp)
);

// Mock and expect the accounting extension to be called
_mockAndExpect(
address(_params.accountingExtension),
abi.encodeWithSignature(
'bond(address,bytes32,address,uint256)', mockDispute.disputer, _requestId, _params.bondToken, _params.bondSize
),
abi.encode(true)
);

vm.warp(_timestamp + _params.bondEscalationDeadline + 1);

// Check: does it revert if the bond escalation is over?
vm.expectRevert(IBondEscalationModule.BondEscalationModule_BondEscalationOver.selector);
vm.prank(address(oracle));
bondEscalationModule.disputeResponse(mockRequest, mockResponse, mockDispute);
}

/**
* @notice Tests that disputeResponse succeeds in starting the bond escalation mechanism when someone disputes
* the first propose before the bond escalation deadline is over.
Expand Down Expand Up @@ -551,10 +502,6 @@ contract BondEscalationModule_Unit_DisputeResponse is BaseTest {
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_responseId)), abi.encode(responseCreatedAt)
);

_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.disputeCreatedAt, (_disputeId)), abi.encode(disputeCreatedAt)
);

vm.expectEmit(true, true, true, true, address(bondEscalationModule));
emit ResponseDisputed({
_requestId: _requestId,
Expand Down Expand Up @@ -605,11 +552,6 @@ contract BondEscalationModule_Unit_DisputeResponse is BaseTest {
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_responseId)), abi.encode(responseCreatedAt)
);

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

// Mock and expect the accounting extension to be called
_mockAndExpect(
address(_params.accountingExtension),
Expand Down
Loading