IRONQ

Job Lifecycle

Create, claim, submit, approve, dispute, and resolve jobs

create_job

Escrows a reward and creates a new Job PDA.

Parameters:

ParamTypeDescription
reward_amountu64Tokens to escrow (must be > 0)
data_hash[u8; 32]Blake3 hash of the off-chain job payload
priorityu80=Low, 1=Medium, 2=High
max_retriesu8Re-open count after expiry

Effects:

  • Creates Job PDA at ["job", queue, job_id_le_bytes]
  • Transfers reward_amount to vault
  • Increments total_jobs_created on queue
  • Status: Open

cancel_job

Cancels an unclaimed job and returns the reward.

Requirements: Job must be in Open status. Only the creator can cancel.

Effects:

  • Returns reward_amount from vault to creator's token account
  • Status: Cancelled (terminal)

claim_job

Worker claims an open job, starting the deadline timer.

Requirements:

  • Job must be Open
  • Worker must be registered and active
  • Worker's active_jobs < max_concurrent_jobs
  • Queue must not be paused

Effects:

  • Sets worker, claimed_at, deadline on the Job
  • Increments active_jobs on Worker
  • Status: Claimed

submit_result

Worker submits a result hash for a claimed job.

Parameters:

ParamTypeDescription
result_hash[u8; 32]Hash of the off-chain result

Requirements: Job must be Claimed. Only the assigned worker can submit.

Effects:

  • Creates JobResult PDA at ["result", job]
  • Status: Submitted

approve_result

Creator approves the submitted result, releasing the reward.

Requirements: Job must be Submitted. Only the creator can approve.

Effects:

  • Transfers reward_amount from vault to worker's token account
  • Increments jobs_completed and total_earned on Worker
  • Decrements active_jobs on Worker
  • Status: Completed (terminal)

dispute_result

Creator disputes the submitted result, escalating to the arbiter.

Requirements: Job must be Submitted. Only the creator can dispute.

Effects:

  • Status: Disputed

resolve_dispute

Arbiter rules on a disputed job.

Parameters:

ParamTypeDescription
worker_winsboolWhether the worker's result is accepted

If worker wins:

  • Reward released to worker
  • jobs_completed incremented
  • Status: Completed

If worker loses:

  • Worker slashed: slash_amount = stake * slash_rate_bps / 10000
  • Full slash_amount returned to creator (plus reward)
  • jobs_failed incremented
  • Status: Expired