Market circuit breaker for new escrow + versioned redeploy runbook #15

Merged
Taskuler-bot merged 4 commits from feat/circuit-breaker into main 2026-11-13 22:08:48 +00:00
Member

Approved scope (2026-11-13): circuit breaker on TaskulerMarket and a runbook for shipping a fixed Market after launch. No deployment in this PR.

Circuit breaker

  • pause() / unpause(), onlyOwner (the governance Safe). Events Paused(address account) / Unpaused(address account) (same signatures as OZ Pausable), view paused(), error EnforcedPause(). Both calls are idempotent. Non-upgradeable as before.
  • Blocked while paused (new value-in): postJob, postProjectJob, placeBid, assignReviewer. The check is in _pull, the only function that increases jobHeld, so a future value-in path can't skip it.
  • Allowed while paused: cancelJob, withdrawBid, acceptBid (existing bids), submitDelivery, acceptDelivery, releaseAfterReview, refundAfterDeadline, every settlement offer call, submitRecommendation, reassignReviewer, executeRecommendation, requestArbitration, rule, resolveStalledDispute, withdraw, and every owner setting including OFAC holds.
  • Design choices:
    • New bids are blocked because each one escrows a new deposit.
    • Accepting an existing bid stays allowed: it adds no value (it only refunds the price difference) and lets jobs that are already escrowed go ahead. A customer whose job has no acceptable bid cancels for a full refund.
    • requestArbitration stays open: its ETH goes straight to Kleros in the same call, and it is the only exit for escalated and lapsed-review jobs.
    • Unpause is immediate like pause. It moves no funds, the Safe can already change new-job parameters instantly (KI-6), and a delay would slow a rollback.
    • Who can pause: DECIDED 2026-11-13: only the Safe; no separate pause-only key (OPEN-QUESTIONS 23b, KI-13).
  • OZ Pausable was measured at about 450 B more bytecode, so the flag is a plain bool packed with treasury.

WorkHistory recorder review

  • setRecorder(market, false) and any revert inside record are caught (WorkHistoryRecordFailed), and the payout stands.
  • A recorder that burns all its gas only gets the fixed 800k.
  • Return data isn't copied (a try with no returns clause and an empty catch).
  • InsufficientGas only means the caller sent too little gas; the call, including Kleros' ruling execution, can be repeated with more.
  • Fixed: a WorkHistory address without code would slip past the try: the empty return data makes the call revert outside the catch, which would block every settlement. The constructor now calls recordCount() and requires code, a successful call and one 32-byte word back; It also requires WorkHistory's owner() to be the Market's governance. Otherwise it reverts BadWorkHistory, which rejects an EOA, a contract with an empty fallback such as a Safe, a wrong contract, a WorkHistory owned by another address, and a look-alike that answers recordCount() but has an empty fallback. These are constructor-only checks with 0 runtime bytes; DeployPhase1 already deploys WorkHistory owned by the same governance. The address is immutable, and WorkHistory has no selfdestruct and no upgrade path.

Ownership

  • renounceOwnership() now reverts RenounceDisabled() on every Ownable contract: TaskulerMarket, WorkHistory, ReviewerRegistry, BuilderBonus and LiquidityReserve (TSKR and the vesting vaults have no owner). Ownership only moves through the two-step transfer, so the owner-only safety controls can't be lost.

Versioned redeploy runbook

New docs/VERSIONED-REDEPLOY-RUNBOOK.md, linked from DEPLOY-RUNBOOK.md. It covers:

  • trigger and decision
  • pausing the old Market
  • comms timeline and templates
  • wind-down on the old contract (including the KI-8 note that multi-round disputes have no timeout)
  • dependents to re-point
  • Kleros whitelist and dispute template
  • Ponder/API cutover
  • the Safe transaction checklist
  • verification and rollback

