Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected typos found #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions config-task.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#Provide the taskId if you are updating the task
# Provide the taskId if you are updating the task
task_id: ''
# Name and desciption of your task
# Name and description of your task
task_name: 'Your-task-name'
task_description: 'This task is to test out the namespace function'

# network value can be DEVELOPMENT , ARWEAVE or IPFS
# Network value can be DEVELOPMENT, ARWEAVE or IPFS
task_executable_network: 'DEVELOPMENT'

# Provide your web3.storage key as it is needed for uploading your metadata
Expand All @@ -16,7 +16,7 @@ task_audit_program: ''
# Provide your transaction ID in case of ARWEAVE and in case of DEVELOPMENT give your executable name as main otherwise leave blank
task_audit_program_id: 'main'

# Total round time of your task : it must be given in slots and each slot is rougly equal to 4ms
# Total round time of your task: it must be given in slots and each slot is roughly equal to 4ms
round_time: 600

audit_window: 200
Expand All @@ -26,32 +26,32 @@ submission_window: 200

minimum_stake_amount: 5

# total_bounty_amount cannot be grater than bounty_amount_per_round
# total bounty is not accepted in case of update task
# Total_bounty_amount cannot be greater than bounty_amount_per_round
# Total bounty is not accepted in case of updating a task
total_bounty_amount: 10

bounty_amount_per_round: 1

#Number of times allowed to re-submit the distribution list in case the distribution list is audited
# Number of times allowed to re-submit the distribution list in case the distribution list is audited
allowed_failed_distributions: 3

#Space in MBs
space: 1

# Note that the value field in RequirementTag is optional, so it is up to you to include it or not based on your use case.
# To add more global variables and task variables, please refer the type,value,description format shown below
# To add more global variables and task variables, please refer to the type, value, and description format shown below

author: 'Your name'
description: 'task-description'
repositoryUrl: 'Github/gitlab link'
repositoryUrl: 'Github/Gitlab link'
imageUrl: 'Enter you image URL'
requirementsTags:
- type: TASK_VARIABLE
value: SECRET_WEB3_STORAGE_KEY
description: 'used to connect web3.storage'
- type: TASK_VARIABLE
value: 'SCRAPING_URL'
description: 'url from which you want to scrape'
description: 'URL from which you want to scrape'
- type: CPU
value: '4-core'
- type: RAM
Expand Down
44 changes: 20 additions & 24 deletions coreLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,30 @@ const crypto = require('crypto');

class CoreLogic {
async task() {
// Write the logic to do the work required for submitting the values and optionally store the result in levelDB

// Write the logic required to complete the task. Work results (submission value) can be optionally stored on NeDB.
// Below is just a sample of work that a task can do

try {
const x = Math.random().toString(); // generate random number and convert to string
const cid = crypto.createHash('sha1').update(x).digest('hex'); // convert to CID
console.log('HASH:', cid);

// fetching round number to store work accordingly

if (cid) {
await namespaceWrapper.storeSet('cid', cid); // store CID in levelDB
await namespaceWrapper.storeSet('cid', cid); // store CID on NeDB
}
} catch (err) {
console.log('ERROR IN EXECUTING TASK', err);
}
}
async fetchSubmission() {
// Write the logic to fetch the submission values here and return the cid string

// fetching round number to store work accordingly

async fetchSubmission() {
// Write the logic to fetch the submission value here
console.log('IN FETCH SUBMISSION');

// The code below shows how you can fetch your stored value from level DB

const cid = await namespaceWrapper.storeGet('cid'); // retrieves the cid
// The code below shows how you can fetch your stored value from NeDB
const cid = await namespaceWrapper.storeGet('cid'); // retrieves the submission value
console.log('CID', cid);

return cid;
}

Expand All @@ -52,7 +47,7 @@ class CoreLogic {
const submissions_audit_trigger =
taskAccountDataJSON.submissions_audit_trigger[round];
if (submissions == null) {
console.log('No submisssions found in N-2 round');
console.log('No submissions found in N-2 round');
return distributionList;
} else {
const keys = Object.keys(submissions);
Expand All @@ -74,7 +69,7 @@ class CoreLogic {
const votes = submissions_audit_trigger[candidatePublicKey].votes;
if (votes.length === 0) {
// slash 70% of the stake as still the audit is triggered but no votes are casted
// Note that the votes are on the basis of the submission value
// Note that the votes are based on the submission value
// to do so we need to fetch the stakes of the candidate from the task state
const stake_list = taskAccountDataJSON.stake_list;
const candidateStake = stake_list[candidatePublicKey];
Expand All @@ -89,8 +84,8 @@ class CoreLogic {
}

if (numOfVotes < 0) {
// slash 70% of the stake as the number of false votes are more than the number of true votes
// Note that the votes are on the basis of the submission value
// slash 70% of the stake as the number of false votes is more than the number of true votes
// Note that the votes are based on the submission value
// to do so we need to fetch the stakes of the candidate from the task state
const stake_list = taskAccountDataJSON.stake_list;
const candidateStake = stake_list[candidatePublicKey];
Expand Down Expand Up @@ -127,7 +122,7 @@ class CoreLogic {
}

async submitDistributionList(round) {
// This function just upload your generated dustribution List and do the transaction for that
// This function uploads the generated distribution list to K2

console.log('SubmitDistributionList called');

Expand All @@ -151,7 +146,7 @@ class CoreLogic {
}

async validateNode(submission_value, round) {
// Write your logic for the validation of submission value here and return a boolean value in response
// Write your logic for the validation of the submission value here and return a boolean value in response

// The sample logic can be something like mentioned below to validate the submission

Expand All @@ -170,7 +165,7 @@ class CoreLogic {
// return false;
// }

// For succesfull flow we return true for now
// For successful flow we return true for now
return true;
}

Expand All @@ -194,8 +189,8 @@ class CoreLogic {
_dummyDistributionList,
_dummyTaskState,
) => {
// Write your logic for the validation of submission value here and return a boolean value in response
// this logic can be same as generation of distribution list function and based on the comparision will final object , decision can be made
// Write your logic for the validation of the distribution list here and return a boolean value in response
// This logic can be the same as the generation of distribution list function and based on the comparison of both lists, a decision can be made

try {
console.log('Distribution list Submitter', distributionListSubmitter);
Expand All @@ -215,7 +210,7 @@ class CoreLogic {
_dummyTaskState,
);

// compare distribution list
// Compare distribution lists

const parsed = fetchedDistributionList;
console.log(
Expand All @@ -231,8 +226,9 @@ class CoreLogic {
return false;
}
};
// Submit Address with distributioon list to K2

async submitTask(roundNumber) {
// This function uploads the submission value to K2
console.log('submitTask called with round', roundNumber);
try {
console.log('inside try');
Expand Down Expand Up @@ -274,4 +270,4 @@ class CoreLogic {
}
const coreLogic = new CoreLogic();

module.exports = { coreLogic };
module.exports = { coreLogic };