mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-02 13:23:10 +00:00
fix: only slots host should be able to submit proof (#227)
* fix: only slots host should be able to submit proof * chore: formatting
This commit is contained in:
parent
1982e71d52
commit
0bf138512b
@ -35,6 +35,7 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
error Marketplace_InvalidState();
|
||||
error Marketplace_StartNotBeforeExpiry();
|
||||
error Marketplace_SlotNotAcceptingProofs();
|
||||
error Marketplace_ProofNotSubmittedByHost();
|
||||
error Marketplace_SlotIsFree();
|
||||
error Marketplace_ReservationRequired();
|
||||
error Marketplace_NothingToWithdraw();
|
||||
@ -208,12 +209,12 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
revert Marketplace_SlotNotFree();
|
||||
}
|
||||
|
||||
_startRequiringProofs(slotId);
|
||||
submitProof(slotId, proof);
|
||||
|
||||
slot.host = msg.sender;
|
||||
slot.filledAt = uint64(block.timestamp);
|
||||
|
||||
_startRequiringProofs(slotId);
|
||||
submitProof(slotId, proof);
|
||||
|
||||
context.slotsFilled += 1;
|
||||
context.fundsToReturnToClient -= _slotPayout(requestId, slot.filledAt);
|
||||
|
||||
@ -321,6 +322,11 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
Groth16Proof calldata proof
|
||||
) public requestIsKnown(_slots[id].requestId) {
|
||||
Slot storage slot = _slots[id];
|
||||
|
||||
if (msg.sender != slot.host) {
|
||||
revert Marketplace_ProofNotSubmittedByHost();
|
||||
}
|
||||
|
||||
Request storage request = _requests[slot.requestId];
|
||||
uint256[] memory pubSignals = new uint256[](3);
|
||||
pubSignals[0] = _challengeToFieldElement(getChallenge(id));
|
||||
|
||||
@ -485,6 +485,13 @@ describe("Marketplace", function () {
|
||||
await marketplace.submitProof(slotId(slot), proof)
|
||||
})
|
||||
|
||||
it("reverts when somebody other then host submit the proof", async function () {
|
||||
switchAccount(host2)
|
||||
await expect(
|
||||
marketplace.submitProof(slotId(slot), proof)
|
||||
).to.be.revertedWith("Marketplace_ProofNotSubmittedByHost")
|
||||
})
|
||||
|
||||
it("converts first 31 bytes of challenge to field element", async function () {
|
||||
let challenge = arrayify(await marketplace.getChallenge(slotId(slot)))
|
||||
let truncated = challenge.slice(0, 31)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user