Why Blockchain Unit 1
Why Blockchain Unit 1
Contents
Introduction
What is Blockchain?
What is Block in Blockchain?
Structure of a Block
Block Header
Transactions
In Conclusion
Introduction
In this article, we’ll go through the components and structure of Blockchain’s block. We’re going
to take the Bitcoin block as an instance. Bitcoin is a popular permissionless public blockchain
network. Before getting into block anatomy, let’s begin with understanding blockchain briefly.
What is Blockchain?
Blockchain comes under Distributed Ledger Technology (DLT). It’s a distributed database that
records– who transacts what to whom and who owns what? Hence, a blockchain is
a decentralized database containing imprints of assets and transactions across a whole network.
Each node/system in the network shares the exact same copy of records, making it nearly
impossible to disrupt or alter.
All nodes or systems are connected peer to peer (P2P) in a network. This distribution is on a
conceptual network level.
However, when it comes to storing the ledger of the transactions in a blockchain network, it’s
different. Let’s understand it clearly.
Each block header contains the previous block hash, current block hash, nonce,
Merkle root, and other details.
All blocks are connected linearly by carrying the hash of the previous block.
The previous block hash is used to compute the current block hash.
The first block with no previous block hash is called “Genesis Block.”
For adding a new block to the network, the blockchain follows consensus
mechanisms like proof of work (PoW), proof of stake (PoS), etc.
Structure of a Block
Let’s just draw a conceptual image of a block with reference to a ledger of transactions.
The above image will create a simpler conceptual block visualization in your head. However, the
actual block contains a lot more information than the ledger image above.
Block Height –
It’s the sequence number of the block in the chain of blocks. Block Height: 1 is the genesis
block (first block in the network).
Block Size –
It’s a 4-bytes or 32-bit field that contains the size of the block. It adds size in Bytes. Ex – Block
Size: 216 Bytes.
Block Reward –
This field contains the amount rewarded to the miner for adding a block of transactions.
Tx Count –
The transaction counter shows the number of transactions contained by the block. The field has
a maximum size of 9 bytes.
Block Header –
The Block header is an 80-Byte field that contains the metadata – the data about the block.
Time – It’s the digitally recorded moment of time when the block has been mined. It is
used to validate the transactions.
Version – It’s a 4-bytes field representing the version number of the protocol used.
Usually, for bitcoin, it’s ‘0x1’.
Previous Block Hash – It’s a 32-bytes field that contains a 256-bits hash (created
by SHA-256 cryptographic hashing) of the previous block. This helps to create a linear
chain of blocks.
Bits – It’s a 4-bytes field that tells the complexity to add the block. It’s also known as
“difficulty bits.” According to PoW, the block hash should be less than the difficulty
level.
Nonce – It’s a 4-bytes field that contains a 32-bit number. These are the only changeable
element in a block of transactions. In PoW, miners alter nonce until they find the right
block hash.
Merkle Root – A 32-bytes field containing a 256-bit root hash. It’s constructed
hierarchically combining hashes of the individual transactions in a block.
For a public blockchain, the decision to add a transaction to the chain is made by
consensus. This means that the majority of “nodes” (or computers in the network)
must agree that the transaction is valid. The people who own the computers in
the network are incentivised to verify transactions through rewards.
The transaction is validated by the network and made part of the mining process.
Mining is in progress and is done when a minder earns a bitcoin. The network validates the
result of the mining process. The receiver of the money gets a confirmation of the successful
transaction.
What transactions are Bitcoin miners verifying?
What does Bitcoin transaction confirmation do? A Bitcoin transaction, or any
cryptocurrency transaction must be confirmed on a blockchain to verify that the
transaction is legitimate. A confirmed transaction means that the transaction has
been included in a block, and therefore included in the blockchain.
Let's say Raj and Shalini are two nodes on a bitcoin blockchain network. Now Raj wants to
send 50 Bitcoins (BTCs) to Shalini via a secure channel. This transaction will be done
through the blockchain network.
Blockchain Architecture
Now in this Blockchain Technology tutorial, let’s study the
Blockchain architecture by understanding its various components:
A Blockchain is a chain of blocks that contain information. The data which is stored
inside a block depends on the type of blockchain.
For Example, A Bitcoin Block contains information about the Sender, Receiver,
number of bitcoins to be transferred.
The first block in the chain is called the Genesis block. Each new block in the chain
is linked to the previous block.
Therefore, the Hash is very useful when you want to detect changes to
intersections. If the fingerprint of a block changes, it does not remain the same
block.
1. Data
2. Hash
3. Hash of the previous block
Consider the following example, where we have a chain of 3 blocks. The 1st block
has no predecessor. Hence, it does not contain has the previous block. Block 2
contains a hash of block 1. While block 3 contains Hash of block 2.
Hence, all blocks are contained hashes of previous blocks. This is the technique
that makes a blockchain so secure. Let’s see how it works –
Therefore, changing a single block can quickly make all following blocks invalid.
Proof of Work
Hashes are an excellent mechanism to prevent tempering, but computers these
days are high-speed and can calculate hundreds of thousands of hashes per
second. In a matter of a few minutes, an attacker can tamper with a block and
then recalculate all the hashes of other blocks to make the blockchain valid
again.
In the case of Bitcoin, it takes almost 10 minutes to calculate the required proof-
of-work to add a new block to the chain. Considering our example, if a hacker
would to change data in Block 2, he would need to perform proof of work (which
would take 10 minutes) and only then make changes in Block 3 and all the
succeeding blocks.
This kind of mechanism makes it quite tough to tamper with the blocks, so even
if you tamper with even a single block, you will need to recalculate the proof-of-
work for all the following blocks. Thus, hashing and proof-of-work mechanisms
make a blockchain secure.
Let’s see what happens when any user creates a new block. This new block is
sent to all the users on the network. Each node needs to verify the block to
make sure that it hasn’t been altered. After complete checking, each node adds
this block to their blockchain.
All these nodes in this network create a consensus. They agree about what
blocks are valid and which are not. Nodes in the network will reject blocks that
are tampered with.
After doing all these, your tampered block becomes accepted by everyone else.
This is next to an impossible task. Hence, Blockchains are so secure. Next, in this
beginner’s Blockchain development tutorial, we will learn how a Blockchain
transaction works?
Step 3) The network of nodes validates the transaction and the user’s status
with the help of known algorithms.
Step 4) Once the transaction is complete, the new block is then added to the
existing blockchain. In such a way that is permanent and unalterable.
Time reduction: In the financial industry, blockchain can play a vital role by
allowing the quicker settlement of trades as it does not need a lengthy process
of verification, settlement, and clearance because a single version of agreed-
upon data of the shared ledger is available between all stack holders.
Decentralized: There are standards rules on how every node exchanges the
blockchain information. This method ensures that all transactions are validated
and all valid transactions are added one by one.
Blockchain versions
Now in this Blockchain development tutorial, let’s learn about Blockchain
versions.
Blockchain Versions
Blockchain 1.0: Currency
The implementation of DLT (distributed ledger technology) led to its first and
obvious application: cryptocurrencies. This allows financial transactions based
on blockchain technology. It is used in currency and payments. Bitcoin is the
most prominent example in this segment.
This Video shows a more technical explanation of what is Bitcoin and how
does it work
1. Nick opens his bitcoin wallet. This implies that Nick is indirectly
creating his own bitcoin address. He’s supposed to get some
bitcoins.
6. It’s mining time and miners pick up the transactions (first those
who pays more transaction fee) and group them into blocks trying to
solve the Proof Of Work (or POW — a consensus
algorithm) and calculate a certain hash function.
7. The miner who get it propagates the new block to the network.
10. New confirmations appear with each new block that is created
and linked.
Transactions can also include fees. If there are any bitcoins left over
after adding up the inputs and subtracting the outputs, the
remainder is a fee paid to the miner. The fee isn’t strictly required,
but transactions without a fee will be a low priority for miners and
may not be processed for days or maybe discarded entirely. A typical
fee for a transaction is 0.0002 bitcoins (about 20 cents), so fees are
low but not trivial.
STEP 2: Broadcasting
STEP 4: Validation
Once the transaction is on the Mempool, then the miners pick up the
transactions (First those who pays more transaction fee) and group
them in blocks. As on May 2017, each block has a maximum size
limit of 1 MB (change in this limit is under discussion by the
community) and contains around 2.000 to 3000 transactions,
depending on the size of each transaction. Then, by using the Proof-
of-Work Consensus Algorithm, the network agrees on the valid
block, and consequently the transactions, on average every 10
minutes.
1. Clent-Server Model: Here all the client nodes update data to the central server (assuming
1:M mapping). The server takes the input and all updates the data in its database. And after
that, when a client asks for the data server provides the updated data. The server holds 100%
of the data. Most of the websites on the internet today are built on this model. It's very
efficient but also very easy to take down or corrupt by governing bodies or bad people. As the
main target of the whole system becomes the target.
2. Peer-To-Peer (P2P) Model: In this model, each participant of the network has the 100% of
the data (or close to it) instead of a centralized server. It's kind of a gossip model. Where each
participant in a group of friends knows 100% about the gossip. It is a decentralized
communications model in which each party has the same capabilities and either party can
initiate a communication session. Unlike the client/server model, in which the client makes a
service request and the server fulfills the request, the P2P network model allows each node to
function as both a client and server. It is less efficient than the Clent-Server model as the data
has to be replicated to all the nodes whenever there is new data coming. However, here each
peer/node is more independent as they can operate to some extent if they lost connection to
the network. Also, it is very robust. As there is no central server, it is very hard to close down
a P2P
In comparison to the proof of Work (PoW) system, PoB reduces energy consumption.
Moreover, compared with proof of stake (PoS) systems, PoB doesn’t need miners to stake
coins to add a new block to the network.
There are various versions of Proof of Burn in blockchain, with the most acknowledged version
being Iain Stewart’s algorithm. He’s also the inventor of the Proof of Burn consensus
mechanism.
Here, the concept of “burning the coins” means investing the native coins in virtual mining
rigs (mining powers). It allows miners with the most virtual mining rigs or a miner who
invested the most coins – to add his new block of transactions to the network. Hence, the
number of burnt coins shows miners’ commitment to the network.
First, let’s begin with how do the miners burn the coins?
Here, the miners transfer some amount of coins to an unspendable address or an escrow
account. These publicly verified unspendable accounts are randomly created with no private keys
associated. Once coins get received by burn address/accounts, it becomes useless and
inaccessible. Eventually, the burnt coins in the account are used for strengthening the security of
the network.
See the below diagram. Each miner sends some of their coins to the burn address or unspendable
escrow account.
John wins as he burns the maximum number of coins. Hence, he gets the chance to add his block
of transactions to the network.
Moreover, the block added by John will be verified by other network validators. If the block is
found invalid, then the second-highest (Ross) gets the chance to add a new block.
Proof of Burn in blockchain promotes the periodic burning of coins to avoid partiality among
new and old network participants. It means the virtual power of mining reduces each time a
new block gets mined. Moreover, it motivates miners to make regular transactions instead of just
one-time investments.
Now let’s jump to the pros and cons of using the PoB approach.
Benefits of PoB
Following are the advantages of Proof of Burn in blockchain:
Less power and energy consumption.
Motivates miners to make regular transactions using cryptocurrency.
PoB is more sustainable and doesn’t need hardware for heavy computation.
Used for long-term commitments
Limitations of PoB
Following are the disadvantages of Proof of Burn in blockchain:
Proof-of-Activity (PoA)?
In this series of learning various consensus algorithms in blockchain, today, we picked up proof
of Activity (PoA). In this article, you’ll learn about the working of the PoA mechanism along
with its pros and cons.
PoA mechanism ensures that all blocks of transactions added to the network are genuine and
valid. It’s a way that helps miners to get network agreement (or consensus) to add their new
block. Moreover, PoA protects the blockchain network against external and internal attacks.
Then a group of validators is picked at random. They are responsible for validating or
signing the new block. Validators analyze the header information of the block and then mark it
as valid or invalid. This process continues until a block receives the required number of validators
(or signers).
The higher coins the network participant holds, the stronger are their chances of being picked up
as a validator (or signer).
Once the group of validators signs the new block by the miners, it’s marked as a valid,
complete block and gets added to the blockchain network. Finally, the transactions will get
recorded on the newly added block.
At last, the mining fees/rewards distributes among the miners and the group of validators who
contributed to the mining process.
Let’s see how the proof of Activity (PoA) mechanism works step by step.
How does the Proof of Activity (PoA) Algorithm work?
Following are the steps to the PoA algorithm.
Miners try to submit their almost empty block (with header information and miner’s reward
address) by solving a complex mathematical puzzle (finding the correct nonce and block hash)—
similar to PoW.
Once the miners submit their nearly blank blocks, the consensus approach switches from PoW to
the PoS mechanism.
This step uses the concepts of the Proof of Stake (PoS) mechanism for using network validators.
However, here validators and miners are separate entities.
A group of network participants called validators (or signers) verifies the block submitted by the
miners. These network validators are selected based on their coins in the network. The higher the
coins held by a validator, have the maximum chances of getting their signed block chosen.
Validators analyze the header information and miners’ reward address of the block and
then mark it as signed or unsigned.
Note: The process of signing continues until a block receives the required number of signs on
their block by the validators.
Once a block gets signed by the required number of validators. It marks a valid and complete
block. Afterward, new transactions from the transaction pool add to the block. Finally, the block
gets added to the blockchain network.
The mining reward is distributed among the winning block’s miner and the validators for their
contribution to the network.
PoA combines to utilize PoW’s hashing system and PoS’s digital signing.
It highly reduces the probability of a 51% attack on the network.
Maintains the difficulty level to protect the network.
PoA has high fault tolerance as the whole system will never shut down completely.
Provide earning opportunities to both miners and network validators.
Like
Be the first one to like the blog!
Introduction
In this series of covering consensus mechanisms used by blockchain networks, today, we picked
up Proof of Elapsed time (PoET). It is the algorithm behind Hyperledger permissioned
blockchain network for businesses.
This article covers the gore details of the PoET algorithm along with its functioning. It also
covers the difference between Proof of Work and Proof of Elapsed Time. In addition, the article
goes through the benefits and limitations of the PoET consensus algorithm.
The PoET algorithm was developed by Intel Corporation, the processor chip giant, in early
2016. Intel associated with Linux Foundation in the development of Hyperledger Sawtooth.
They aimed to build a highly scalable private blockchain network.
PoET Mechanism assigns an amount of time to each node in the network randomly. The node
must sleep or do another task for that random wait time. Whichever node gets the shortest
waiting time wakes up and add their block to the network. Later, the new update information
floods among other network participants.
The Proof of Elapsed time in blockchain needs to ensure 3 significant factors for this
process to work:
Ensure that the node or network participant gets the random waiting time indeed.
Check if they are not choosing the shortest waiting time on purpose.
Verify if the node has completed the given waiting time or not.
Let’s dig a bit deeper into working on the Proof of Elapsed Time mechanism.
A newly proposed block selects if the controller approves the newly proposed block by the first
woken up node. Else it gets discarded. And then, the selection process of assigning waiting time
starts again.
Selection Process
First, each participating node has to share its certificate by Intel Software Guard
Extension (SGX), which ensures its validity to generate a new block in the network.
After that, they are eligible to get a timer object.
The numbers assigned to each node as a timer object (waiting countdown time) by
Intel’s random number generation instruction, RAND. It generates difficult to detect
random numbers.
Now, the time object given to each participating node activates.
Generation Process
After the time object ends and the node wakes up, it’s eligible to forge a new block to the
network.
The active node generates the hash (using a hash function like SHA-256) of its block of
transactions and submits it for acceptance. It doesn’t require showing computation
work done by the node.
Afterward, the update gets flooded to the network.
Therefore ends the iteration of mining a new block in a permissioned blockchain network using
the PoET consensus mechanism.
PoET is way more time and energy-efficient than PoW. It is backed by one of the renowned
technology giants, Intel corporation, which makes it more trusting and reliable.
You can also read about Digital Signing in Blockchain using Crypto