Book Image

Practical Artificial Intelligence and Blockchain

By : Ganesh Prasad Kumble
Book Image

Practical Artificial Intelligence and Blockchain

By: Ganesh Prasad Kumble

Overview of this book

AI and blockchain are two emerging technologies catalyzing the pace of enterprise innovation. With this book, you’ll understand both technologies and converge them to solve real-world challenges. This AI blockchain book is divided into three sections. The first section covers the fundamentals of blockchain, AI, and affiliated technologies, where you’ll learn to differentiate between the various implementations of blockchains and AI with the help of examples. The second section takes you through domain-specific applications of AI and blockchain. You’ll understand the basics of decentralized databases and file systems and connect the dots between AI and blockchain before exploring products and solutions that use them together. You’ll then discover applications of AI techniques in crypto trading. In the third section, you’ll be introduced to the DIApp design pattern and compare it with the DApp design pattern. The book also highlights unique aspects of SDLC (software development lifecycle) when building a DIApp, shows you how to implement a sample contact tracing application, and delves into the future of AI with blockchain. By the end of this book, you’ll have developed the skills you need to converge AI and blockchain technologies to build smart solutions using the DIApp design pattern.
Table of Contents (15 chapters)
1
Section 1: Overview of Blockchain Technology
4
Section 2: Blockchain and Artificial Intelligence
9
Section 3: Developing Blockchain Products

Consensus algorithms

The laws that human society relies on to function are much more difficult to enforce when it comes to computers. Consensus algorithms are the specific instructions programmed on computers in a network so that they have a common definition of objects and instructions to agree on changes. Crashes, failures, and Byzantine faults in computers led to a better approach in forming an agreement in a digital network and so consensus algorithms rose to great heights, well before the dawn of the internet. This concept has been revisited thanks to the new leap in innovation to blockchains.

The following sections look at some of the important consensus algorithms used by blockchains.

Proof of work

Proof of work (PoW) is a consensus algorithm introduced by the anonymous founder of Bitcoin—Satoshi Nakamoto. The PoW consensus algorithm is one of the earliest consensus algorithms used in a blockchain environment. It leverages a combination of cryptography, P2P network communications, and a Merkle data structure to offer a distributed, immutable, and cumulative state of accounts in the Bitcoin blockchain. The solution computed by the first node is verified by the remaining nodes and the block producer is broadcast in the network:

  • Merit: The PoW algorithm has been time tested in the Bitcoin blockchain network and there is not a single hack/compromise of the account states in the network leading to double spend.
  • Demerit: As the PoW algorithm needs to find a solution to a mathematical problem, significant CPU cycles are required to generate hashes and so it is an energy-intensive technique.

Proof of stake

Proof of stake (PoS) is a new consensus algorithm designed and developed to address some of the trade-offs of the PoW algorithm. The block-producing node is determined by an application of mathematical function involving a few determining factors, such as the stake (for example, ETH), the age of the node, and the randomization of eligible node candidates:

  • Merit: The PoS algorithm is energy-efficient as there are fewer computational requirements and it does not select a block-producing node based on a solution-verification model.
  • Demerit: Although the PoS algorithm is efficient in its block times and is environment-friendly, there have been criticisms relating to the algorithm's vulnerability to capitalist attacks on the network of the node owner and tries to compete with other candidates with a stupendous amount of cryptocurrency at stake, higher than all the other candidates.

Proof of burn

Proof of Burn (PoB) is a consensus algorithm with an interesting approach to solving transition problems from one version of cryptocurrency to another in the blockchains. Through the PoB algorithm, the old cryptocurrency (or its preceding version) is burnt in order to reduce its supply and gradually increase the supply of the new cryptocurrency (or its succeeding version). This consensus algorithm is practiced in various forms, including a method wherein users can transfer the old cryptocurrency to an unspendable wallet address in exchange for new ones:

  • Merit: The PoB algorithm is convenient during the transition of cryptocurrencies and network upgrades if the system trusts the participating entities.
  • Demerit: The PoB algorithm is usually applicable in PoW-based blockchains and so has a limitation of applicability. This is due to the requirement of verifiable proofs and the ability to decay the burnt coins over time, which is naturally capable through PoW algorithms.

Delegated Proof of Stake

