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.
State machine
Section titled “State machine”OPEN -> SELECTED -> ACTIVE -> COMPLETEDOPEN -> CANCELLEDSELECTED -> OPENACTIVE -> TIMED_OUT1. Create an open task
Section titled “1. Create an open task”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.
2. Select a bid
Section titled “2. Select a bid”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
globalFeeBpsasfeeBpsSnapshot; - sets
activateDeadline = selectedAt + 900seconds; - records the delegatee, reward, bond, and compute window;
- emits the encrypted key for the selected delegatee; and
- refunds
escrowedRewardUSDC - rewardUSDCto the delegator immediately.
After selection, escrowedRewardUSDC equals the chosen rewardUSDC. The delegatee’s bond remains under the delegatee’s control until activation.
3. Activate the task
Section titled “3. Activate the task”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 + computeWindowSecActivation is the slashability boundary: the bond and submission clock begin together through the same transaction.
4. Submit and settle
Section titled “4. Submit and settle”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:
- changes the state to
COMPLETED; - stores the proved
outputHash; - accrues
rewardUSDC * feeBpsSnapshot / 10_000topendingTreasuryFees; - pays
rewardUSDC - feeplus the full bond to the delegatee; and - emits
TaskCompletedwith the fullpublicValuesandoutputURI.
Read Proof binding for the exact commitment checks.
Exit paths
Section titled “Exit paths”| 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.