Pre-audit hardening, part 2: bonus guards, dispute timeout, review execution, release controls #10

Merged
Taskuler-bot merged 3 commits from fix/pre-audit-2 into main 2026-11-13 01:05:01 +00:00
Member

Second round of pre-audit hardening, stacked on #9 (base fix/pre-audit-1). No deploy, no tag.

Changes

  • BuilderBonus
    • At most 3 bonuses per customer address per funding period (MAX_PER_CUSTOMER_PER_PERIOD), counted at reservation like the per-builder cap; a released slot frees both counts.
    • Awards are pending for CLAIM_DELAY (14 days). Within that time the owner (Safe) may cancelAward(jobId, reason) (non-empty reason, BonusCancelled); the TSKR returns to the program budget (slot freed, awarded/totalOwed reduced; anything above the remaining need can go back to the allocation vault through the existing returnExcess). Cancelling frees the builder's and the customer's count for that period again. After the delay anyone calls unlock(jobId) (BonusUnlocked) to make it claimable; withdraw is unchanged.
    • A minimum bounty stays required per token (0 = not eligible), and a job qualifies only if its snapshotted protocol fee rate is at least 2% (MIN_FEE_BPS = 200, checked in qualifies, so no reservation or award below it).
    • Reserving slots on jobs left open needs one live job of at least the minimum bounty per slot, escrowed for the job's life, within the per-customer and per-builder caps (documented in NatSpec and KNOWN-ISSUES).
  • Dispute timeout: resolveStalledDispute(jobId) (anyone) once DISPUTE_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 before appeal (otherwise RulingPending). The check is in a new external library DisputeLib that reads the KlerosCore 2.0.0-rc.2 views (currentRuling from the pinned IArbitratorV2; appealPeriod, getNumberOfRounds, disputes through a minimal IKlerosCoreViews with 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 outcome DisputeTimedOut. A later rule() is accepted (ruling recorded, Ruling emitted) but moves nothing, so the arbitrator callback never fails; a second callback still reverts.
  • CR2: the customer (Safe) may executeRecommendation before the 5-day objection window ends only when the recommendation is 100%; any other split waits the full window.
  • Delivery window: submitDelivery reverts (DeadlinePassed) from deadline + gracePeriod, the moment refundAfterDeadline opens.
  • LiquidityReserve: release is replaced by scheduleRelease → executeRelease after RELEASE_DELAY (48 hours), with cancelRelease by the owner before execution. A scheduled release expires RELEASE_WINDOW (7 days) after it becomes executable (schedule + 48h + 7d); from then on executeRelease reverts ReleaseExpired. NatSpec corrected.
  • Deploy script: 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.
  • Merged fix/pre-audit-1 forward (no force push): reviewer assignment while Open with ReviewerAssigned on assign and reassign, single declarations for library-raised errors.
  • Docs: README, KNOWN-ISSUES (KI-8 final timeout behavior, KI-9 fee minimum, cancel and the off-chain BonusAwarded monitoring 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

  • Market: new resolveStalledDispute(uint256), DISPUTE_TIMEOUT() (= 180 days), disputeCreatedAt(uint256), event DisputeTimedOut(uint256 indexed jobId, uint256 indexed disputeId), errors DeadlinePassed(), RulingPending().
  • New external library DisputeLib (linked at deploy, like PayoutLib/ReviewLib).
  • WorkHistory: Outcome gains DisputeTimedOut (= 6).
  • BuilderBonus: slots(uint256) now returns (builder, period, state, awardedAt, customer); SlotState gains Cancelled (4) and Unlocked (5), and Awarded (2) now means pending; BonusAwarded gains uint64 claimableAt; new unlock(uint256), cancelAward(uint256,string), customerPeriodCount(address,uint256), MAX_PER_CUSTOMER_PER_PERIOD(), CLAIM_DELAY(), MIN_FEE_BPS(), events BonusCancelled, BonusUnlocked, errors CustomerPeriodCapReached, TooEarly, TooLate.
  • LiquidityReserve: release(...) removed; new scheduleRelease, executeRelease, cancelRelease, releases(uint256), releaseCount(), RELEASE_DELAY(), RELEASE_WINDOW(), events ReleaseScheduled, ReleaseCancelled, error ReleaseExpired().

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, late rule(); invariant handlers exercise stalled disputes, late rulings, unlocks and cancellations; invariant_PerCustomerPerPeriod).
  • TaskulerMarket runtime size 23,877 B (limit 24,576, 699 B left). DisputeLib 734 B.
Second round of pre-audit hardening, stacked on #9 (base `fix/pre-audit-1`). No deploy, no tag. ## Changes - **BuilderBonus** - At most 3 bonuses per customer address per funding period (`MAX_PER_CUSTOMER_PER_PERIOD`), counted at reservation like the per-builder cap; a released slot frees both counts. - Awards are pending for `CLAIM_DELAY` (14 days). Within that time the owner (Safe) may `cancelAward(jobId, reason)` (non-empty reason, `BonusCancelled`); the TSKR returns to the program budget (slot freed, `awarded`/`totalOwed` reduced; anything above the remaining need can go back to the allocation vault through the existing `returnExcess`). Cancelling frees the builder's and the customer's count for that period again. After the delay anyone calls `unlock(jobId)` (`BonusUnlocked`) to make it claimable; `withdraw` is unchanged. - A minimum bounty stays required per token (0 = not eligible), and a job qualifies only if its snapshotted protocol fee rate is at least 2% (`MIN_FEE_BPS` = 200, checked in `qualifies`, so no reservation or award below it). - Reserving slots on jobs left open needs one live job of at least the minimum bounty per slot, escrowed for the job's life, within the per-customer and per-builder caps (documented in NatSpec and KNOWN-ISSUES). - **Dispute timeout:** `resolveStalledDispute(jobId)` (anyone) once `DISPUTE_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 before `appeal` (otherwise `RulingPending`). The check is in a new external library `DisputeLib` that reads the KlerosCore 2.0.0-rc.2 views (`currentRuling` from the pinned `IArbitratorV2`; `appealPeriod`, `getNumberOfRounds`, `disputes` through a minimal `IKlerosCoreViews` with 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 outcome `DisputeTimedOut`. A later `rule()` is accepted (ruling recorded, `Ruling` emitted) but moves nothing, so the arbitrator callback never fails; a second callback still reverts. - **CR2:** the customer (Safe) may `executeRecommendation` before the 5-day objection window ends only when the recommendation is 100%; any other split waits the full window. - **Delivery window:** `submitDelivery` reverts (`DeadlinePassed`) from `deadline + gracePeriod`, the moment `refundAfterDeadline` opens. - **LiquidityReserve:** `release` is replaced by `scheduleRelease` → `executeRelease` after `RELEASE_DELAY` (48 hours), with `cancelRelease` by the owner before execution. A scheduled release expires `RELEASE_WINDOW` (7 days) after it becomes executable (schedule + 48h + 7d); from then on `executeRelease` reverts `ReleaseExpired`. NatSpec corrected. - **Deploy script:** `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. - Merged `fix/pre-audit-1` forward (no force push): reviewer assignment while Open with `ReviewerAssigned` on assign and reassign, single declarations for library-raised errors. - Docs: README, KNOWN-ISSUES (KI-8 final timeout behavior, KI-9 fee minimum, cancel and the off-chain `BonusAwarded` monitoring 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 - Market: new `resolveStalledDispute(uint256)`, `DISPUTE_TIMEOUT()` (= 180 days), `disputeCreatedAt(uint256)`, event `DisputeTimedOut(uint256 indexed jobId, uint256 indexed disputeId)`, errors `DeadlinePassed()`, `RulingPending()`. - New external library `DisputeLib` (linked at deploy, like `PayoutLib`/`ReviewLib`). - WorkHistory: `Outcome` gains `DisputeTimedOut` (= 6). - BuilderBonus: `slots(uint256)` now returns `(builder, period, state, awardedAt, customer)`; `SlotState` gains `Cancelled` (4) and `Unlocked` (5), and `Awarded` (2) now means pending; `BonusAwarded` gains `uint64 claimableAt`; new `unlock(uint256)`, `cancelAward(uint256,string)`, `customerPeriodCount(address,uint256)`, `MAX_PER_CUSTOMER_PER_PERIOD()`, `CLAIM_DELAY()`, `MIN_FEE_BPS()`, events `BonusCancelled`, `BonusUnlocked`, errors `CustomerPeriodCapReached`, `TooEarly`, `TooLate`. - LiquidityReserve: `release(...)` removed; new `scheduleRelease`, `executeRelease`, `cancelRelease`, `releases(uint256)`, `releaseCount()`, `RELEASE_DELAY()`, `RELEASE_WINDOW()`, events `ReleaseScheduled`, `ReleaseCancelled`, error `ReleaseExpired()`. ## 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, late `rule()`; invariant handlers exercise stalled disputes, late rulings, unlocks and cancellations; `invariant_PerCustomerPerPeriod`). - `TaskulerMarket` runtime size 23,877 B (limit 24,576, 699 B left). `DisputeLib` 734 B.
- BuilderBonus: at most 3 bonuses per customer per funding period (counted at
  reservation, freed on release); awards are pending for 14 days, then `unlock`
  makes them claimable; the owner may `cancelAward` with a reason within that
  time (TSKR stays in the program budget). Minimum bounty stays required.
- Market: `resolveStalledDispute` closes a dispute with no ruling 90 days after
  creation (full refund to the customer, deposits returned, no protocol fee);
  a later `rule()` is accepted as a no-op. New WorkHistory outcome
  DisputeTimedOut.
- Market: early `executeRecommendation` by the customer only at 100%.
- Market: `submitDelivery` closes at deadline + grace.
- LiquidityReserve: 48-hour schedule/execute timelock, cancellable by the owner.
- Deploy script: REWARDS_DISTRIBUTOR required and must be a contract (testnet
  override only on Arbitrum Sepolia).
- Tests and docs for each item.
# Conflicts:
#	src/TaskulerMarket.sol
- Dispute timeout raised to 180 days and limited to disputes where the
  arbitrator shows no ruling, appeal period or appeal round (RulingPending);
  check lives in the new external DisputeLib using KlerosCore rc.2 views.
- BuilderBonus: jobs need a snapshotted protocol fee of at least 2%
  (MIN_FEE_BPS); cancelAward frees the builder and customer period counts.
- LiquidityReserve: scheduled releases expire 7 days after becoming
  executable (ReleaseExpired).
- Tests with mocked KlerosCore views; docs updated (KNOWN-ISSUES KI-8/9/11,
  THREAT-MODEL operational controls, AUDIT-SCOPE, README, SECURITY-NOTES).
george approved these changes 2026-11-13 00:53:12 +00:00
Dismissed
george approved these changes 2026-11-13 00:53:50 +00:00
Taskuler-bot changed target branch from fix/pre-audit-1 to main 2026-11-13 00:59:05 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
taskuler/contracts!10
No description provided.