Eclipsed

First morning first Disquieting, uncertain, mystifying Wandering distracted so as not to be forced to focus The decrepit leaden layers Asbestos old to disassemble and disintegrate Wondering when to…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Blockchain Engine for Decentralized Super Computing

The human brain weighs about 3 pounds, and consists of approximately 100 billion neurons, creating a complex neural-network of 100 trillion connections. This gives the human brain the cognitive power to process information far more efficiently than the fastest supercomputers ever built.

Blockchain Engine for Decentralized Super Computing

Human brains are also immensely energy-efficient, using about 100,000 times less energy than a computer. In fact, the complexity of the entire World-Wide-Web, with about 17 Billion internet-connected devices, can only be compared to the socket circuitry of a single human brain.

There’s a growing need for a new breed of computers that are exponentially fast and also energy efficient.

Your current desktop computer works just fine when handling basic tasks like simple arithmetics, internet search, document processing, and video streaming. But your PC’s computing power isn’t good enough to tackle some of the world’s most complex scientific problems. Some math problems could take a desktop computer tens of thousands of years to resolve.

A simple example would be if your computer was tasked with finding the 52nd perfect number. This sounds like a simple task, but it could take your computer 50,000 years or more to find this number. A perfect number is a positive integer that is equal to the sum of its positive divisors (factors). 6 is a perfect number because its factors 1, 2, and 3 add to 6. The 51st perfect number, which is also the largest perfect number known to man, is (2⁸²⁵⁸⁹⁹³²)(2⁸²⁵⁸⁹⁹³³-1) and has 49,724,095 digits.

The process of investigating such numbers that have hundreds of thousands of digits or more is a daunting task for even a super computer, let alone a desktop computer. Handling these gigantic figures would drain your computer’s resources before arriving at a solution. That’s why super computers are so vital to modern scientific research.

The particles that make up the fabric of life, matter, and the universe are equally as complex as the properties of perfect numbers. More so in the fields of Life sciences, Nuclear research, Atomic physics, Material sciences, Particle physics, Artificial Intelligence (AI) and Machine Learning (ML).

Now that we know why super computers are essential to the 21st-century economy, let’s see where current super computers fall short.

Renting native super computers isn’t cheap either, especially for lengthy amounts of research. Super computing prices can quickly rise to millions of dollars, too expensive for low budget researchers.

‘Centralized’ super computers also come with futuristic limitations. Among others the ever-increasing costs of microprocessor design, not forgetting the drawbacks of Moore’s law.

A Blockchain computer is a decentralized network of computing devices across the world working collectively in a peer-to-peer network to accomplish a given task. By its very nature, a blockchain computer avoids almost all the limitations of native super computers.

Computing resources, especially energy, are shared between the different nodes (computers) of the blockchain network. The mantle for providing computing power doesn’t fall solely on a single device, hence boasting energy-efficiency.

To achieve decentralized super computing, we’ll be deploying distributed programming and recursive design techniques.

Distributed Recursive programming is the backbone of our decentralized super computing system. It involves breaking down a computer’s task into a chain of events that can be executed independently and concurrently by the different decentralized nodes of the blockchain network until a solution is found or the task is terminated.

You could say Distributed Recursive Programming is the engine of our Blockchain Computer.
OK then, let’s get technical.

Let’s build our first blockchain super computer program.
We are going to create a very simple blockchain ‘super computer’ program that prompts every device in the blockchain network to print “Hello World”. When 10,000 messages are written, the chain will terminate.

From here onward, I'll assume you have experience working with JavaScript, Node.js, Express, NPM, Socket.io, DotEnv, and the Command Line Interface. I’ll also assume that you have an understanding of Distributed computing and Recursive programming.

Download and install Node.js onto your computer.
For the latest versions of Nodejs, NPM, the package manager, comes preinstalled. So don’t worry about re-installing it.
Open the Node.js command prompt terminal and create a new folder for your project by running the command below.

Then we initialize our project by running the command below in the terminal prompt.

npm init

Fill in the required values and press enter to create a package.json file.
The results of your package.json file should look like below, depending on what values you filled during project initialization.

Now let’s install all the required dependency modules we mentioned earlier into our project.
To do this, run the command below in the Node.js prompt terminal.

npm install express dotenv socket.io — save

Our modules are now installed.
Moving on, Let’s create the server that will listen to and manage all the new decentralized nodes added to the blockchain network.

After installing our dependency modules, create a server file named index.js as defined in package.json.
Add the code below into that index.js file.

// Import dependencies
var app = require(‘express’)();
var http = require(‘http’).createServer(app);

// Define port
const PORT = 3000;

// Define client entry point
app.get(‘/’, function(req, res) {
res.send(‘Hello World’);
});

// listen to port
http.listen(PORT, function() {
console.log(‘listening on *:’ + PORT);
});

Now, let’s run our server to see that we’re going in the right direction.
Run the command below in the terminal prompt.

node index.js

You should see a message like ‘listening on *:3000’.
This basically means that our server is running well so far.
Open your browser and visit the URL http://localhost:3000/
You’ll see our “Hello World” message that we defined in our entry “/” endpoint.

