This short-article focusses on one of the most popular consensus problems in distributed computing known as “Byzantine’s General Problem” and when a distributed system is said to be Byzantine Fault Tolerant. Various Byzantine Fault Tolerant algorithms are being used in Permissioned Blockchain Networks e.g Hyperledger Sawtooth is using Practical Byzantine Fault Tolerant(PBFT) to achieve consensus. So, if you want to understand how the consensus is actually achieved in such systems. This article is surely for you.
So let’s begin this journey.
First of let’s focus on the term ‘Byzantine Fault Tolerant’ and when a distributed system is said to be Byzantine Fault Tolerant? The answer lies within the different types of failures that can occur in a distributed system-
1.Crash-Fail: In this type of failure, the component stop working without any warning. So you need to restart the node or replace it. We can say it is a ‘Fail-Stop’ failure.
2.Omission Failure: In this, component transmits a message but that message is not received by other nodes or we can say it is omitted.
3.Byzantine Failures: It is a ‘no-stop failure’.It occurs when there is a malicious or traitor node in the network which sends conflicting messages or block the messages by not sending them to the other nodes in the network, which may lead to faulty results.
Now I think it is self-explanatory that a distributed system is said to be Byzantine Fault Tolerant if it can cope-up with the Byzantine Failures.
The applications of BFT can be found in various domain like Blockchain and even in Boeing 777 and 787 flight controls.
Let’s move on to a specific problem which forms a base for understanding BFT-
The Byzantine General’s Problem :
Situation: Suppose there are several generals and they have to attack army camp C and they are surrounding the army camp such that they can’t communicate with each other directly. The only way communication can happen in between them is through a carrier and he needs to pass the enemy camp for transferring every message. So they need proper protocols to reach a final decision whether to “attack ” on C, the next morning or “retreat”. If they all agree to attack, and they do attack then they will surely win or if they agree to “retreat” then they can fight on another day. But if one of the general attack and other decides to retreat then they are surely gonna lose.
Malicious Generals create variation in the decision to the others
Message Carriers may not reach
Reach a single solution, considering the downsides of a few Generals
Keeping in mind the situation, let’s discuss this problem with three generals.
Three Generals Problem:
Suppose, there are one commander and two lieutenants surrounding the army camp C and they have to collectively reach a decision to ‘attack’ or ‘retreat’.
If neither of the generals is faulty then all will work good and they will surely reach a decision.
Let’s see the case if one of the generals starts behaving maliciously:
The workshop was intended to excite and inspire some of the minds to set into brain-storming that might help the audience to come up with innovation with 21 st century internet Magnus, BLOCKCHAIN, to solve the real-world problems.
The prerequisite was null and void but an audience with a little bit of patience and curiosity, which certainly the audience was!
The workshop was segmented into two halves. It started with non-technical points to get launched into the topic and later shifted to tech-based. Key points of the talk were:
Intuitive questions like why blockchain, what are the daily life problems that are needed to be addressed through blockchains, how blockchains can solve the crisis of current internet like data tampering and data breaching was answered to create the vacuum in audience minds for the talk.
The talk then moved to introduce the audience with basic key terminologies like cryptography, hashing, mining, genesis block, ledger, nodes, consensus, etc.
Very carefully the backbones of the blockchain were introduced. The network design concept that gives this technology the key power were: a) Distributed system and b) Decentralized systems. How the Blockchain provides architectural and political decentralization and logical centralization was deeply discussed.
All of these gives the blockchain major characteristic system advantages of attack and collusion resistance, fault tolerance, good scalability, etc.
Finally, the real world application of the blockchain was explained and vividly demonstrated. The successful digital currency of Bitcoin, how it solved the major two unsolved problems of its time- malicious activity prevention and the double spending, how it works and some of its basic underlining stories were discussed.
The workshop ended with the display of a few of the projects that instructors made to participate in various hackathons.
Here is the ppt used in the actual workshop. All the references and important links would be uploaded soon, stay tuned!!!!
Are You a New Developer to the Ethereum Ecosystem?
Below is a mix of the main infrastructure tools and knowledge centres that will teach you how to build software on Ethereum. We recommend taking a look through the portal and reading about all the developer tools and options before getting started.
The most used chrome extension wallet and Web 3 provider that allows users to interact with decentralized applications.
Smart Contract Languages
A pythonic programming language for implementing smart contracts. Vyper is also currently beta software.
IDE stands for Integrated Development Environment. IDEs and Editors are what you need to write and test software. They are software suites that consolidate basic tools that are required to start writing on Ethereum. Below are the most popular IDEs and Editors.
Visual Studio Code extension that adds support for Solidity.
Public Testnets on Ethereum offer a way for developers to test what they build without putting their creations on the main Ethereum network. Developers are able to obtain as much ETH as you want on testnets because testnet ETH doesn’t carry any monetary value. Below are the most used testnets to start testing on and the links for where you can request testnet ETH.
A proof-of-authority blockchain started by the Geth team. Test ether must be requested.
Similar to Public Testnets, Local Testnets are a place for you to test your software without pushing it public. Unlike Public Testnets, the Local Testnet software will only run on your computer/node and other users won’t be able to see it or interact with it.
Fast Ethereum RPC client for testing and development. The command line version of Ganache, your personal blockchain for Ethereum development.
If you want to start developing dapps, you’ll need front-end development skills. Below are the most popular front-end interfaces that will help you turn your dapp from an idea to a live Ethereum mainnet application.
A collection of front-end libraries that make writing decentralized application frontends easier and more predictable. Drizzle provides a Redux library to connect a frontend to a blockchain.
If you want to graduate from just building dapps, you’ll need to start learning and using the backend interfaces listed below. If you’re interested in doing backend/protocol work on Ethereum, you should have significant experience with Go, Rust, Java, .NET, Ruby, or Python. Explore some of the most frequently used backend interfaces below.
A lightweight Java and Android library for integration with Ethereum clients.
Smart Contract Library
You’ve probably used programming libraries before, and these are no different. A smart contract library is the reusable piece of code for a smart contract which is deployed once and shared many times. Below are the most used smart contract libraries.
A collection of building blocks for building smart contract systems written in Solidity.
Smart Contract Testing and Deployment
If you are creating a tool, product, or application on Ethereum, you’ll want to make sure your smart contract is in working order before deploying to the mainnet. These tools will help you build, test, and ship your code.
A framework that allows you to easily develop and deploy decentralized applications. Currently integrates with EVM blockchains (Ethereum), IPFS, Swarm, Whisper, and Orbit.
An Ethereum client refers to any node that is able to parse and verify the blockchain, its smart contracts, and everything in between. An Ethereum client also provides interfaces to create transactions and mine blocks which is the key for any Ethereum transaction. Below are the most popular Ethereum clients.
A command line interface for running a full Ethereum node implemented in Go.
Ethereum allows you to save variables or data in permanent storage. The storage platforms below are where all of the smart contract data lives. IPFS is the most commonly used storage system on Ethereum. Explore the platforms below to learn more about how storage on Ethereum works.
A decentralized peer to peer database on top of IPFS.
Ok, so you’ve finally built your dapp or smart contract. But how do you know it was set up correctly and is safe from hackers? The security tools below will help ensure that your code is safe and follows all Ethereum development best practices.
The goal of this article is to let you know about a BASIC BLOCKCHAIN structure by making a sample blockchain by using a Scripting language Python.
And a small assignment at the last.
The information about the following will be provided on the further articles:
various applications of blockchain and at various levels
use blockchain to create your own cryptocurrency
use of blockchain to create a file deployment system
and Many More…
This article will, for right now, will not have information about deploying your own Blockchain Application, and creating a distributed and decentralized file sharing system.
If you are just interested with how to create a blockchain Jump directly to CONSTRUCTING even I would have done that…
So, let’s start to learn something new……
What is Blockchain?
Back in 2008, some mysterious Person/group of persons named SATOSHI NAKAMOTO released a whitepaper named Bitcoin: A Peer to Peer Electronics Cash System (I suggest that you read the paper to understand how it was presented to the world) in which BITCOIN was described to be a BLOCKCHAIN based technology,
a completely trustless (though the meaning is exactly the opposite, it actually means no trust issues)
technology that can actually serve as a new form of currency which has its value just as a Stock Share and transaction just like a Barter system.
So, right now before turning this article into a History(story) or market revolutionalizing technology journey let’s start some keyboard ticking and see where we are able to implement key points of a Blockchain, though I will provide you enough resources to read more about emergence and have an intuitive idea about its potential.
Let’s get started…
Design and Features
So, let us begin with the basic design of blockchain by understanding how does it implement its key features.
Before explaining further I want you to go through this wonderful video about blockchain. So we shall jump directly to the technical part. It will let you understand most of the things.
Now after this you must have understood the basic structure of Blockchain.
It is a distributed and decentralized ledger system which provides a TAMPER free service to store records.
Python 3.6 (a basic python would work but if you don’t know any about it don’t worry it’s very simple and I will try to give an intuitive idea about what I am using and why.)
a cool text editor would work well > Sublime Text 3(choose according to the platform you have, it’s lightweight and good)n > Atom (the best one to use, has an extension for a terminal)
LINUX (Suggested, It’s better to switch to Linux now if you really have to do some good) ……that’s it for now, its basic
Let us start by creating a BLOCK:
We’ll start by creating a class of simple BLOCK using Python:
def __init__ (self, timestamp, data, previousHash = ' '):
self.timestamp = timestamp
self.data = data
self.previousHash = previousHash
self.hash = #TODO function calculateHash()
Just have a look at this block we have 4 arguments. Of course, self is working for self-element initialization, for those who don’t understand just understand that it is a kind of PYTHON convention of constructors.
Also that we haven’t included hash in the block argument as it will be calculated and stored inside the function itself #TODO.
Now let’s write the function to calculate hash the block:
use of encode() and in the return line hexdigest() → so the answer for that is you need to encode every text before hashing, I’ll try to cover it in further blogs. → and to convert hash object into a string we need to use the hexdigest function
and yes, for sha256 you need to import hashlib library, and also you need to convert everything into a string before hashing it
Also, we need to include time for timestamp
So the code for blocks looks like: –
from hashlib import sha256
def __init__ (self, timestamp, data, previousHash = ' '):
self.timestamp = timestamp
self.data = data
self.previousHash = previousHash
self.hash = # TODO
return sha256((str(self.timestamp) + str(self.data) + \ str(self.previousHash).encode()).hexdigest())
and now let’s begin with our Blockchain class definition:
Genesis Block: the very first block of the blockchain is termed as a genesis block. And it generally can have any data. So we need to initialize our blockchain with it if we don’t have any block in the BLOCKCHAIN. We will have the following structure:
You can also have a look at my team Project with Ujjwal Kumar – LinkedIn & Hrishabh Sharma – LinkedIn, another CEV members @ Rajasthan DIGIFEST 2k18 Online hackathon – a 36 hours hackathon held on 6 July 2018 on making a cryptocurrency RAJCOIN for Rajasthan Govt @ the following Github link.