Runbook notes added in review: the current Arbitrum Sepolia set is the ae943b1 deploy (Market 0x1B8B23CE442922Cb2629E2A4898C5b7cC44a6AD5, BuilderBonus 0x229aE95602e6E62b32022cdB2d2B9c1903091473; record on PR #14); the old Market stays whitelisted at Kleros until its wind-down is complete (pre-pause bids can still be accepted and disputed); when (normally never) to zero the old BuilderBonus minBounty, and that doing so also releases honest reserved slots (KI-14); the deploy-only script does not exist yet (23c); the dispute check needs a Delivered job and real ETH.

Immutable dependencies found:

  • BuilderBonus.market is immutable, so a new Market needs a new BuilderBonus. The old program's returnExcess keeps the budget for unused slots, and the new one starts again at 5,000 slots with no bars or exclusions carried over (new KI-14, OPEN-QUESTIONS 23a). BuilderBonus has no pause of its own (agreed). Follow-up PR #16 makes BuilderBonus repointable instead.
  • TaskulerMarket.reviewerRegistry and workHistory are immutable on the Market, but neither contract is bound to a Market. Reuse both: setRecorder for the new Market, and revoke the old one only after wind-down.
  • TSKR, the vesting vaults, their beneficiaries and the LiquidityReserve don't reference the Market and stay unchanged. The rewards distributor re-points its transfers to the new BuilderBonus.
  • DeployPhase1.s.sol deploys a full new set, so it must not be used for a versioned redeploy. A dedicated script is still to be written (OPEN-QUESTIONS 23c).

ABI changes

  • TaskulerMarket gains:
    • functions pause(), unpause(), paused()
    • events Paused(address) (topic0 0x62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258) and Unpaused(address) (topic0 0x5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa)
    • error EnforcedPause()
  • Existing selectors and events are unchanged.
  • Errors BadWorkHistory() (Market constructor) and RenounceDisabled() (all five Ownable contracts; renounceOwnership() keeps its selector but always reverts).

Tests

  • New test/CircuitBreaker.t.sol (17 tests):
    • access control, including a pending owner; events and idempotence; unpause is immediate
    • value-in matrix (USDC, ETH, project and Safe jobs)
    • governance still works while paused
    • every in-flight lifecycle finishes while paused and the Market drains to zero
    • fuzz: settlement results are identical paused or not
    • recorder failure modes: revoked, reverting, gas-burning, return-bomb, codeless; retrying a low-gas ruling
    • constructor rejects a WorkHistory that is address(0), an EOA, an empty-fallback contract, a token, a reverting contract, one owned by another address, or a recordCount()-plus-empty-fallback contract (BadWorkHistory)
    • renounceOwnership reverts on all five Ownable contracts
  • The Market invariant handler now flips the breaker, and a new invariant NoEscrowInflowWhilePaused checks that no call made while paused adds to escrow.
  • Full forge test with the fork RPC set: 272 passed, 0 failed, 0 skipped (including the 5 fork tests).

Size

TaskulerMarket runtime is 24,146 B, 430 B under the 24,576 B limit (+206 B vs main). No logic moved into the libraries.

Docs updated: KNOWN-ISSUES (KI-3, new KI-13 and KI-14), THREAT-MODEL, AUDIT-SCOPE (Market 1327/925, total 2661/1751), SECURITY-NOTES, OPEN-QUESTIONS 23, README.

Approved scope (2026-11-13): circuit breaker on TaskulerMarket and a runbook for shipping a fixed Market after launch. No deployment in this PR. ## Circuit breaker - `pause()` / `unpause()`, `onlyOwner` (the governance Safe). Events `Paused(address account)` / `Unpaused(address account)` (same signatures as OZ `Pausable`), view `paused()`, error `EnforcedPause()`. Both calls are idempotent. Non-upgradeable as before. - **Blocked while paused (new value-in):** `postJob`, `postProjectJob`, `placeBid`, `assignReviewer`. The check is in `_pull`, the only function that increases `jobHeld`, so a future value-in path can't skip it. - **Allowed while paused:** `cancelJob`, `withdrawBid`, `acceptBid` (existing bids), `submitDelivery`, `acceptDelivery`, `releaseAfterReview`, `refundAfterDeadline`, every settlement offer call, `submitRecommendation`, `reassignReviewer`, `executeRecommendation`, `requestArbitration`, `rule`, `resolveStalledDispute`, `withdraw`, and every owner setting including OFAC holds. - **Design choices:** - New bids are blocked because each one escrows a new deposit. - Accepting an existing bid stays allowed: it adds no value (it only refunds the price difference) and lets jobs that are already escrowed go ahead. A customer whose job has no acceptable bid cancels for a full refund. - `requestArbitration` stays open: its ETH goes straight to Kleros in the same call, and it is the only exit for escalated and lapsed-review jobs. - Unpause is immediate like pause. It moves no funds, the Safe can already change new-job parameters instantly (KI-6), and a delay would slow a rollback. - **Who can pause: DECIDED 2026-11-13:** only the Safe; no separate pause-only key (OPEN-QUESTIONS 23b, KI-13). - OZ `Pausable` was measured at about 450 B more bytecode, so the flag is a plain bool packed with `treasury`. ## WorkHistory recorder review - `setRecorder(market, false)` and any revert inside `record` are caught (`WorkHistoryRecordFailed`), and the payout stands. - A recorder that burns all its gas only gets the fixed 800k. - Return data isn't copied (a `try` with no `returns` clause and an empty `catch`). - `InsufficientGas` only means the caller sent too little gas; the call, including Kleros' ruling execution, can be repeated with more. - **Fixed:** a WorkHistory address without code would slip past the `try`: the empty return data makes the call revert outside the `catch`, which would block every settlement. The constructor now calls `recordCount()` and requires code, a successful call and one 32-byte word back; It also requires WorkHistory's `owner()` to be the Market's governance. Otherwise it reverts `BadWorkHistory`, which rejects an EOA, a contract with an empty fallback such as a Safe, a wrong contract, a WorkHistory owned by another address, and a look-alike that answers `recordCount()` but has an empty fallback. These are constructor-only checks with 0 runtime bytes; `DeployPhase1` already deploys WorkHistory owned by the same governance. The address is immutable, and WorkHistory has no selfdestruct and no upgrade path. ## Ownership - `renounceOwnership()` now reverts `RenounceDisabled()` on every Ownable contract: TaskulerMarket, WorkHistory, ReviewerRegistry, BuilderBonus and LiquidityReserve (TSKR and the vesting vaults have no owner). Ownership only moves through the two-step transfer, so the owner-only safety controls can't be lost. ## Versioned redeploy runbook New `docs/VERSIONED-REDEPLOY-RUNBOOK.md`, linked from `DEPLOY-RUNBOOK.md`. It covers: - trigger and decision - pausing the old Market - comms timeline and templates - wind-down on the old contract (including the KI-8 note that multi-round disputes have no timeout) - dependents to re-point - Kleros whitelist and dispute template - Ponder/API cutover - the Safe transaction checklist - verification and rollback Runbook notes added in review: the current Arbitrum Sepolia set is the ae943b1 deploy (Market `0x1B8B23CE442922Cb2629E2A4898C5b7cC44a6AD5`, BuilderBonus `0x229aE95602e6E62b32022cdB2d2B9c1903091473`; record on PR #14); the old Market stays whitelisted at Kleros until its wind-down is complete (pre-pause bids can still be accepted and disputed); when (normally never) to zero the old BuilderBonus `minBounty`, and that doing so also releases honest reserved slots (KI-14); the deploy-only script does not exist yet (23c); the dispute check needs a Delivered job and real ETH. Immutable dependencies found: - **`BuilderBonus.market`** is immutable, so a new Market needs a new BuilderBonus. The old program's `returnExcess` keeps the budget for unused slots, and the new one starts again at 5,000 slots with no bars or exclusions carried over (new KI-14, OPEN-QUESTIONS 23a). BuilderBonus has no pause of its own (agreed). Follow-up PR #16 makes BuilderBonus repointable instead. - **`TaskulerMarket.reviewerRegistry`** and **`workHistory`** are immutable on the Market, but neither contract is bound to a Market. Reuse both: `setRecorder` for the new Market, and revoke the old one only after wind-down. - **TSKR, the vesting vaults, their beneficiaries and the LiquidityReserve** don't reference the Market and stay unchanged. The rewards distributor re-points its transfers to the new BuilderBonus. - `DeployPhase1.s.sol` deploys a full new set, so it must not be used for a versioned redeploy. A dedicated script is still to be written (OPEN-QUESTIONS 23c). ## ABI changes - TaskulerMarket gains: - functions `pause()`, `unpause()`, `paused()` - events `Paused(address)` (topic0 `0x62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258`) and `Unpaused(address)` (topic0 `0x5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa`) - error `EnforcedPause()` - Existing selectors and events are unchanged. - Errors `BadWorkHistory()` (Market constructor) and `RenounceDisabled()` (all five Ownable contracts; `renounceOwnership()` keeps its selector but always reverts). ## Tests - New `test/CircuitBreaker.t.sol` (17 tests): - access control, including a pending owner; events and idempotence; unpause is immediate - value-in matrix (USDC, ETH, project and Safe jobs) - governance still works while paused - every in-flight lifecycle finishes while paused and the Market drains to zero - fuzz: settlement results are identical paused or not - recorder failure modes: revoked, reverting, gas-burning, return-bomb, codeless; retrying a low-gas ruling - constructor rejects a WorkHistory that is address(0), an EOA, an empty-fallback contract, a token, a reverting contract, one owned by another address, or a `recordCount()`-plus-empty-fallback contract (`BadWorkHistory`) - `renounceOwnership` reverts on all five Ownable contracts - The Market invariant handler now flips the breaker, and a new invariant `NoEscrowInflowWhilePaused` checks that no call made while paused adds to escrow. - Full `forge test` with the fork RPC set: **272 passed, 0 failed, 0 skipped** (including the 5 fork tests). ## Size TaskulerMarket runtime is 24,146 B, 430 B under the 24,576 B limit (+206 B vs main). No logic moved into the libraries. Docs updated: KNOWN-ISSUES (KI-3, new KI-13 and KI-14), THREAT-MODEL, AUDIT-SCOPE (Market 1327/925, total 2661/1751), SECURITY-NOTES, OPEN-QUESTIONS 23, README.
- TaskulerMarket: owner-controlled pause()/unpause() (events Paused/Unpaused, error EnforcedPause); while paused,
  postJob, postProjectJob, placeBid and assignReviewer revert; every other path, including disputes and withdrawals,
  is unchanged
- Constructor requires the WorkHistory address to have code
- Tests: paused-state matrix, in-flight lifecycles under pause, access control and events, recorder failure modes,
  invariant handler flips the breaker
- docs: VERSIONED-REDEPLOY-RUNBOOK (linked from DEPLOY-RUNBOOK), KNOWN-ISSUES KI-3/KI-13/KI-14, THREAT-MODEL,
  AUDIT-SCOPE, SECURITY-NOTES, OPEN-QUESTIONS 23, README
- TaskulerMarket constructor: WorkHistory must answer recordCount() with one word (error BadWorkHistory)
- renounceOwnership reverts (RenounceDisabled) on TaskulerMarket, WorkHistory, ReviewerRegistry, BuilderBonus and
  LiquidityReserve
- Tests for both
- Runbook: Kleros whitelist kept until wind-down completes, deploy-only script not yet written, old BuilderBonus
  minBounty guidance, dispute check needs a Delivered job and ETH; current Sepolia deploy referenced (ae943b1, PR #14)
- KI-13 / OPEN-QUESTIONS 23b: pause stays Safe-only (decided); KI-14: zeroing minBounty also releases in-flight slots
george approved these changes 2026-11-13 22:06:35 +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!15
No description provided.