Let’s replace the ‘Hello World’ message in our ‘/’ endpoint with an HTML User Interface (UI).
Replace it with the following code.

Our index.js server file will then look like below.

// Import dependencies
var app = require(‘express’)();
var http = require(‘http’).createServer(app);

// Define port
const PORT = 3000;

// listen to port
http.listen(PORT, function() {
console.log(‘listening on *:’ + PORT);
});

<!DOCTYPE html>
<html>
<head>
<title>Blockchain Super Computer</title>
<style>
.container {
width: 80%;
margin: 1rem auto;
}
.text-justify {
text-align: justify;
}
</style>
</head>
<body>
<div class=”container”>
<p class=”text-justify”>Blockchain Super Computer</p>
</div>
<div class=”container”>
<center>
<button id=”process-stop”> Start Processing </button>
<p id=”process-count”>0 Processes Executed</p>
</center>
</div>
</body>
</html>

Now start the server again by running the command ‘node index.js’ in the terminal prompt.
The server home page will redirect you to our new HTML page.
Our Blockchain Computer UI is ready.

Let’s import the socket.io module to enhance real-time client-server communication.
Update your index.js server with the following code.

// Import dependencies
require(‘dotenv’).config();
var app = require(‘express’)();
var http = require(‘http’).createServer(app);
var io = require(‘socket.io’)(http);
var Blockchain = require(‘./engine/index’);

// Define port
const PORT = 3000;

// listen to port
http.listen(PORT, function() {
console.log(‘listening on *:’ + PORT);
});

// Detect socket new connection
io.on(‘connection’, function(socket) {
console.log(‘a user has connected!’);

// Detect socket disconnections
socket.on(‘disconnect’, function() {
console.log(‘user disconnected’);
});

// Run blockchain engine if user clicks ‘start’
if(state==’true’) {

// Fetch process fragments and execute blockchain
// on each process

const getFragment = async function(offset=pivot){

// Set fragment for process transition
const setFragment =fulcrum;

// Create new instance of blockchain processor
const blockchain = new Blockchain(offset,offset+setFragment);

// Return results of fragment
return {
processor: blockchain.chain(),
nextFragment: (offset+setFragment)<terminate?(offset+setFragment):undefined
};
};

// Fetch next process
const getProcess = async function(offset=0){

// call fragment
const fragment = await getFragment(offset);

// If next fragment exists, execute recursively
if(fragment.nextFragment){

// Call getProcess
return await getProcess(fragment.nextFragment);
} else {}
}

// Run processor
getProcess()
.then((done) =>
console.log(done));

Notice the importation of the new socket.io module.
We’ll talk about the newly imported blockchain engine later.
Also, notice the importation of the ‘dotenv’ module. We’ll use it for handling our environment configuration variables.
Remember we earlier installed the ‘dotenv’ module in our project.
Now, create a .env file in the root of our project folder and add the following code to it.

Ok then, Let’s make the client UI know that our server socket is listening to any client requests.
Go to the /public folder and update index.html with the following code.

<!DOCTYPE html>
<html>
<head>
<title>Blockchain Super Computer</title>
<style>
.container {
width: 80%;
margin: 1rem auto;
}
.text-justify {
text-align: justify;
}
</style>
</head>
<body>
<div class=”container”>
<p class=”text-justify”>Blockchain Super Computer</p>
</div>
<div class=”container”>
<center>
<button id=”process-stop”> Start Processing </button>
<p id=”process-count”>0 Processes Executed</p>
</center>
</div>

When the client clicks the ‘Start Processing’ button, the server starts the computing process immediately.
Let’s move on to the most crucial part, setting up the blockchain computing engine.

It’s time to create the blockchain engine, the most vital part of our project.
Create a new folder, call it engine.
Inside /engine, create a new file named index.js.
Copy and paste the following code to the new index.js file.

class Blockchain {
//Initialize constructor
constructor(start, stop){
this.start = start;
this.stop = stop;
}

// Create chain engine
chain (){
const {start,stop} = this;
for(var i=start; i<stop+1;i++){
console.log(“Hello World”+(i));
}
}
}

// Export Blockchain
module.exports =Blockchain;

We export the ‘BlockChain’ engine and import it into our index.js server file. Remember we imported it into the index.js server file earlier.
We then create a new instance of the blockchain engine and populate it with our process variables.

const blockchain = new Blockchain( offset,offset+setFragment);
blockchain.chain();

It’s time to test our Blockchain super computer.
In our project’s command prompt terminal, run the following command.

node index.js

This is a very simple implementation of a decentralized blockchain super computer.

The aim is to highlight the basic concepts of decentralized blockchain computing.

Add a comment

Related posts:

Tentang Catatan Kehidupan

Kutipan singkat mengenai kehidupan. “Tentang Catatan Kehidupan” is published by Aufa Billah in Aufa Billah.

The Unique Challenge of Working with Clinical Text in NLP

Working with high-intensity corpora like legal or clinical texts presents a unique challenge for NLP engineers. This is how to understand it. Doctors and lawyers are expected to keep up with a…

Making a Raised Bed by Hand

I used to think a raised bed involved spending money on boards, hardware and the most ridiculous thing: imported dirt. But you don’t need any of those things, because the soil you need is under the…