[marketplace] remove slotMustAcceptProofs modifier
Replaced by checks on slot state
This commit is contained in:
parent
7d377a3739
commit
1316682a6f
|
@ -113,15 +113,13 @@ contract Marketplace is Collateral, Proofs, StateRetrieval {
|
|||
payoutSlot(slot.requestId, slotId);
|
||||
} else if (state == SlotState.Failed) {
|
||||
removeFromMySlots(msg.sender, slotId);
|
||||
} else {
|
||||
} else if (state == SlotState.Filled) {
|
||||
_forciblyFreeSlot(slotId);
|
||||
}
|
||||
}
|
||||
|
||||
function markProofAsMissing(
|
||||
SlotId slotId,
|
||||
Period period
|
||||
) public slotMustAcceptProofs(slotId) {
|
||||
function markProofAsMissing(SlotId slotId, Period period) public {
|
||||
require(slotState(slotId) == SlotState.Filled, "Slot not accepting proofs");
|
||||
_markProofAsMissing(slotId, period);
|
||||
address host = getHost(slotId);
|
||||
if (missingProofs(slotId) % slashMisses == 0) {
|
||||
|
@ -136,14 +134,7 @@ contract Marketplace is Collateral, Proofs, StateRetrieval {
|
|||
}
|
||||
}
|
||||
|
||||
function _forciblyFreeSlot(
|
||||
SlotId slotId
|
||||
)
|
||||
internal
|
||||
slotMustAcceptProofs(slotId)
|
||||
marketplaceInvariant
|
||||
// TODO: restrict senders that can call this function
|
||||
{
|
||||
function _forciblyFreeSlot(SlotId slotId) internal marketplaceInvariant {
|
||||
Slot storage slot = _slot(slotId);
|
||||
RequestId requestId = slot.requestId;
|
||||
RequestContext storage context = requestContexts[requestId];
|
||||
|
@ -402,15 +393,6 @@ contract Marketplace is Collateral, Proofs, StateRetrieval {
|
|||
assert(funds.received == funds.balance + funds.sent);
|
||||
}
|
||||
|
||||
/// @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 slotId id of the slot, that is mapped to a request, for which to obtain state info
|
||||
modifier slotMustAcceptProofs(SlotId slotId) {
|
||||
RequestId requestId = _getRequestIdForSlot(slotId);
|
||||
require(_requestAcceptsProofs(requestId), "Slot not accepting proofs");
|
||||
_;
|
||||
}
|
||||
|
||||
struct MarketplaceFunds {
|
||||
uint256 balance;
|
||||
uint256 received;
|
||||
|
|
|
@ -37,15 +37,4 @@ contract TestMarketplace is Marketplace {
|
|||
function slot(SlotId slotId) public view returns (Slot memory) {
|
||||
return _slot(slotId);
|
||||
}
|
||||
|
||||
function testAcceptsProofs(
|
||||
SlotId slotId
|
||||
)
|
||||
public
|
||||
view
|
||||
slotMustAcceptProofs(slotId)
|
||||
// solhint-disable-next-line no-empty-blocks
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -734,43 +734,6 @@ describe("Marketplace", function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe("modifiers", function () {
|
||||
beforeEach(async function () {
|
||||
switchAccount(client)
|
||||
await token.approve(marketplace.address, price(request))
|
||||
await marketplace.requestStorage(request)
|
||||
switchAccount(host)
|
||||
await token.approve(marketplace.address, collateral)
|
||||
await marketplace.deposit(collateral)
|
||||
})
|
||||
|
||||
describe("accepting proofs", function () {
|
||||
it("fails when request Cancelled", async function () {
|
||||
await marketplace.fillSlot(slot.request, slot.index, proof)
|
||||
await waitUntilCancelled(request)
|
||||
await expect(
|
||||
marketplace.testAcceptsProofs(slotId(slot))
|
||||
).to.be.revertedWith("Slot not accepting proofs")
|
||||
})
|
||||
|
||||
it("fails when request Finished", async function () {
|
||||
await waitUntilStarted(marketplace, request, proof)
|
||||
await waitUntilFinished(marketplace, requestId(request))
|
||||
await expect(
|
||||
marketplace.testAcceptsProofs(slotId(slot))
|
||||
).to.be.revertedWith("Slot not accepting proofs")
|
||||
})
|
||||
|
||||
it("fails when request Failed", async function () {
|
||||
await waitUntilStarted(marketplace, request, proof)
|
||||
await waitUntilFailed(marketplace, request)
|
||||
await expect(
|
||||
marketplace.testAcceptsProofs(slotId(slot))
|
||||
).to.be.revertedWith("Slot empty")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("list of active requests", function () {
|
||||
beforeEach(async function () {
|
||||
switchAccount(host)
|
||||
|
|
Loading…
Reference in New Issue