From 7d377a373902d95efda8e3feeb58b1f69faa3502 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Mon, 16 Jan 2023 17:26:11 +0100 Subject: [PATCH] [marketplace] remove requestMustAcceptProofs modifier Is already covered by the slot state check later on --- contracts/Marketplace.sol | 12 ++---------- test/Marketplace.test.js | 12 ++++++------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/contracts/Marketplace.sol b/contracts/Marketplace.sol index 41d3bad..d4e4a18 100644 --- a/contracts/Marketplace.sol +++ b/contracts/Marketplace.sol @@ -74,7 +74,7 @@ contract Marketplace is Collateral, Proofs, StateRetrieval { RequestId requestId, uint256 slotIndex, bytes calldata proof - ) public requestMustAcceptProofs(requestId) marketplaceInvariant { + ) public { Request storage request = _request(requestId); require(slotIndex < request.ask.slots, "Invalid slot"); @@ -82,7 +82,7 @@ contract Marketplace is Collateral, Proofs, StateRetrieval { Slot storage slot = slots[slotId]; slot.requestId = requestId; - require(slotState(slotId) == SlotState.Free, "Slot already filled"); + require(slotState(slotId) == SlotState.Free, "Slot is not free"); require(balanceOf(msg.sender) >= collateral, "Insufficient collateral"); @@ -411,14 +411,6 @@ contract Marketplace is Collateral, Proofs, StateRetrieval { _; } - /// @notice Modifier that requires the request state to be that which is accepting proof submissions from hosts occupying slots. - /// @dev Request state must be new or started, and must not be cancelled, finished, or failed. - /// @param requestId id of the request, for which to obtain state info - modifier requestMustAcceptProofs(RequestId requestId) { - require(_requestAcceptsProofs(requestId), "Request not accepting proofs"); - _; - } - struct MarketplaceFunds { uint256 balance; uint256 received; diff --git a/test/Marketplace.test.js b/test/Marketplace.test.js index b36c8b4..f7070fb 100644 --- a/test/Marketplace.test.js +++ b/test/Marketplace.test.js @@ -173,7 +173,7 @@ describe("Marketplace", function () { await marketplace.fillSlot(slot.request, slot.index, proof) await expect( marketplace.fillSlot(slot.request, slot.index, proof) - ).to.be.revertedWith("Slot already filled") + ).to.be.revertedWith("Slot is not free") }) it("is rejected when request is unknown", async function () { @@ -191,7 +191,7 @@ describe("Marketplace", function () { switchAccount(host) await expect( marketplace.fillSlot(requestId(expired), slot.index, proof) - ).to.be.revertedWith("Request not accepting proofs") + ).to.be.revertedWith("Slot is not free") }) it("is rejected when request is finished", async function () { @@ -199,7 +199,7 @@ describe("Marketplace", function () { await waitUntilFinished(marketplace, requestId(request)) await expect( marketplace.fillSlot(slot.request, slot.index, proof) - ).to.be.revertedWith("Request not accepting proofs") + ).to.be.revertedWith("Slot is not free") }) it("is rejected when request is failed", async function () { @@ -207,7 +207,7 @@ describe("Marketplace", function () { await waitUntilFailed(marketplace, request) await expect( marketplace.fillSlot(slot.request, slot.index, proof) - ).to.be.revertedWith("Request not accepting proofs") + ).to.be.revertedWith("Slot is not free") }) it("is rejected when slot index not in range", async function () { @@ -224,7 +224,7 @@ describe("Marketplace", function () { } await expect( marketplace.fillSlot(slot.request, lastSlot, proof) - ).to.be.revertedWith("Slot already filled") + ).to.be.revertedWith("Slot is not free") }) }) @@ -417,7 +417,7 @@ describe("Marketplace", function () { } await expect( marketplace.fillSlot(slot.request, lastSlot, proof) - ).to.be.revertedWith("Slot already filled") + ).to.be.revertedWith("Slot is not free") }) })