(Node.js version v8.9.3
. npm verison 5.5.1
)
Clone the repo :
git clone https://github.com/SagarB-97/ColabIt.git
cd ColabIt
- Install dependencies
cd peerserver
npm install
- Run server
node index.js
Run the following in the repository's root
- Install dependencies :
npm install
- Start the application :
npm start
The platform can be used to distribute tasks that require enormous number of CPU cycles. The task can be distributed such that each executor (or volunteer) performs the task task in parallel and returns the calculated output to the submitter (until the incentivisation layer is integrated).
-
Open browser and go to
http://localhost:3000/
and chooseSubmit Task
-
Enter Task title and the javascript function (See below).
-
Hit Submit. A peer is registered and it starts waiting for executors to connect to it.
-
Enter batch size and Input. Input format is :
{
"Input": [/*Your array of input JSONs*/]
}
This is the function that each executor executes in parallel. The submitter divides the entire input into smaller arrays of Batch Size
each and each executor is sent its share of input.
Assumption : Assume the variable input
contains the json object that the executor receives.
The plaform takes care of :
- Scaling up as the number of executors connected increases. That is, the throughput is proportional to the number of connected executors.
- Giving an executor more input as soon as it signals completion of its allotted batch. This way the more competent executors (with higher computational power) can contribute more.
An example problem that the platform can be used to solve is Factorisation of a large number.
The javascript function for this problem is :
obj = input;
factor = [];
outArr = [];
for(var k = obj.start; k <= obj.end && k * k <= obj.num; k++) {
if(obj.num % k == 0) {
factor.push(k);
factor.push(obj.num / k);
}
}
outArr.push({Factor: factor});
return {output: outArr};
The input to find factors of 123456789123456800000
can be :
{
"Input": [
{
"start": 1,
"end": 100000000,
"num": 123456789123456800000
},
{
"start": 100000001,
"end": 200000000,
"num": 123456789123456800000
},
...
...
...
{
"start": 11100000001,
"end": 11200000000,
"num": 123456789123456800000
}
]
}
The entire input and a script to generate the input is provided in the Examples
folder.
An Ethereum Blockchain has been used for the verification and incentivization. A test Blockchain can be created using Ganache. The Truffle framework is used to compile and deploy the smart contract to the Blockchain.
Run Ganache (CLI or GUI)
Then, edit the host and port values in smart_contracts/truffle-config.js
to point to where the Ganache Blockchain is running.
cd smart_contracts
vim truffle-config.js
Then compile the smart contract and deploy it to the Blockchain
truffle compile --reset --all
truffle migrate --reset --all
truffle migrate
will return the address of the deployed smart contract. Replace the address in the line VerifyContract.at(address)
with this address in the executor_connected.ejs
and the submitter_connected.ejs
files. A quick ctrl+f
should do the trick.
This should be done every time the contract code is modified.