Delegated Proof of Stake (dPOS) is a consensus algorithm developed and used by the Block.one EOS platform. Under dPOS, the token holders reserve the right to nominate the validators (also called block producers). The selection of block producers is a continuous process and performs the duties of packaging user transactions into blocks with Byzantine fault-tolerant safety:

  • Merit: dPOS is Byzantine Fault Tolerance (BFT) -ready and scales easily in a public network environment.
  • Demerit: Although dPOS is efficient, it is prone to capitalistic efforts to supersede other minor token stakeholders.

Proof of authority

As the name suggests, the Proof of Authority (PoA) algorithm facilitates a distributed consensus with a few eligible verifiable nodes preserving the right to add transactions to blocks, if some criteria is met. There are many variants of the PoA algorithm, with or without the reputations of the validating nodes used in the public, private, and permissioned blockchains:

  • Merit: The PoA algorithm is energy-efficient and not prone to capitalistic pitfalls as the validator nodes are authorized to add transactions to blocks based on their reputation. If the node is observed to malfunction, its reputation is severely affected and cannot proceed as a validator.
  • Demerit: The PoA algorithm is partially centralized as the authority of adding or rejecting transactions lies in the purview of very few nodes in the network.

Practical Byzantine fault tolerance

Practical Byzantine Fault Tolerance (PBFT) is one of the replication algorithms brought to light by academic research. Authored by Miguel Castro and Barbara Liskov in 1999 (http://pmg.csail.mit.edu/papers/osdi99.pdf), this algorithm was primarily aimed at solving the Byzantine faults caused by the arbitrary point of failures in the nodes of a network.

Notably, the PBFT algorithm is used by the Hyperledger Fabric blockchain framework:

  • Merit: The PBFT algorithm is efficient, with fast transaction processing and scalable to hundreds of nodes in a private network.
  • Demerit: The algorithm is based on a gatekeeper technique and is hence criticized for its centralized approaches. PBFT is not suitable for public blockchains.

Proof of elapsed time

Proof of Elapsed Time (PoET) is a consensus algorithm developed and used by the Hyperledger Sawtooth blockchain framework. The PoET algorithm ensures security and randomness involved in the leadership of validator nodes with special CPU instructions available in most of the advanced processors featuring secure virtual environments:

  • Merit: PoET allows anyone with eligible hardware to participate as a validator node, allowing legitimate ways of verifying the leader election.
  • Demerit: Although PoET does not involve staking cryptocurrencies to form a validatory node, the cost of affording specialized hardware does not come cheap. So, there have been criticisms highlighting this as an unfair bar to enter the network.

RAFT

RAFT is a consensus algorithm designed and developed by Diego Ongaro and John Ousterhout with the main motivation to bring about a distributed consensus algorithm that is much easier to understand than Paxos. Notably, RAFT ensures safe leader election, appending log entries in a distributed manner, and state machine consistency. The RAFT consensus is implemented in the Quorum blockchain to inherit the preceding described safety features:

  • Merit: RAFT is one of the fastest algorithms in processing complex transaction payloads with the security of leadership and state machine consistency.
  • Demerit: RAFT is suitable for permissioned or private blockchains only.

Ternary augmented RAFT architecture

Ternary Augmented RAFT Architecture (TARA) is a consensus algorithm designed for large-scale Byzantine-distributed networks. It is an enhanced version of the RAFT consensus algorithm to address heterogeneous transactions identifiable by their asset classes by leveraging PBFT hardening and cryptographic message exchanges. TARA introduces dynamic hierarchy to networks to ensure that their authority is not concentrated among a few nodes:

  • Merits: TARA offers service clusters to ensure high availability, throughput, and scale. It has the hardware of all form factors with the ability to compute and store transactions can participate. TARA can be applied in all three environments—public, private, and permissioned blockchain networks.
  • Demerit: Leadership election is not inherently dependent on the node's reputation, thereby allowing a potential attack on systems. These constraints must be implemented explicitly.

Avalanche

The Avalanche consensus is a protocol for distributed systems, introducing leaderless Byzantine fault tolerance, using a metastable mechanism achieving the same level of security and consistency among the nodes. Avalanche depends on the Snowball family to form a DAG, which stores the user transactional data, instead of blocks:

  • Merit: Avalanche guarantees liveness and is immune to race conditions in the network.
  • Demerit: Leadership consensus may not be applicable to all blockchain environments as there is not a carefully analyzed set of heuristics to ensure consistency.

With this detailed analysis of consensus algorithms, let's now go through the development tools available to blockchain developers.