[marketplace] remove wrappers around proof functions
No longer required; slot state is checked in Proofs.sol
This commit is contained in:
parent
55ef97687e
commit
6eab9fee9a
|
@ -249,31 +249,6 @@ contract Marketplace is Collateral, Proofs, StateRetrieval {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isProofRequired(SlotId slotId) public view returns (bool) {
|
|
||||||
if (slotState(slotId) != SlotState.Filled) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return _isProofRequired(slotId);
|
|
||||||
}
|
|
||||||
|
|
||||||
function willProofBeRequired(SlotId slotId) public view returns (bool) {
|
|
||||||
if (slotState(slotId) != SlotState.Filled) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return _willProofBeRequired(slotId);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getChallenge(SlotId slotId) public view returns (bytes32) {
|
|
||||||
if (slotState(slotId) != SlotState.Filled) {
|
|
||||||
return bytes32(0);
|
|
||||||
}
|
|
||||||
return _getChallenge(slotId);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPointer(SlotId slotId) public view returns (uint8) {
|
|
||||||
return _getPointer(slotId);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _price(
|
function _price(
|
||||||
uint64 numSlots,
|
uint64 numSlots,
|
||||||
uint256 duration,
|
uint256 duration,
|
||||||
|
|
|
@ -35,7 +35,7 @@ abstract contract Proofs is Periods {
|
||||||
probabilities[id] = probability;
|
probabilities[id] = probability;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getPointer(
|
function getPointer(
|
||||||
SlotId id,
|
SlotId id,
|
||||||
Period proofPeriod
|
Period proofPeriod
|
||||||
) internal view returns (uint8) {
|
) internal view returns (uint8) {
|
||||||
|
@ -46,25 +46,25 @@ abstract contract Proofs is Periods {
|
||||||
return uint8(pointer);
|
return uint8(pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getPointer(SlotId id) internal view returns (uint8) {
|
function getPointer(SlotId id) public view returns (uint8) {
|
||||||
return _getPointer(id, blockPeriod());
|
return getPointer(id, blockPeriod());
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getChallenge(uint8 pointer) internal view returns (bytes32) {
|
function getChallenge(uint8 pointer) internal view returns (bytes32) {
|
||||||
bytes32 hash = blockhash(block.number - 1 - pointer);
|
bytes32 hash = blockhash(block.number - 1 - pointer);
|
||||||
assert(uint256(hash) != 0);
|
assert(uint256(hash) != 0);
|
||||||
return keccak256(abi.encode(hash));
|
return keccak256(abi.encode(hash));
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getChallenge(
|
function getChallenge(
|
||||||
SlotId id,
|
SlotId id,
|
||||||
Period proofPeriod
|
Period proofPeriod
|
||||||
) internal view returns (bytes32) {
|
) internal view returns (bytes32) {
|
||||||
return _getChallenge(_getPointer(id, proofPeriod));
|
return getChallenge(getPointer(id, proofPeriod));
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getChallenge(SlotId id) internal view returns (bytes32) {
|
function getChallenge(SlotId id) public view returns (bytes32) {
|
||||||
return _getChallenge(id, blockPeriod());
|
return getChallenge(id, blockPeriod());
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getProofRequirement(
|
function _getProofRequirement(
|
||||||
|
@ -76,13 +76,13 @@ abstract contract Proofs is Periods {
|
||||||
if (state != SlotState.Filled || !isAfter(proofPeriod, start)) {
|
if (state != SlotState.Filled || !isAfter(proofPeriod, start)) {
|
||||||
return (false, 0);
|
return (false, 0);
|
||||||
}
|
}
|
||||||
pointer = _getPointer(id, proofPeriod);
|
pointer = getPointer(id, proofPeriod);
|
||||||
bytes32 challenge = _getChallenge(pointer);
|
bytes32 challenge = getChallenge(pointer);
|
||||||
uint256 probability = (probabilities[id] * (256 - downtime)) / 256;
|
uint256 probability = (probabilities[id] * (256 - downtime)) / 256;
|
||||||
isRequired = uint256(challenge) % probability == 0;
|
isRequired = uint256(challenge) % probability == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _isProofRequired(
|
function isProofRequired(
|
||||||
SlotId id,
|
SlotId id,
|
||||||
Period proofPeriod
|
Period proofPeriod
|
||||||
) internal view returns (bool) {
|
) internal view returns (bool) {
|
||||||
|
@ -92,11 +92,11 @@ abstract contract Proofs is Periods {
|
||||||
return isRequired && pointer >= downtime;
|
return isRequired && pointer >= downtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _isProofRequired(SlotId id) internal view returns (bool) {
|
function isProofRequired(SlotId id) public view returns (bool) {
|
||||||
return _isProofRequired(id, blockPeriod());
|
return isProofRequired(id, blockPeriod());
|
||||||
}
|
}
|
||||||
|
|
||||||
function _willProofBeRequired(SlotId id) internal view returns (bool) {
|
function willProofBeRequired(SlotId id) public view returns (bool) {
|
||||||
bool isRequired;
|
bool isRequired;
|
||||||
uint8 pointer;
|
uint8 pointer;
|
||||||
(isRequired, pointer) = _getProofRequirement(id, blockPeriod());
|
(isRequired, pointer) = _getProofRequirement(id, blockPeriod());
|
||||||
|
@ -115,7 +115,7 @@ abstract contract Proofs is Periods {
|
||||||
require(periodEnd < block.timestamp, "Period has not ended yet");
|
require(periodEnd < block.timestamp, "Period has not ended yet");
|
||||||
require(block.timestamp < periodEnd + proofTimeout, "Validation timed out");
|
require(block.timestamp < periodEnd + proofTimeout, "Validation timed out");
|
||||||
require(!received[id][missedPeriod], "Proof was submitted, not missing");
|
require(!received[id][missedPeriod], "Proof was submitted, not missing");
|
||||||
require(_isProofRequired(id, missedPeriod), "Proof was not required");
|
require(isProofRequired(id, missedPeriod), "Proof was not required");
|
||||||
require(!missing[id][missedPeriod], "Proof already marked as missing");
|
require(!missing[id][missedPeriod], "Proof already marked as missing");
|
||||||
missing[id][missedPeriod] = true;
|
missing[id][missedPeriod] = true;
|
||||||
missed[id] += 1;
|
missed[id] += 1;
|
||||||
|
|
|
@ -26,22 +26,6 @@ contract TestProofs is Proofs {
|
||||||
_startRequiringProofs(slot, _probability);
|
_startRequiringProofs(slot, _probability);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isProofRequired(SlotId id) public view returns (bool) {
|
|
||||||
return _isProofRequired(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function willProofBeRequired(SlotId id) public view returns (bool) {
|
|
||||||
return _willProofBeRequired(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getChallenge(SlotId id) public view returns (bytes32) {
|
|
||||||
return _getChallenge(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPointer(SlotId id) public view returns (uint8) {
|
|
||||||
return _getPointer(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function markProofAsMissing(SlotId id, Period _period) public {
|
function markProofAsMissing(SlotId id, Period _period) public {
|
||||||
_markProofAsMissing(id, _period);
|
_markProofAsMissing(id, _period);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue