Unit - 1 Block Chain
Unit - 1 Block Chain
History of Blockchain
The blockchain technology was described in 1991 by the research scientist Stuart
Haber and W. Scott Stornetta. They wanted to introduce a computationally
practical solution for time-stamping digital documents so that they could not be
backdated or tampered. They develop a system using the concept
of cryptographically secured chain of blocks to store the time-stamped
documents.
All the participants in the network govern and agreed-upon consensus on the
updates to the records in the ledger. There is no central authority, or third-party
mediators such as a financial institution or government agencies are involved.
Every record in the distributed ledger has a timestamp and unique cryptographic
signature. It makes the ledger an auditable, and immutable history of all
transactions in the network.
Further, if any alterations made to the ledger, they are reflected and copied to all
participants in seconds or minutes. In other words, when any modifications or
updates happen in the ledger, each node constructs the new transaction, and then
the nodes vote by consensus algorithm on which copy is correct. Once a
consensus algorithm has been determined, all the other nodes update themselves
with the new and correct copy of the ledger.
The primary advantage of the distributed ledger is the lack of central authority. As
we know that centralized ledgers are prone to cyber-attack, distributed ledgers are
inherently very hard to attack. It is because all the distributed copies need to be
attacked simultaneously for an attack to be successful.
Features of Blockchain
Last Updated : 14 Mar, 2023
Here In this article, we will discuss the features of blockchain technology and how
they make it a revolutionary and highly desirable platform for various applications.
A blockchain is a chain of blocks that contains information. Most people think that
Blockchain is Bitcoin and vice-versa. But it’s not the case. In fact, Bitcoin is a
digital currency or cryptocurrency that works on Blockchain Technology.
Blockchain was invented by Satoshi Nakamoto. As the name suggests, Each block
consists of a number of transactions, and each transaction is recorded in the form
of a Hash. Hash is a unique address assigned to each block during its creation and
any further modification in the block will lead to a change in its hash.
Features of Blockchain
Let’s have a look at the primary features of the blockchain technology:
1. Immutable
All network participants have a copy of the ledger for complete transparency. A
public ledger will provide complete information about all the participants on the
network and transactions. The distributed computational power across the
computers ensures a better outcome.
Distributed ledger is one of the important features of blockchains due to many
reasons like:
In distributed ledger tracking what’s happening in the ledger is easy as changes
propagate really fast in a distributed ledger.
Every node on the blockchain network must maintain the ledger and participate
in the validation.
Any change in the ledger will be updated in seconds or minutes and due to no
involvement of intermediaries in the blockchain, the validation for the change
will be done quickly.
If a user wants to add a new block then other participating nodes have to verify
the transaction. For a new block to be added to the blockchain network it must
be approved by a majority of the nodes on the network.
In a blockchain network, no node will get any sort of special treatment or favors
from the network. Everyone will have to follow the standard procedure to add a
new block to the network.
3. Decentralized
Blockchain technology is a decentralized system, which means that there is no
central authority controlling the network. Instead, the network is made up of a
large number of nodes that work together to verify and validate transactions. Each
and every node in the blockchain network will have the same copy of the ledger.
Decentralization property offers many advantages in the blockchain network:
As a blockchain network does not depend on human calculations it is fully
organized and fault-tolerant.
The blockchain network is less prone to failure due to the decentralized nature
of the network. Attacking the system is more expensive for the hackers hence it
is less likely to fail.
There is no third-party involved hence no added risk in the system.
The decentralized nature of blockchain facilitates creating a transparent profile
for every participant on the network. Thus, every change is traceable, and more
concreate.
Users now have control over their properties and they don’t have to rely on
third-party to maintain and manage their assets.
4. Secure
All the records in the blockchain are individually encrypted. Using encryption adds
another layer of security to the entire process on the blockchain network. Since
there is no central authority, it does not mean that one can simply add, update or
delete data on the network.
Every information on the blockchain is hashed cryptographically which means that
every piece of data has a unique identity on the network. All the blocks contain a
unique hash of their own and the hash of the previous block. Due to this property,
the blocks are cryptographically linked with each other. Any attempt to modify the
data means to change all the hash IDs which is quite impossible.
5. Consensus
Every blockchain has a consensus to help the network to make quick and unbiased
decisions. Consensus is a decision-making algorithm for the group of nodes active
on the network to reach an agreement quickly and faster and for the smooth
functioning of the system. Nodes might not trust each other but they can trust the
algorithm that runs at the core of the network to make decisions. There are many
consensus algorithms available each with its pros and cons. Every blockchain must
have a consensus algorithm otherwise it will lose its value.
6. Unanimous
All the network participants agree to the validity of the records before they can be
added to the network. When a node wants to add a block to the network then it
must get majority voting otherwise the block cannot be added to the network. A
node cannot simply add, update, or delete information from the network. Every
record is updated simultaneously and the updations propagate quickly in the
network. So it is not possible to make any change without consent from the
majority of nodes in the network.
7. Faster Settlement
Traditional banking systems are prone to many reasons for fallout like taking days
to process a transaction after finalizing all settlements, which can be corrupted
easily. On the other hand, blockchain offers a faster settlement compared to
traditional banking systems. This blockchain feature helps make life easier.
Blockchain technology is increasing and improving day by day and has a really
bright future in the upcoming years. The transparency, trust, and temper proof
characteristics have led to many applications of it like bitcoin, Ethereum, etc. It is a
pillar in making the business and governmental procedures more secure, efficient,
and effective.
These protocols are nothing more than algorithms that control all activity on a
blockchain network. In this article, we will discuss the various consensus protocols
used the blockchain network, including the advantages and disadvantages these
protocols, and in which situations they are most useful. We will be looking at the
following consensus protocols:
The first consensus protocol used in the blockchain network was Proof of Work
(PoW). Cynthia Dwork and Moni Naor introduced it in 1993, and Satoshi
Nakamoto, the creator of the Bitcoin network, reintroduced it in 2008.
Using the public and private keys assigned to each user, each transaction is
validated and signed.
The PoW consensus is best used by a developer who wants to create applications
that require security or node management identity, where users will need to be
identified, authorized, or authenticated before accessing services or systems.
Bitcoin, one of the largest blockchain networks, adopted this protocol.
Advantages of PoW
One of the advantages of PoW is that it is highly scalable, meaning it is good for
variety of applications like cryptocurrency mining, validation transaction, or
mining new tokens.
Disadvantages of PoW
A disadvantage of the PoW is the probability of a “51% attack”. This is the point at
which a single attacker gains control of more than half of the network’s computing
power, rendering decentralization ineffective.
Unlike PoW, which validates blocks using a cryptographic hash function, PoS
validates blocks based on the stake of the validators (miners), where validators will
stake a portion of their cryptocurrency.
These validators are chosen at random by PoS based on the amount allocated. The
higher a validator’s stakes, the more likely they are to be chosen.
Ethereum, one of the largest blockchain networks, adopted the PoS protocol to
improve network scalability and reduce electricity consumption.
Disadvantages of PoS
A disadvantage of PoS is that an attacker can revert the victim’s transactions and
bribe the miners to confirm them.
Secondly, PoS benefits the wealthy. Mining power in Proof of Stake is determined
by the number of coins staked by a validator. Participants who stake more coins
have a better chance of being chosen to add new blocks.
Byzantine model:
In the Byzantine Generals Problem, the untampered agreement that all the loyal
generals need to agree to is the blockchain. Blockchain is a public, distributed
ledger that contains the records of all transactions. If all users of the Bitcoin
network, known as nodes, could agree on which transactions occurred and in
what order, they could verify the ownership and create a functioning, trustless
money system without the need for a centralized authority. Due to its
decentralized nature, blockchain relies heavily on a consensus technique to
validate transactions. It is a peer-to-peer network that offers its users transparency
as well as trust. Its distributed ledger is what sets it apart from other systems.
Blockchain technology can be applied to any system that requires proper
verification.
Proof Of Work: The network would have to be provable, counterfeit-resistant,
and trust-free in order to solve the Byzantine General’s Problem. Bitcoin
overcame the Byzantine General’s Problem by employing a Proof-of-Work
technique to create a clear, objective regulation for the blockchain. Proof of work
(PoW) is a method of adding fresh blocks of transactions to the blockchain of a
cryptocurrency. In this scenario, the task consists of creating a hash (a long string
of characters) that matches the desired hash for the current block.
1. Counterfeit Resistant: Proof-of-Work requires network participants to
present proof of their work in the form of a valid hash in order for their block,
i.e. piece of information, to be regarded as valid. Proof-of-Work requires
miners to expend significant amounts of energy and money in order to
generate blocks, encouraging them to broadcast accurate information and so
protecting the network. Proof-of-Work is one of the only ways for a
decentralized network to agree on a single source of truth, which is essential
for a monetary system. There can be no disagreement or tampering with the
information on the blockchain network because the rules are objective. The
ruleset defining which transactions are valid and which are invalid, as well as
the system for choosing who can mint new bitcoin, are both objectives.
2. Provable: Once a block is uploaded to the blockchain, it is incredibly difficult
to erase, rendering Bitcoin’s history immutable. As a result, participants of the
blockchain network may always agree on the state of the blockchain and all
transactions inside it. Each node independently verifies whether blocks satisfy
the Proof-of-Work criterion and whether transactions satisfy additional
requirements.
3. Trust-free: If any network member attempts to broadcast misleading
information, all network nodes immediately detect it as objectively invalid and
ignore it. Because each node on the Bitcoin network can verify every
information on the network, there is no need to trust other network members,
making Bitcoin a trustless system.
In order to address this issue, honest nodes (such as computers or other physical
devices) must be able to establish an agreement in the presence of dishonest
nodes.
In the Byzantine agreement issue, an arbitrary processor initializes a single
value that must be agreed upon, and all nonfaulty processes must agree on that
value. Every processor has its own beginning value in the consensus issue, and
all nonfaulty processors must agree on a single common value.
The Byzantine army’s position can be seen in computer networks.
The divisions can be viewed as computer nodes in the network, and the
commanders as programs running a ledger that records transactions and events
in the order that they occur. The ledgers are the same for all systems, and if
any of them is changed, the other ledgers are updated as well if the changes
are shown to be true, so all distributed ledgers should be in agreement.
Hashing:
Markle tree:
A hash tree is also known as Merkle Tree. It is a tree in which each leaf node is
labeled with the hash value of a data block and each non-leaf node is labeled with
the hash value of its child nodes labels.
A regular pointer stores the memory address of data. With this pointer, the data
can be accessed easily. On the other hand, a hash pointer is a pointer to where
data is stored and with the pointer, the cryptographic hash of the data is also
stored. So a hash pointer points to the data and also allows us to verify the data. A
hash pointer can be used to build all kinds of data structures such as blockchain
and Merkle tree.
Blockchain Structure
Block Structure
1. Block header: The header data contains metadata of the block, i.e information
about the block itself. The contents of the block header include-
Hash of the previous block header.
Hash of the current block.
Timestamp.
Cryptographic nonce.
Merkle root.
2. Merkle tree: A Merkle tree is a binary tree formed by hash pointers, and
named after its creator, Ralph Merkle.
As mentioned earlier, each block is supposed to hold a certain number of
transactions. Now the question arises, how to store these transactions within a
block? One approach can be to form a hash pointer-based linked list of
transactions and store this complete linked list in a block. However, when we
put this approach into perspective, it does not seem practical to store a huge
list of hundreds of transactions. What if there is a need to find whether a
particular transaction belongs to a block? Then we will have to traverse the
blocks one by one and within each block traverse the linked list of
transactions.
This is a huge overhead and can reduce the efficiency of the blockchain. Now,
this is where the Merkle tree comes into the picture. Merkle tree is a per-block
tree of all the transactions that are included in the block. It allows us to have a
hash/digest of all transactions and provides proof of membership in a time-
efficient manner.
So to recap, the blockchain is a hash-based linked list of blocks, where each
block consists of a header and transactions. The transactions are arranged in a
tree-like fashion, known as the Merkle tree.
Each block comprises of block header + Merkle tree
A Merkle tree is constructed from the leaf nodes level all the way up to the
Merkle root level by grouping nodes in pairs and calculating the hash of each
pair of nodes in that particular level. This hash value is propagated to the next
level. This is a bottom-to-up type of construction where the hash values are
flowing from down to up direction.
Hence, by comparing the Merkle tree structure to a regular binary tree data
structure, one can observe that Merkle trees are actually inverted down.
Binary tree direction vs Merkle tree direction
Example: Consider a block having 4 transactions- T1, T2, T3, T4. These four
transactions have to be stored in the Merkle tree and this is done by the following
steps-
Step 1: The hash of each transaction is computed.
H1 = Hash(T1).
Step 2: The hashes computed are stored in leaf nodes of the Merkle tree.
Step 3: Now non-leaf nodes will be formed. In order to form these nodes, leaf
nodes will be paired together from left to right, and the hash of these pairs will be
calculated. Firstly hash of H1 and H2 will be computed to form H12. Similarly,
H34 is computed. Values H12 and H34 are parent nodes of H1, H2, and H3, H4
respectively. These are non-leaf nodes.
H12 = Hash(H1 + H2)
H34 = Hash(H3 + H4)
Step 4: Finally H1234 is computed by pairing H12 and H34. H1234 is the only
hash remaining. This means we have reached the root node and therefore H1234
is the Merkle root.
H1234 = Hash(H12 + H34)
Merkle tree works by hashing child nodes again and again till only one hash
remains.
Key Points:
In order to check whether the transaction has tampered with the tree, there is
only a need to remember the root of the tree.
One can access the transactions by traversing through the hash pointers and if
any content has been changed in the transaction, this will reflect on the hash
stored in the parent node, which in turn would affect the hash in the upper-
level node and so on until the root is reached.
Hence the root of the Merkle tree has also changed. So Merkle root which is
stored in the block header makes transactions tamper-proof and validates the
integrity of data.
With the help of the Merkle root, the Merkle tree helps in eliminating
duplicate or false transactions in a block.
It generates a digital fingerprint of all transactions in a block and the Merkle
root in the header is further protected by the hash of the block header stored in
the next block.
Why Merkle Trees are Important For Blockchain?
In a centralized network, data can be accessed from one single copy. This
means that nodes do not have to take the responsibility of storing their own
copies of data and data can be retrieved quickly.
However, the situation is not so simple in a distributed system.
Let us consider a scenario where blockchain does not have Merkle trees. In
this case, every node in the network will have to keep a record of every single
transaction that has occurred because there is no central copy of the
information.
This means that a huge amount of information will have to be stored on every
node and every node will have its own copy of the ledger. If a node wants to
validate a past transaction, requests will have to be sent to all nodes,
requesting their copy of the ledger. Then the user will have to compare its own
copy with the copies obtained from several nodes.
Any mismatch could compromise the security of the blockchain. Further on,
such verification requests will require huge amounts of data to be sent over the
network, and the computer performing this verification will need a lot of
processing power for comparing different versions of ledgers.
Without the Merkle tree, the data itself has to be transferred all over the
network for verification.
Merkle trees allow comparison and verification of transactions with viable
computational power and bandwidth. Only a small amount of information
needs to be sent, hence compensating for the huge volumes of ledger data that
had to be exchanged previously.
Merkle trees use a one-way hash function extensively and this hashing separates
the proof of data from data itself
Proof of Membership
Merkle tree.
If there are n nodes in the tree then only log(n) nodes need to be examined. Hence
even if there are a large number of nodes in the Merkle tree, proof of membership
can be computed in a relatively short time.
Merkle Proofs
Gas limit:
The gas limit is like setting a budget for how much you’re willing to spend on
sending a transaction or running a program on a blockchain, like Ethereum. It stops
your transaction from using up too much of the blockchain’s energy. Think of it
like telling a taxi driver the most you’ll pay for a ride. If the ride costs more than
your budget, you won’t get to your destination. If it costs less, you only pay for the
distance covered.
What is the Purpose of Gas Limit?
Over the ETH network, the processing of pending transactions depends on the gas
limit that each transaction is willing to spend on the block. The Ethereum Virtual
Machine processes every transaction and requires some amount of gas fees for
execution. Each block has its gas limit. While creating a block, designated users
must remember that the total transactional gas limit is not to exceed the block’s gas
limit. Thus, every transaction’s gas limit has to be carefully decided.
How do Gas Limits Work?
Gas fees provide each node involved some incentive to add a new block to the
chain and execute a transaction. Now, they may charge very high depending upon
the traffic on the chain. The gas limit controls the users over how much they spend
on executing a transaction. A simulator suggests average gas fees to the users, who
can then decide whether they want to keep the gas limit equal to the average,
higher, or lower. A higher gas limit will get your transaction processed faster since
the designated node would get to charge more. A lower gas limit will keep you in
the queue until any willing node decides to execute the transaction. Usually, people
keep the cryptocurrency gas limit equal to the average gas fees.
Transaction fee:
Blockchain transaction fees are an essential aspect of the decentralized digital
currency system. In this comprehensive guide, we will explore what blockchain
transaction fees are, how they are determined, the different types of fees, how to
calculate them, and techniques to minimize these fees. So, whether you are a
crypto enthusiast, investor, or just curious about the technology behind digital
currencies, this guide will provide you with valuable insights into blockchain
transaction fees.
But what happens to the transaction fees once they are collected by the miners?
Well, these fees become part of the miner’s revenue. In addition to the block
reward, which is a predetermined amount of cryptocurrency given to the miner for
successfully mining a block, transaction fees contribute to their earnings. This dual
incentive system ensures that miners have a vested interest in maintaining the
integrity and security of the blockchain network.
Lastly, the urgency of the transaction also affects the fees. If you need your
transaction to be confirmed quickly, you may opt to pay a higher fee to incentivize
miners to prioritize it. This is particularly important for time-sensitive transactions,
such as buying a limited-edition item or participating in a time-limited token sale.
Anonymity:
Chain policy:
Forks in Blockchain are two types: Soft Fork and Hard Fork.
Soft Fork
A soft fork is a software upgrade that is backwards compatible with older versions.
This means that participants that did not upgrade to the new software will still be
able to participate in validating and verifying transactions.
Hence, soft forks represent a gradual upgrading mechanism as those who have yet
to upgrade their software is incentivized to do so, or risk having reduced
functionalities.
Hard Fork
Hard forks refer to a software upgrade that isn’t compatible with older versions.
All participants must upgrade to the new software to continue participating and
validating new transactions. Those who didn’t upgrade would be separated from
the network and cannot validate the new transactions. This separation results in a
permanent divergence of the Blockchain.
Ethere
um Classic is a Blockchain-based open source platform that enables smart
contracts and has a full Turing programming language. Source: Wikipedia
Ethereum had a hard fork to reverse the effects of a hack that occurred in one of
their applications (called the Decentralized Autonomous Organization or simply,
DAO).
As Ethereum’s core developers and the majority of its community went ahead with
the hard fork, the minority that stayed behind and didn’t upgrade their software
continued to mine what is now known as Ethereum Classic (ETC).
It’s important to note that since the majority transited to the new chain, they still
retained the original ETH symbol, while the minority supporting the old chain
were given the term Ethereum Classic or ETC.
Bitcoin Cash
Bitcoi
n was forked to create Bitcoin Cash because the developers of Bitcoin wanted to
make some important changes to Bitcoin. Source: Wikipedia
Bitcoin Cash is a cryptocurrency that is a fork of Bitcoin. Bitcoin Cash is a spin-off
or altcoin that was created in 2017. In 2018 Bitcoin Cash subsequently split into
two cryptocurrencies: Bitcoin Cash, and Bitcoin. Bitcoin Cash is sometimes also
referred to as Bcash.
Bitcoin was forked to create Bitcoin Cash because the developers of Bitcoin
wanted to make some important changes to Bitcoin. The developers of the Bitcoin
community could not come to an agreement concerning some of the changes that
they wanted to make. So, a small group of these developers forked Bitcoin to
create a new version of the same code with a few modifications.
The changes that make all the difference between Bitcoin Cash vs Bitcoin are
these:
Bitcoin Cash has cheaper transfer fees, so making transactions in BCH will
save you more money than using BTC.
BCH has faster transfer times. So, you don’t have to wait the 10 minutes it
takes to verify a Bitcoin transaction!
BCH can handle more transactions per second. This means that more people
can use BCH at the same time than they can with BTC.
Types of Blockchain
Permissionless Blockchain
These are the closed network only a set of groups are allowed to validate
transactions or data in a given blockchain network. These are used in the network
where high privacy and security are required.
Characteristics:
A major feature is a transparency based on the objective of the organization.
Another feature is the lack of anatomy as only a limited number of users are
allowed.
It does not have a central authority.
Developed by private authority.
Advantages:
This blockchain tends to be faster as it has some nodes for validations.
They can offer customizability.
Strong Privacy as permission is needed for accessing transaction information.
As few nodes are involved performance and scalability are increased.
Disadvantages:
Not truly decentralized as it requires permission
Risk of corruption as only a few participants are involved.
Anytime owner and operator can change the rules as per their need.
Types of Blockchain
1. Public Blockchain
2. Private Blockchain
These blockchains are not as decentralized as the public blockchain only selected
nodes can participate in the process, making it more secure than the others.
These are not as open as a public blockchain.
They are open to some authorized users only.
These blockchains are operated in a closed network.
In this few people are allowed to participate in a network within a
company/organization.
Advantages:
Speed: The rate of the transaction is high, due to its small size. Verification of
each node is less time-consuming.
Scalability: We can modify the scalability. The size of the network can be
decided manually.
Privacy: It has increased the level of privacy for confidentiality reasons as the
businesses required.
Balanced: It is more balanced as only some user has the access to the
transaction which improves the performance of the network.
Disadvantages:
Security- The number of nodes in this type is limited so chances of
manipulation are there. These blockchains are more vulnerable.
Centralized- Trust building is one of the main disadvantages due to its central
nature. Organizations can use this for malpractices.
Count- Since there are few nodes if nodes go offline the entire system of
blockchain can be endangered.
Use Cases: With proper security and maintenance, this blockchain is a great asset
to secure information without exposing it to the public eye. Therefore companies
use them for internal auditing, voting, and asset management. An example of
private blockchains is Hyperledger, Corda.
3. Hybrid Blockchain
It is the mixed content of the private and public blockchain, where some part is
controlled by some organization and other makes are made visible as a public
blockchain.
It is a combination of both public and private blockchain.
Permission-based and permissionless systems are used.
User access information via smart contracts
Even a primary entity owns a hybrid blockchain it cannot alter the transaction
Advantages:
Ecosystem: Most advantageous thing about this blockchain is its hybrid
nature. It cannot be hacked as 51% of users don’t have access to the network
Cost: Transactions are cheap as only a few nodes verify the transaction. All
the nodes don’t carry the verification hence less computational cost.
Architecture: It is highly customizable and still maintains integrity, security,
and transparency.
Operations: It can choose the participants in the blockchain and decide which
transaction can be made public.
Disadvantages:
Efficiency: Not everyone is in the position to implement a hybrid Blockchain.
The organization also faces some difficulty in terms of efficiency in
maintenance.
Transparency: There is a possibility that someone can hide information from
the user. If someone wants to get access through a hybrid blockchain it
depends on the organization whether they will give or not.
Ecosystem: Due to its closed ecosystem this blockchain lacks the incentives
for network participation.
Use Case: It provides a greater solution to the health care industry, government,
real estate, and financial companies. It provides a remedy where data is to be
accessed publicly but needs to be shielded privately. Examples of Hybrid
Blockchain are Ripple network and XRP token.
4. Consortium Blockchain
It is a creative approach that solves the needs of the organization. This blockchain
validates the transaction and also initiates or receives transactions.
Also known as Federated Blockchain.
This is an innovative method to solve the organization’s needs.
Some part is public and some part is private.
In this type, more than one organization manages the blockchain.
Advantages:
Speed: A limited number of users make verification fast. The high speed
makes this more usable for organizations.
Authority: Multiple organizations can take part and make it decentralized at
every level. Decentralized authority, makes it more secure.
Privacy: The information of the checked blocks is unknown to the public
view. but any member belonging to the blockchain can access it.
Flexible: There is much divergence in the flexibility of the blockchain. Since
it is not a very large decision can be taken faster.
Disadvantages:
Approval: All the members approve the protocol making it less flexible.
Since one or more organizations are involved there can be differences in the
vision of interest.
Transparency: It can be hacked if the organization becomes corrupt.
Organizations may hide information from the users.
Vulnerability: If few nodes are getting compromised there is a greater chance
of vulnerability in this blockchain
Use Cases: It has high potential in businesses, banks, and other payment
processors. Food tracking of the organizations frequently collaborates with their
sectors making it a federated solution ideal for their use. Examples of consortium
Blockchain are Tendermint and Multichain.