Blockchain Technology
and
Cryptocurrency: Consensus
Ashok Kumar Turuk
1
Consensus and integrity
Block creation and transaction confirmation with POW consensus
model
2
Consensus and integrity
Consensus means agreement among Proof of work
peers. Compute the hash H of block header
Consensus is an agreement among elements (fixed) and a nonce
the full nodes about the next block to (variable):
be added to the chain, a process that 1. H = hash(header, nonce) //nonce is
ensures the integrity of the chain. variable parameter in the header
Different consensus models: 2. If H <= function(difficulty) for
Ethereum, the miner has solved the
Proof of work (POW), puzzle, jump to step 4. //difficulty is a
Proof of authority (POA), and variable parameter in the header
Proof of stake (POS) 3. Else change the nonce and repeat
steps 1 and 2.
4. Puzzle has been solved.
3
Consensus and integrity
Proof of stake A round-robin policy is used to avoid
The full node with the most at stake monopoly by the node with the most
or most coins in its account chooses at stake.
the next block to be added to the The transaction fees pay the minter
chain. fee, and there is no miner fee, such as
in POW.
The idea is that the node with the The POS approach is expected to be
most at stake will not act maliciously environment-friendly and efficient.
and risk its stake by forking the
network.
4
Consensus and integrity
Byzantine fault-tolerant consensus
Practical Byzantine Fault Tolerance (PBFT) has been proven to tolerate
random or Byzantine node failures (including malicious nodes).
In PBFT, nodes elect a leader, and that leader adds the next block to the
chain.
The nodes exchange messages.
The messages, along with the saved state, are used to reach a consensus in
the presence of random independent faults or bad nodes.
The chosen node adds the next block of validated transactions.
PBFT is popular in permissioned blockchains such as Hyperledger Fabric.
5
Public, private, and
permissioned networks
Transparent, permissionless public Only permitted participants can transact and take
system that anyone can join and part in the blockchain operations membership
leave as they wish. Highly selective and often limited and permanent.
6
Blockchain
The peer-to-peer capability bitcoin A transaction recorded on a
could be applied to other, non- blockchain contains a peer-to-
cryptocurrency types of transactions peer message that specifies the
These transactions involve assets operations executed, data
such as titles, deeds, music and art, parameters used for the
secret codes, contracts between
businesses, autonomous driver
execution of operations, the
decisions, and artifacts resulting from sender and receiver of the
many everyday human endeavors. message, the transaction fee,
A transaction record may contain and the timestamp of its
other details based on the blockchain recording
protocol and the application
7
Blockchain
A snapshot of the Ethereum public blockchain
8
Blockchain
Blockchain programming context
9
Blockchain
Blockchain stacks and types of programming.
Bitcoin has only the wallet application, whereas
Ethereum features programmable code called smart
contracts
10
Blockchain
Protocol-level programming: Application-level programming:
This level involves software that is needed
for the deployment and operation of the
• This level involves programming
blockchain itself. using web (or enterprise or mobile)
This software is similar to your operating application frameworks and user
system or networking software. interface design concepts.
Smart contract-level programming: • Web programming to link to
At this level that you design and program
underlying smart contracts and to
the rules for verification and validation, and deploy end-to-end decentralized
specify the data and messages that are to applications (Dapps) on the
be recorded on the underlying blockchain. blockchain
The smart contract is the engine that drives
the blockchain on behalf of the user
application.
11
Blockchain
• Dapps are web or enterprise • A smart contract is an immutable
applications that include application executable code representing the
logic to invoke blockchain functions logic of a Dapp.
that implement trust intermediation • The data variables and functions defined
in a smart contract collectively represent
• Dapps embed a significant code the state and operations for enforcing an
element—that of smart contracts. application’s (Dapp’s) rules for
• For any given smart contract, an exact verification, validation, and recording on
copy of the smart contract’s code is the blockchain
transmitted through a special transaction
and deployed in the participant nodes of
a blockchain network.
12