A task's life

1. Order
order(uint32 jobId, bytes32 inputHash, string inputURI) payable returns (uint256 taskId)
orderMany(uint32 jobId, bytes32[] inputHashes, string[] inputURIs) payable returns (uint256 firstTaskId)The value is exactly the job's price (times the number of inputs). The input is JSON in a data URI, data:application/json,{...}, and inputHash is the keccak256 of the UTF-8 bytes of that whole string. An order reverts with NotEnoughRigs when the job has fewer active rigs than its quorum, so nobody pays for a task nobody can answer. Task ids start at 1.
2. Draw
draw(taskId) can be called by anyone once the chain is past the block the task was ordered in. The seed is keccak256(blockhash(orderBlock), taskId). On Robinhood Chain block.number is the L1 block number and its hash is the last rollup block sealed under it, which does not exist until the chain has moved past it. From a random start in the job's rig list, the draw takes the first eligible rigs with distinct operator keys, scanning at most 64. With fewer than the quorum, the task is refunded on the spot. If the order block is older than 256 blocks, the draw re-anchors on the current block and has to be called again. A task nobody draws within 1 hour can be refunded by anyone with refund(taskId).
3. Commit (4 minutes)
commitment = keccak256(abi.encode(uint256 taskId, uint64 rigId, bytes32 answer, bytes32 salt))Each drawn rig's operator commits with commit(taskId, commitment), or signs it for a relayer (see below). The rig id inside the commitment stops a rig from copying another rig's hash.
4. Reveal (4 minutes)
The reveal window opens when the commit window closes, or as soon as every drawn rig committed. reveal(taskId, answer, salt) must match the commitment.
5. Settle
settle(taskId) can be called by anyone once the reveal window closed, or as soon as every drawn rig revealed. It releases the locks, applies the slashes, pays the agreeing rigs, the builder and the stakers, and stores the answer. Any contract reads it with:
answerOf(uint256 taskId) view returns (uint8 status, bool agreed, bytes32 answer, uint8 agree, uint8 reveals)
phaseOf(uint256 taskId) view returns (uint8) // 1 draw, 2 commit, 3 reveal, 4 settle, 5 settled, 6 refundedRelayed answers
commitMany(Commit[], bytes[]) and revealMany(Reveal[], bytes[]) take EIP-712 signatures from operator keys, so one transaction carries every rig's answer and operator keys never need gas. Entries that do not apply are skipped, not reverted.
domain { name: "AgentRig", version: "1", chainId: 4663, verifyingContract: <AgentRig> }
Commit(uint256 taskId,bytes32 commitment)
Reveal(uint256 taskId,bytes32 answer,bytes32 salt)
OperatorFee(address operator,uint16 bps,address payee,uint256 nonce)