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 Dec 1, 2022
1 parent 0dedc59 commit 6eb225c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 44 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
10 changes: 5 additions & 5 deletions test-smoke/colony-storage-consistent.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ contract("Contract Storage", (accounts) => {
console.log("miningCycleStateHash:", miningCycleStateHash);
console.log("tokenLockingStateHash:", tokenLockingStateHash);

expect(colonyNetworkStateHash).to.equal("0x48dd4c68818ce358b837af63f864f11addd2463932892f0e34221847f30485be");
expect(colonyStateHash).to.equal("0x0f313bb56d1f77b5335a68ab7163274a332dd328c7984f910be86694cdcfc7b8");
expect(metaColonyStateHash).to.equal("0x1ff5429d38cc209e06a73a816d2bdf17f911dd751ea5f15bfbac52cf0ef997e8");
expect(miningCycleStateHash).to.equal("0x658d6769e5fa5bc9a34e264a6446c8937fa7985688605146e4f0aeb33db37089");
expect(tokenLockingStateHash).to.equal("0x72e4b1f6b54178a1e53a9b1270590e6d49f0f1cda3dcde5d6136860bc6e73742");
expect(colonyNetworkStateHash).to.equal("0x570abb3930d7a11071801bb7d43a48fd726722371a49f4f7ec73714f9987c818");
expect(colonyStateHash).to.equal("0xa49d332bbdd1951f062b1ffc40bbeb7b3a0a16fd2cd1879fca8348eda7b5b587");
expect(metaColonyStateHash).to.equal("0xff23657f917385e6a94f328907443fef625f08b8b3224e065a53b690f91be0bb");
expect(miningCycleStateHash).to.equal("0x264d4a83e21fef92f687f9fabacae9370966b0b30ebc15307653c4c3d33a0035");
expect(tokenLockingStateHash).to.equal("0x983a56a52582ce548e98659e15a9baa5387886fcb0ac1185dbd746dfabf00338");
});
});
});

0 comments on commit 6eb225c

Please sign in to comment.