In the previous lesson, we added 4 console logs for Task, Submission, Audit, and Distribution. These are the four main parts of a Koii task:
- Do the work
- Submit the results
- Verify the work
- Distribute rewards and penalties
This ensures that each node operator has an incentive to act honestly and perform the task correctly. Their work will be checked, and if they don't perform the task correctly, they will not only miss out on rewards, they could lose some or all of their staked KOII.
When writing a task, you're able to customize each step: what work you want done, what should be submitted as proof, how that proof should be checked, and what rewards and penalties you want to set.
Tip
For a more in-depth explanation of how Koii Tasks run, see our docs on runtime flow and gradual consensus.
Now let's see how runtime flow works in the EZ Testing example.
This task simply saves the string "Hello, World!" to the local database
Submission.fetchSubmission()
and Submission.sendTask()
.
In this case, we are fetching the string from the local database and submitting it.
Here we are verifying whether the submission is the string "Hello, World!".
Inside Distribution.generateDistributionList()
.
Rewards are distributed to each node that completed the work. Here we are penalizing incorrect submissions by removing 70% of their stake and equally distributing the bounty per round to all successful submissions.
When developing your task, you'll want to iterate quickly, and having to deploy a task or launch the desktop node can be a hassle. We've provided a simple solution in the form of a testing script that will allow you to simulate rounds and test your task functionality. The script is available in tests/unitTest.js
and you can run it via yarn test
.
Now that we've seen how tasks work, let's deploy one. PartIV