diff --git a/contracts/Marketplace.sol b/contracts/Marketplace.sol index 98fbdba..b706ce0 100644 --- a/contracts/Marketplace.sol +++ b/contracts/Marketplace.sol @@ -320,18 +320,10 @@ contract Marketplace is Collateral, Proofs { return _timeout(); } - function proofStart(SlotId slotId) public view override returns (uint256) { - return requestStart(_slot(slotId).requestId); - } - function proofEnd(SlotId slotId) public view override returns (uint256) { return requestEnd(_slot(slotId).requestId); } - function requestStart(RequestId requestId) public view returns (uint256) { - return _context(requestId).startedAt; - } - function requestEnd(RequestId requestId) public view returns (uint256) { uint256 end = _context(requestId).endsAt; if (_requestAcceptsProofs(requestId)) { diff --git a/contracts/Proofs.sol b/contracts/Proofs.sol index 97601f5..5e0d5d3 100644 --- a/contracts/Proofs.sol +++ b/contracts/Proofs.sol @@ -19,6 +19,7 @@ abstract contract Proofs is Periods { } mapping(SlotId => bool) private slotIds; + mapping(SlotId => uint256) private slotStarts; mapping(SlotId => uint256) private probabilities; mapping(SlotId => uint256) private missed; mapping(SlotId => mapping(Period => bool)) private received; @@ -28,10 +29,6 @@ abstract contract Proofs is Periods { return timeout; } - // Override this to let the proving system know when proofs for a - // slot are required. - function proofStart(SlotId id) public view virtual returns (uint256); - // Override this to let the proving system know when proofs for a // slot are no longer required. function proofEnd(SlotId id) public view virtual returns (uint256); @@ -46,6 +43,7 @@ abstract contract Proofs is Periods { function _startRequiringProofs(SlotId id, uint256 probability) internal { require(!slotIds[id], "Proofs already required for slot"); slotIds[id] = true; + slotStarts[id] = block.timestamp; probabilities[id] = probability; } @@ -90,7 +88,7 @@ abstract contract Proofs is Periods { SlotId id, Period proofPeriod ) internal view returns (bool isRequired, uint8 pointer) { - Period start = periodOf(proofStart(id)); + Period start = periodOf(slotStarts[id]); Period end = periodOf(proofEnd(id)); if (!isAfter(proofPeriod, start) || !isBefore(proofPeriod, end)) { return (false, 0); diff --git a/contracts/TestProofs.sol b/contracts/TestProofs.sol index af5d9d7..244c6d9 100644 --- a/contracts/TestProofs.sol +++ b/contracts/TestProofs.sol @@ -5,7 +5,6 @@ import "./Proofs.sol"; // exposes internal functions of Proofs for testing contract TestProofs is Proofs { - mapping(SlotId => uint256) private starts; mapping(SlotId => uint256) private ends; constructor( @@ -19,10 +18,6 @@ contract TestProofs is Proofs { } - function proofStart(SlotId slotId) public view override returns (uint256) { - return starts[slotId]; - } - function proofEnd(SlotId slotId) public view override returns (uint256) { return ends[slotId]; } @@ -59,10 +54,6 @@ contract TestProofs is Proofs { _markProofAsMissing(id, _period); } - function setProofStart(SlotId id, uint256 start) public { - starts[id] = start; - } - function setProofEnd(SlotId id, uint256 end) public { ends[id] = end; } diff --git a/test/Proofs.test.js b/test/Proofs.test.js index 452933c..727b7b0 100644 --- a/test/Proofs.test.js +++ b/test/Proofs.test.js @@ -37,7 +37,6 @@ describe("Proofs", function () { describe("general", function () { beforeEach(async function () { - await proofs.setProofStart(slotId, await currentTime()) await proofs.setProofEnd(slotId, (await currentTime()) + duration) }) @@ -90,7 +89,6 @@ describe("Proofs", function () { let id2 = hexlify(randomBytes(32)) let id3 = hexlify(randomBytes(32)) for (let slotId of [id1, id2, id3]) { - await proofs.setProofStart(slotId, await currentTime()) await proofs.setProofEnd(slotId, (await currentTime()) + duration) await proofs.startRequiringProofs(slotId, probability) } @@ -122,7 +120,6 @@ describe("Proofs", function () { } beforeEach(async function () { - await proofs.setProofStart(slotId, await currentTime()) await proofs.setProofEnd(slotId, (await currentTime()) + duration) await proofs.startRequiringProofs(slotId, probability) await advanceTimeTo(periodEnd(periodOf(await currentTime()))) @@ -157,7 +154,6 @@ describe("Proofs", function () { const proof = hexlify(randomBytes(42)) beforeEach(async function () { - await proofs.setProofStart(slotId, await currentTime()) await proofs.setProofEnd(slotId, (await currentTime()) + duration) await proofs.startRequiringProofs(slotId, probability) })