Pre-audit hardening, part 2: bonus guards, dispute timeout, review execution, release controls #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/pre-audit-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Second round of pre-audit hardening, stacked on #9 (base
fix/pre-audit-1). No deploy, no tag.Changes
MAX_PER_CUSTOMER_PER_PERIOD), counted at reservation like the per-builder cap; a released slot frees both counts.CLAIM_DELAY(14 days). Within that time the owner (Safe) maycancelAward(jobId, reason)(non-empty reason,BonusCancelled); the TSKR returns to the program budget (slot freed,awarded/totalOwedreduced; anything above the remaining need can go back to the allocation vault through the existingreturnExcess). Cancelling frees the builder's and the customer's count for that period again. After the delay anyone callsunlock(jobId)(BonusUnlocked) to make it claimable;withdrawis unchanged.MIN_FEE_BPS= 200, checked inqualifies, so no reservation or award below it).resolveStalledDispute(jobId)(anyone) onceDISPUTE_TIMEOUT(180 days) has passed since dispute creation, and only while the arbitrator has been silent: no current ruling, no appeal period, a single round, period beforeappeal(otherwiseRulingPending). The check is in a new external libraryDisputeLibthat reads the KlerosCore 2.0.0-rc.2 views (currentRulingfrom the pinnedIArbitratorV2;appealPeriod,getNumberOfRounds,disputesthrough a minimalIKlerosCoreViewswith the rc.2 signatures). A view that reverts counts as no activity, so an unresponsive arbitrator can't lock funds. It resolves at 0% with both deposits returned and no protocol fee, so the customer gets price + prepaid fee + deposit and the builder its deposit. An unearned reviewer fee goes back to the customer, and the Kleros prepay stays with whoever paid it. New WorkHistory outcomeDisputeTimedOut. A laterrule()is accepted (ruling recorded,Rulingemitted) but moves nothing, so the arbitrator callback never fails; a second callback still reverts.executeRecommendationbefore the 5-day objection window ends only when the recommendation is 100%; any other split waits the full window.submitDeliveryreverts (DeadlinePassed) fromdeadline + gracePeriod, the momentrefundAfterDeadlineopens.releaseis replaced byscheduleRelease→executeReleaseafterRELEASE_DELAY(48 hours), withcancelReleaseby the owner before execution. A scheduled release expiresRELEASE_WINDOW(7 days) after it becomes executable (schedule + 48h + 7d); from then onexecuteReleaserevertsReleaseExpired. NatSpec corrected.REWARDS_DISTRIBUTOR(the community vault beneficiary) is required and must have contract code; no deployer default.ALLOW_NON_CONTRACT_GOVERNANCE_TESTNET(Arbitrum Sepolia only) also covers it.fix/pre-audit-1forward (no force push): reviewer assignment while Open withReviewerAssignedon assign and reassign, single declarations for library-raised errors.BonusAwardedmonitoring as an operational control, KI-11 release expiry), THREAT-MODEL (new operational controls section), AUDIT-SCOPE (line counts, new files), SECURITY-NOTES and OPEN-QUESTIONS updated. Treasury vault cliff unchanged.ABI changes (frontend), on top of #9
resolveStalledDispute(uint256),DISPUTE_TIMEOUT()(= 180 days),disputeCreatedAt(uint256), eventDisputeTimedOut(uint256 indexed jobId, uint256 indexed disputeId), errorsDeadlinePassed(),RulingPending().DisputeLib(linked at deploy, likePayoutLib/ReviewLib).OutcomegainsDisputeTimedOut(= 6).slots(uint256)now returns(builder, period, state, awardedAt, customer);SlotStategainsCancelled(4) andUnlocked(5), andAwarded(2) now means pending;BonusAwardedgainsuint64 claimableAt; newunlock(uint256),cancelAward(uint256,string),customerPeriodCount(address,uint256),MAX_PER_CUSTOMER_PER_PERIOD(),CLAIM_DELAY(),MIN_FEE_BPS(), eventsBonusCancelled,BonusUnlocked, errorsCustomerPeriodCapReached,TooEarly,TooLate.release(...)removed; newscheduleRelease,executeRelease,cancelRelease,releases(uint256),releaseCount(),RELEASE_DELAY(),RELEASE_WINDOW(), eventsReleaseScheduled,ReleaseCancelled, errorReleaseExpired().Checks
forge test: 239 passed, 0 failed (new unit tests for every item, including mocked KlerosCore views: no ruling ever, ruling with appeal open, appeal in progress, execution period, unresponsive arbitrator, laterule(); invariant handlers exercise stalled disputes, late rulings, unlocks and cancellations;invariant_PerCustomerPerPeriod).TaskulerMarketruntime size 23,877 B (limit 24,576, 699 B left).DisputeLib734 B.