Skip to content

Task lifecycle

OCH-1.1 separates bid selection from bond activation. This keeps reward escrow, key delivery, bond custody, and the compute window aligned with explicit state transitions.

OPEN -> SELECTED -> ACTIVE -> COMPLETED
OPEN -> CANCELLED
SELECTED -> OPEN
ACTIVE -> TIMED_OUT

The delegator calls:

createTask(
bytes32 specHash,
bytes32 verifierId,
bytes32 inputHash,
uint256 maxRewardUSDC,
uint256 minBondUSDC,
uint64 acceptDeadline,
uint64 maxComputeWindowSec,
string specURI
)

The hub confirms that the verifier registry has an active, ID-consistent verifier. It snapshots the verifier address and runtime code hash, transfers maxRewardUSDC into escrow, and creates the task in OPEN state.

The TaskCreated event exposes the new taskId and the task’s commitments. Delegatees use that taskId to prepare signed bids.

Before acceptDeadline, the delegator calls selectBid(taskId, bid, delegateeSig, encryptedKey). The hub validates the signed bid and moves the task to SELECTED.

Selection also:

  • snapshots globalFeeBps as feeBpsSnapshot;
  • sets activateDeadline = selectedAt + 900 seconds;
  • records the delegatee, reward, bond, and compute window;
  • emits the encrypted key for the selected delegatee; and
  • refunds escrowedRewardUSDC - rewardUSDC to the delegator immediately.

After selection, escrowedRewardUSDC equals the chosen rewardUSDC. The delegatee’s bond remains under the delegatee’s control until activation.

The selected delegatee calls activateTask(taskId) on or before activateDeadline. The hub transfers bondUSDC from the delegatee, changes the state to ACTIVE, and sets:

submitDeadline = activatedAt + computeWindowSec

Activation is the slashability boundary: the bond and submission clock begin together through the same transaction.

On or before submitDeadline, the selected delegatee calls:

submitResult(taskId, proof, publicValues, outputURI)

The hub checks the task’s escrow invariant, the static public-value commitments, the snapshotted verifier code, and the proof. On success it:

  1. changes the state to COMPLETED;
  2. stores the proved outputHash;
  3. accrues rewardUSDC * feeBpsSnapshot / 10_000 to pendingTreasuryFees;
  4. pays rewardUSDC - fee plus the full bond to the delegatee; and
  5. emits TaskCompleted with the full publicValues and outputURI.

Read Proof binding for the exact commitment checks.

Current state Call Authorized caller and timing Result
OPEN cancelUnaccepted(taskId) Delegator CANCELLED; current reward escrow returns to the delegator.
OPEN sweepExpiredOpen(taskId) Any caller after acceptDeadline CANCELLED; current reward escrow returns to the delegator.
SELECTED cancelSelection(taskId) Delegator, or any caller after activateDeadline OPEN; selection fields clear and current escrow stays with the task for reselection.
ACTIVE claimTimeout(taskId) Any caller after submitDeadline TIMED_OUT; reward escrow and the full bond pay to the delegator.

The pause control preserves settlement continuity: active delegatees can submit results, and task exit calls remain available, while new creation, selection, and activation wait for the hub to resume.