Skip to content

Commit

Permalink
Second attempt at fix for issue
Browse files Browse the repository at this point in the history
  • Loading branch information
area committed Nov 30, 2022
1 parent 0dedc59 commit ae55253
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 39 deletions.
7 changes: 0 additions & 7 deletions contracts/reputationMiningCycle/IReputationMiningCycle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,5 @@ interface IReputationMiningCycle is ReputationMiningCycleDataTypes {
/// enum in ReputationMiningCycleDataTypes
/// @param _since The timestamp the last response for the submission in the dispute in question was made at.
/// @return possible bool Whether the user can respond at the current time.
/// @dev Deprecated
function getResponsePossible(DisputeStages _stage, uint256 _since) external view returns (bool possible);

/// @notice Returns whether the caller is able to currently respond to a dispute stage.
/// @param _since The timestamp the last response for the submission in the dispute in question was made at.
/// @return possible bool Whether the user can respond at the current time.
function getResponsePossible(uint256 _since) external view returns (bool possible);

}
14 changes: 5 additions & 9 deletions contracts/reputationMiningCycle/ReputationMiningCycle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ contract ReputationMiningCycle is ReputationMiningCycleCommon {
require(submissionWindowClosed(), "colony-reputation-mining-submission-window-still-open");

require(
responsePossible(disputeRounds[_roundNumber][0].lastResponseTimestamp),
responsePossible(DisputeStages.ConfirmNewHash, disputeRounds[_roundNumber][0].lastResponseTimestamp),
"colony-reputation-mining-user-ineligible-to-respond"
);

Expand Down Expand Up @@ -256,7 +256,7 @@ contract ReputationMiningCycle is ReputationMiningCycleCommon {

// Is the person making this call eligible to?
require(
responsePossible(disputeRounds[_round][opponentIdx].lastResponseTimestamp),
responsePossible(DisputeStages.InvalidateHash, disputeRounds[_round][opponentIdx].lastResponseTimestamp),
"colony-reputation-mining-user-ineligible-to-respond"
);

Expand Down Expand Up @@ -292,7 +292,7 @@ contract ReputationMiningCycle is ReputationMiningCycleCommon {

// The submission can be invalidated - now check the person invalidating is allowed to
require(
responsePossible(add(disputeRounds[_round][_idx].lastResponseTimestamp, CHALLENGE_RESPONSE_WINDOW_DURATION)),
responsePossible(DisputeStages.InvalidateHash, add(disputeRounds[_round][_idx].lastResponseTimestamp, CHALLENGE_RESPONSE_WINDOW_DURATION)),
"colony-reputation-mining-user-ineligible-to-respond"
);

Expand Down Expand Up @@ -350,7 +350,7 @@ contract ReputationMiningCycle is ReputationMiningCycleCommon {
require(submissionWindowClosed(), "colony-reputation-mining-cycle-submissions-not-closed");
require(_index < disputeRounds[_round].length, "colony-reputation-mining-index-beyond-round-length");
require(
responsePossible(disputeRounds[_round][_index].lastResponseTimestamp),
responsePossible(DisputeStages.ConfirmNewHash, disputeRounds[_round][_index].lastResponseTimestamp),
"colony-reputation-mining-user-ineligible-to-respond"
);

Expand Down Expand Up @@ -500,11 +500,7 @@ contract ReputationMiningCycle is ReputationMiningCycleCommon {
}

function getResponsePossible(DisputeStages _stage, uint256 _since) external view returns (bool) {
return responsePossible(_since);
}

function getResponsePossible(uint256 _since) external view returns (bool) {
return responsePossible(_since);
return responsePossible(_stage, _since);
}

/////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ contract ReputationMiningCycleBinarySearch is ReputationMiningCycleCommon {
require(_idx < disputeRounds[_round].length, "colony-reputation-mining-index-beyond-round-length");
require(disputeRounds[_round][_idx].lowerBound != disputeRounds[_round][_idx].upperBound, "colony-reputation-mining-challenge-not-active");
require(
responsePossible(disputeRounds[_round][_idx].lastResponseTimestamp),
responsePossible(DisputeStages.BinarySearchResponse, disputeRounds[_round][_idx].lastResponseTimestamp),
"colony-reputation-mining-user-ineligible-to-respond"
);

Expand Down Expand Up @@ -87,7 +87,7 @@ contract ReputationMiningCycleBinarySearch is ReputationMiningCycleCommon {
"colony-reputation-binary-search-result-already-confirmed"
);
require(
responsePossible(disputeRounds[_round][_idx].lastResponseTimestamp),
responsePossible(DisputeStages.BinarySearchConfirm, disputeRounds[_round][_idx].lastResponseTimestamp),
"colony-reputation-mining-user-ineligible-to-respond"
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ contract ReputationMiningCycleCommon is ReputationMiningCycleStorage, PatriciaTr
uint256 constant CHALLENGE_RESPONSE_WINDOW_DURATION = 60 * 20;
uint256 constant Y = UINT256_MAX / (CHALLENGE_RESPONSE_WINDOW_DURATION - ALL_ENTRIES_ALLOWED_END_OF_WINDOW);

function responsePossible(uint256 _responseWindowOpened) internal view returns (bool) {
function responsePossible(DisputeStages _stage, uint256 _responseWindowOpened) internal view returns (bool) {
if (_responseWindowOpened > block.timestamp) {
// I don't think this is currently possible, but belt and braces!
return false;
Expand All @@ -162,7 +162,7 @@ contract ReputationMiningCycleCommon is ReputationMiningCycleStorage, PatriciaTr
return false;
}
uint256 target = windowOpenFor * Y;
if (uint256(keccak256(abi.encodePacked(minerAddress, _responseWindowOpened))) > target) {
if (uint256(keccak256(abi.encodePacked(minerAddress, address(this), _stage))) > target) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ contract ReputationMiningCycleRespond is ReputationMiningCycleCommon {
challengeOpen(_u[U_ROUND], _u[U_IDX])
{
require(
responsePossible(disputeRounds[_u[U_ROUND]][_u[U_IDX]].lastResponseTimestamp),
responsePossible(DisputeStages.RespondToChallenge, disputeRounds[_u[U_ROUND]][_u[U_IDX]].lastResponseTimestamp),
"colony-reputation-mining-user-ineligible-to-respond"
);

Expand Down
18 changes: 0 additions & 18 deletions docs/interfaces/ireputationminingcycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ Get the length of the ReputationUpdateLog stored on this instance of the Reputat

Returns whether the caller is able to currently respond to a dispute stage.

*Note: Deprecated*

**Parameters**

Expand All @@ -292,23 +291,6 @@ Returns whether the caller is able to currently respond to a dispute stage.
|---|---|---|
|possible|bool|bool Whether the user can respond at the current time.

### `getResponsePossible(uint256 _since):bool possible`

Returns whether the caller is able to currently respond to a dispute stage.


**Parameters**

|Name|Type|Description|
|---|---|---|
|_since|uint256|The timestamp the last response for the submission in the dispute in question was made at.

**Return Parameters**

|Name|Type|Description|
|---|---|---|
|possible|bool|bool Whether the user can respond at the current time.

### `getSubmissionUser(bytes32 _hash, uint256 _nLeaves, bytes32 _jrh, uint256 _index):address user`

Get the address that made a particular submission.
Expand Down

0 comments on commit ae55253

Please sign in to comment.