diff --git a/config-task.yml b/config-task.yml index f1d639ef..2cf6e3ba 100644 --- a/config-task.yml +++ b/config-task.yml @@ -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 @@ -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 @@ -26,24 +26,24 @@ 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 @@ -51,7 +51,7 @@ requirementsTags: 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 diff --git a/coreLogic.js b/coreLogic.js index 2b1a0a58..70ec418b 100644 --- a/coreLogic.js +++ b/coreLogic.js @@ -3,8 +3,7 @@ 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 { @@ -12,26 +11,22 @@ class CoreLogic { 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; } @@ -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); @@ -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]; @@ -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]; @@ -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'); @@ -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 @@ -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; } @@ -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); @@ -215,7 +210,7 @@ class CoreLogic { _dummyTaskState, ); - // compare distribution list + // Compare distribution lists const parsed = fetchedDistributionList; console.log( @@ -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'); @@ -274,4 +270,4 @@ class CoreLogic { } const coreLogic = new CoreLogic(); -module.exports = { coreLogic }; +module.exports = { coreLogic }; \ No newline at end of file