diff --git a/test/invariants/PROPERTIES.md b/test/invariants/PROPERTIES.md index 32b27a2..f015bff 100644 --- a/test/invariants/PROPERTIES.md +++ b/test/invariants/PROPERTIES.md @@ -146,5 +146,4 @@ Oracle | disputeResponse(Request,Response,Dispute) external returns (bytes32) | [] | | escalateDispute(Request,Response,Dispute) external | [] | | resolveDispute(Request,Response,Dispute) external | [] | -| updateDisputeStatus(Request,Response,Dispute,DisputeStatus) external | [] | | finalize(Request,Response) external | [] | diff --git a/test/invariants/handlers/BaseHandler.t.sol b/test/invariants/handlers/BaseHandler.t.sol index bcdfc01..da1edae 100644 --- a/test/invariants/handlers/BaseHandler.t.sol +++ b/test/invariants/handlers/BaseHandler.t.sol @@ -13,14 +13,13 @@ contract BaseHandler is Setup, Actors { mapping(bytes32 _requestId => IOracle.Request _data) internal _ghost_requestData; // Track responses for requests - mapping(bytes32 _requestId => bytes32 _responseId) internal _ghost_activeResponses; // requestId => responseId + mapping(bytes32 _requestId => bytes32[] _responsesId) internal _ghost_activeResponses; // requestId => responseId's mapping(bytes32 _responseId => IOracle.Response _data) internal _ghost_responseData; mapping(bytes32 _responseId => bool _isFinalized) internal _ghost_finalizedResponses; // Track disputes mapping(bytes32 _requestId => bytes32[] _disputeIds) internal _ghost_disputes; // requestId => disputeIds mapping(bytes32 _disputeId => IOracle.Dispute _data) internal _ghost_disputeData; - mapping(bytes32 _disputeId => IOracle.DisputeStatus _status) internal _ghost_disputeStatuses; // Track which requests came from EBORequestCreator mapping(bytes32 _requestId => bool _isFromRequestCreator) internal _ghost_validRequests; @@ -56,8 +55,8 @@ contract BaseHandler is Setup, Actors { return _ghost_requests[_seed % _ghost_requests.length]; } - function _getRandomActiveResponse(bytes32 _requestId) internal view returns (IOracle.Response memory) { - bytes32 responseId = _ghost_activeResponses[_requestId]; + function _getRandomActiveResponse(bytes32 _requestId, uint256 _seed) internal view returns (IOracle.Response memory) { + bytes32 responseId = _ghost_activeResponses[_requestId][_seed % _ghost_activeResponses[_requestId].length]; return _ghost_responseData[responseId]; } diff --git a/test/invariants/handlers/HandlerArbitrable.t.sol b/test/invariants/handlers/HandlerArbitrable.t.sol index 7fb7cfd..38a2f6d 100644 --- a/test/invariants/handlers/HandlerArbitrable.t.sol +++ b/test/invariants/handlers/HandlerArbitrable.t.sol @@ -4,11 +4,6 @@ pragma solidity 0.8.26; import {BaseHandler} from './BaseHandler.t.sol'; contract HandlerArbitrable is BaseHandler { - function handleValidateArbitrator(uint256 _actorSeed) external { - address caller = _pickActor(_actorSeed); - arbitrable.validateArbitrator(caller); - } - function handleSetArbitrator(uint256 _actorSeed) external { address newArbitrator = _pickActor(_actorSeed); arbitrable.setArbitrator(newArbitrator); diff --git a/test/invariants/handlers/HandlerBondEscalationModule.t.sol b/test/invariants/handlers/HandlerBondEscalationModule.t.sol index f9c2ba0..3861603 100644 --- a/test/invariants/handlers/HandlerBondEscalationModule.t.sol +++ b/test/invariants/handlers/HandlerBondEscalationModule.t.sol @@ -11,7 +11,7 @@ contract HandlerBondEscalationModule is BaseHandler { IOracle.Dispute memory dispute = _getRandomDispute(requestId, _disputeIndex); if (dispute.requestId == bytes32(0)) return; - if (_ghost_disputeStatuses[keccak256(abi.encode(dispute))] != IOracle.DisputeStatus.Escalated) return; + if (oracle.disputeStatus(keccak256(abi.encode(dispute))) != IOracle.DisputeStatus.Escalated) return; address pledger = _pickActor(_actorSeed); bondEscalationModule.pledgeForDispute(_ghost_requestData[requestId], dispute); @@ -28,7 +28,7 @@ contract HandlerBondEscalationModule is BaseHandler { IOracle.Dispute memory dispute = _getRandomDispute(requestId, _disputeIndex); if (dispute.requestId == bytes32(0)) return; - if (_ghost_disputeStatuses[keccak256(abi.encode(dispute))] != IOracle.DisputeStatus.Escalated) return; + if (oracle.disputeStatus(keccak256(abi.encode(dispute))) != IOracle.DisputeStatus.Escalated) return; address pledger = _pickActor(_actorSeed); bondEscalationModule.pledgeAgainstDispute(_ghost_requestData[requestId], dispute); @@ -53,7 +53,5 @@ contract HandlerBondEscalationModule is BaseHandler { // Clear dispute pledges as they're now settled delete _ghost_pledgesFor[dispute.disputer][disputeId]; delete _ghost_pledgesAgainst[dispute.disputer][disputeId]; - // Update dispute status - _ghost_disputeStatuses[disputeId] = IOracle.DisputeStatus.NoResolution; } } diff --git a/test/invariants/handlers/HandlerBondedResponseModule.t.sol b/test/invariants/handlers/HandlerBondedResponseModule.t.sol index 3705ff8..7a1822b 100644 --- a/test/invariants/handlers/HandlerBondedResponseModule.t.sol +++ b/test/invariants/handlers/HandlerBondedResponseModule.t.sol @@ -8,7 +8,7 @@ contract HandlerBondedResponseModule is BaseHandler { bytes32 requestId = _getRandomRequest(_requestSeed); if (requestId == bytes32(0)) return; - IOracle.Response memory response = _getRandomActiveResponse(requestId); + IOracle.Response memory response = _getRandomActiveResponse(requestId, _requestSeed); if (response.requestId == bytes32(0)) return; bondedResponseModule.releaseUnutilizedResponse(_ghost_requestData[requestId], response); diff --git a/test/invariants/handlers/HandlerCouncilArbitrator.t.sol b/test/invariants/handlers/HandlerCouncilArbitrator.t.sol index 9a8c0c3..ed08aa2 100644 --- a/test/invariants/handlers/HandlerCouncilArbitrator.t.sol +++ b/test/invariants/handlers/HandlerCouncilArbitrator.t.sol @@ -19,8 +19,6 @@ contract HandlerCouncilArbitrator is BaseHandler { ); councilArbitrator.arbitrateDispute(disputeId, status); - // Update ghost variables - _ghost_disputeStatuses[disputeId] = status; // If dispute lost, potentially update request finalization state if (status == IOracle.DisputeStatus.Lost) { diff --git a/test/invariants/handlers/HandlerOracle.t.sol b/test/invariants/handlers/HandlerOracle.t.sol index ba0e5f1..0714b44 100644 --- a/test/invariants/handlers/HandlerOracle.t.sol +++ b/test/invariants/handlers/HandlerOracle.t.sol @@ -20,7 +20,6 @@ contract HandlerOracle is BaseHandler { if (requestId == bytes32(0) || !_ghost_validRequests[requestId]) { return bytes32(0); } - if (_ghost_activeResponses[requestId] != bytes32(0)) return bytes32(0); address proposer = _pickActor(_actorSeed); _blockNumber = _boundBlockNumber(_blockNumber); @@ -32,7 +31,7 @@ contract HandlerOracle is BaseHandler { bytes32 responseId = oracle.proposeResponse(request, response); // Track response - _ghost_activeResponses[requestId] = responseId; + _ghost_activeResponses[requestId].push(responseId); _ghost_responseData[responseId] = response; emit ResponseProposed(requestId, responseId); @@ -46,8 +45,8 @@ contract HandlerOracle is BaseHandler { return bytes32(0); } - bytes32 responseId = _ghost_activeResponses[requestId]; - if (responseId == bytes32(0)) return bytes32(0); + if (_ghost_activeResponses[requestId].length == 0) return (bytes32(0)); + bytes32 responseId = _ghost_activeResponses[requestId][0]; IOracle.Response memory response = _ghost_responseData[responseId]; if (_ghost_finalizedResponses[responseId]) return bytes32(0); @@ -64,7 +63,6 @@ contract HandlerOracle is BaseHandler { _ghost_disputes[requestId].push(disputeId); _ghost_disputeData[disputeId] = dispute; _ghost_bonds[disputer][requestId] = bond; - _ghost_disputeStatuses[disputeId] = IOracle.DisputeStatus.Escalated; emit DisputeCreated(requestId, responseId, disputeId); @@ -78,7 +76,7 @@ contract HandlerOracle is BaseHandler { IOracle.Dispute memory dispute = _getRandomDispute(requestId, _disputeIndex); if (dispute.requestId == bytes32(0)) return; - if (_ghost_disputeStatuses[keccak256(abi.encode(dispute))] != IOracle.DisputeStatus.Escalated) return; + if (oracle.disputeStatus(keccak256(abi.encode(dispute))) != IOracle.DisputeStatus.Escalated) return; IOracle.Response memory response = _ghost_responseData[dispute.responseId]; oracle.escalateDispute(_ghost_requestData[requestId], response, dispute); @@ -95,38 +93,12 @@ contract HandlerOracle is BaseHandler { oracle.resolveDispute(_ghost_requestData[requestId], response, dispute); } - function handleUpdateDisputeStatus(uint256 _requestSeed, uint256 _disputeIndex, uint256 _statusSeed) external { - bytes32 requestId = _getRandomRequest(_requestSeed); - if (requestId == bytes32(0)) return; - - IOracle.Dispute memory dispute = _getRandomDispute(requestId, _disputeIndex); - if (dispute.requestId == bytes32(0)) return; - - // Generate a valid dispute status (NoResolution, Won, Lost) - IOracle.DisputeStatus status = IOracle.DisputeStatus( - bound(_statusSeed, uint8(IOracle.DisputeStatus.NoResolution), uint8(IOracle.DisputeStatus.Lost)) - ); - - IOracle.Response memory response = _ghost_responseData[dispute.responseId]; - oracle.updateDisputeStatus(_ghost_requestData[requestId], response, dispute, status); - - bytes32 disputeId = keccak256(abi.encode(dispute)); - _ghost_disputeStatuses[disputeId] = status; - - // If dispute resolved with Lost status, mark response as finalized - if (status == IOracle.DisputeStatus.Lost) { - _ghost_finalizedResponses[response.requestId] = true; - } - - emit DisputeResolved(disputeId, status); - } - function handleFinalize(uint256 _requestSeed) external { bytes32 requestId = _getRandomRequest(_requestSeed); if (requestId == bytes32(0)) return; - bytes32 responseId = _ghost_activeResponses[requestId]; - if (responseId == bytes32(0)) return; + if (_ghost_activeResponses[requestId].length == 0) return; + bytes32 responseId = _ghost_activeResponses[requestId][0]; IOracle.Response memory response = _ghost_responseData[responseId]; oracle.finalize(_ghost_requestData[requestId], response); @@ -134,7 +106,6 @@ contract HandlerOracle is BaseHandler { // Update ghost variables _ghost_finalizedResponses[responseId] = true; delete _ghost_activeResponses[requestId]; // Clear active response - delete _ghost_disputeStatuses[responseId]; // Clear any dispute status _ghost_validRequests[requestId] = false; // Mark request as no longer valid/active // If there were any disputes, clear their state @@ -142,7 +113,6 @@ contract HandlerOracle is BaseHandler { for (uint256 i = 0; i < disputes.length; i++) { bytes32 disputeId = disputes[i]; delete _ghost_disputeData[disputeId]; - delete _ghost_disputeStatuses[disputeId]; } delete _ghost_disputes[requestId]; diff --git a/test/invariants/properties/PropertyEbo.t.sol b/test/invariants/properties/PropertyEbo.t.sol index da2bfa4..4c2df8b 100644 --- a/test/invariants/properties/PropertyEbo.t.sol +++ b/test/invariants/properties/PropertyEbo.t.sol @@ -9,8 +9,8 @@ contract PropertyEbo is HandlerParent { /// @custom:property-id 1 /// @custom:property Requester can always create a request as long as the same chainId/epoch isn't requested yet - function property_canAlwaysCreateRequest(uint256 _epoch, uint256 _chainId) external { - _epoch = _boundEpoch(_epoch); - string memory _chainId = _generateChainId(_chainId); - } + // function property_canAlwaysCreateRequest(uint256 _epoch, uint256 _chainId) external { + // _epoch = _boundEpoch(_epoch); + // string memory _chainId = _generateChainId(_chainId); + // } }