mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-02 13:23:10 +00:00
chore: add a new canMarkProofAsMissing function (#229)
* Add a new canProofBeMarkedAsMissing function * Rename modifier * Rename canProofBeMarkedAsMissing to canMarkProofAsMissing
This commit is contained in:
parent
b5ca8a61db
commit
aee91f1ac4
@ -335,11 +335,19 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
_proofReceived(id, proof, pubSignals);
|
||||
}
|
||||
|
||||
function markProofAsMissing(SlotId slotId, Period period) public {
|
||||
if (slotState(slotId) != SlotState.Filled)
|
||||
revert Marketplace_SlotNotAcceptingProofs();
|
||||
function canMarkProofAsMissing(
|
||||
SlotId slotId,
|
||||
Period period
|
||||
) public view slotAcceptsProofs(slotId) {
|
||||
_canMarkProofAsMissing(slotId, period);
|
||||
}
|
||||
|
||||
function markProofAsMissing(
|
||||
SlotId slotId,
|
||||
Period period
|
||||
) public slotAcceptsProofs(slotId) {
|
||||
_markProofAsMissing(slotId, period);
|
||||
|
||||
Slot storage slot = _slots[slotId];
|
||||
Request storage request = _requests[slot.requestId];
|
||||
|
||||
@ -349,7 +357,10 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
uint256 validatorRewardAmount = (slashedAmount *
|
||||
_config.collateral.validatorRewardPercentage) / 100;
|
||||
_marketplaceTotals.sent += validatorRewardAmount;
|
||||
assert(_token.transfer(msg.sender, validatorRewardAmount));
|
||||
|
||||
if (!_token.transfer(msg.sender, validatorRewardAmount)) {
|
||||
revert Marketplace_TransferFailed();
|
||||
}
|
||||
|
||||
slot.currentCollateral -= slashedAmount;
|
||||
if (missingProofs(slotId) >= _config.collateral.maxNumberOfSlashes) {
|
||||
@ -559,6 +570,12 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
_;
|
||||
}
|
||||
|
||||
modifier slotAcceptsProofs(SlotId slotId) {
|
||||
if (slotState(slotId) != SlotState.Filled)
|
||||
revert Marketplace_SlotNotAcceptingProofs();
|
||||
_;
|
||||
}
|
||||
|
||||
function requestEnd(RequestId requestId) public view returns (uint64) {
|
||||
RequestState state = requestState(requestId);
|
||||
if (state == RequestState.New || state == RequestState.Started) {
|
||||
|
||||
@ -224,6 +224,16 @@ abstract contract Proofs is Periods {
|
||||
* - proof was already marked as missing
|
||||
*/
|
||||
function _markProofAsMissing(SlotId id, Period missedPeriod) internal {
|
||||
_canMarkProofAsMissing(id, missedPeriod);
|
||||
|
||||
_missing[id][missedPeriod] = true;
|
||||
_missed[id] += 1;
|
||||
}
|
||||
|
||||
function _canMarkProofAsMissing(
|
||||
SlotId id,
|
||||
Period missedPeriod
|
||||
) internal view {
|
||||
uint256 end = _periodEnd(missedPeriod);
|
||||
if (end >= block.timestamp) revert Proofs_PeriodNotEnded();
|
||||
if (block.timestamp >= end + _config.timeout)
|
||||
@ -231,9 +241,6 @@ abstract contract Proofs is Periods {
|
||||
if (_received[id][missedPeriod]) revert Proofs_ProofNotMissing();
|
||||
if (!_isProofRequired(id, missedPeriod)) revert Proofs_ProofNotRequired();
|
||||
if (_missing[id][missedPeriod]) revert Proofs_ProofAlreadyMarkedMissing();
|
||||
|
||||
_missing[id][missedPeriod] = true;
|
||||
_missed[id] += 1;
|
||||
}
|
||||
|
||||
event ProofSubmitted(SlotId id);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user