Uploaded by Mining Books

U1

advertisement
Unit-1
Distributed Systems:
Distributed systems are like a team of computers working together towards a common goal, even though
they are physically separate. They communicate with each other to achieve tasks, appearing as a single
system to users. This concept is crucial in understanding blockchain technology, which is essentially a
distributed ledger system where information is shared across multiple locations.
Electronic Cash:
Electronic cash, or digital currency, has been around since the 1980s. It involves using digital tokens for
transactions, ensuring accountability (to prevent double-spending) and anonymity (to protect user
privacy). Two fundamental issues that need to be addressed in e-cash systems are:
Accountability: Ensuring cash is spendable only once (double-spend problem) and only by its rightful
owner.
Anonymity: Protecting users' privacy, similar to physical cash.
 David Chaum solved these problems in the 1980s using cryptographic operations like blind
signatures and secret sharing.
 Blind signatures allow signing a document without seeing it, while secret sharing enables
detecting double spending.
Blockchain:
Blockchain is a peer-to-peer, distributed ledger that is cryptographically-secure, append-only, immutable
(extremely hard to change), and updateable only via consensus or agreement among peers.
Bitcoin is a decentralized digital currency that operates on a peer-to-peer network, allowing users to send
and receive payments without the need for a central authority. It was introduced in 2009 as the first
practical implementation of electronic cash, solving the problem of distributed consensus in a trustless
network using public key cryptography and a Proof of Work (PoW) mechanism.
Blockchain: Blockchain was born with Bitcoin in 2008, offering a secure and decentralized way to
manage digital currency transactions. It uses cryptographic techniques and a Proof of Work mechanism
to ensure security.
How a blockchain works:
 Node Roles: Nodes in a blockchain network can be miners who create new blocks and mint
cryptocurrency or block signers who validate and digitally sign transactions.
 Consensus Mechanism: The decision on which node appends the next block to the blockchain
is made using a consensus mechanism, a critical aspect of blockchain networks.
 Transaction Validation: Transactions are validated by nodes based on preset criteria before being
included in a block and propagated onto the network.
 Block Creation: A node starts a transaction, digitally signs it, and propagates it to peers for
validation. Once validated, the transaction is included in a block, which becomes part of the
ledger.
 Block Confirmation: Each new block cryptographically links back to the previous block,
providing confirmation to the transactions within. Transactions are reconfirmed with each new
block, typically requiring multiple confirmations for finality.
This process ensures the integrity and security of transactions on the blockchain network, with each step
contributing to the verification and confirmation of transactions and blocks.
The generic elements of a blockchain include:
Address: Unique identifiers used in blockchain transactions to denote senders and recipients. Addresses
are usually public keys or derived from public keys. It is recommended for users to generate a new
address for each transaction to maintain anonymity and prevent identification.
Transaction: The fundamental unit of a blockchain representing a transfer of value from one address to
another.
Block: Composed of multiple transactions and other elements like the previous block hash, timestamp,
and nonce.
Peer-to-peer network: A network where all peers can communicate with each other and send/receive
messages.
Scripting or programming language: Programs that perform operations on transactions. In Bitcoin,
transaction scripts are predefined in a language called Script.
Virtual machine: Allows Turing complete code to run on a blockchain, enabling smart contracts.
State machine: Modifies the state of a blockchain from initial to final form through transaction
execution and validation.
Node: Performs various functions like proposing and validating transactions, mining, and transaction
signing.
Smart contract: Programs that run on top of the blockchain, executing business logic when specific
conditions are met. They are enforceable and automatically executable, providing flexibility and power
to blockchain applications.
These elements play crucial roles in the functioning and structure of a blockchain network, facilitating
transactions, consensus, security, and the execution of smart contracts.
Benefits and Limitations of Blockchain
Blockchain technology offers improved security, transparency, and efficiency in various sectors.
However, challenges like scalability and energy consumption exist.
The key benefits of blockchain technology include:
 Decentralization: No need for a trusted third party, as consensus mechanisms are used to validate
transactions.
 Transparency and trust: Shared ledger allows everyone to see the data, establishing trust.
 Immutability: Once data is written to the blockchain, it is extremely difficult to change.
 High availability: Replicated data on thousands of nodes in a peer-to-peer network ensures high
availability.
 Security: Transactions are cryptographically secured, providing network integrity.
 Simplification: Serves as a single shared ledger, reducing complexity of managing separate
databases.
 Faster dealings: Enables quick settlement of trades without lengthy verification processes.
 Cost savings: Eliminates overhead costs paid to trusted third parties.
Blockchain technology challenges that need to be addressed:





Scalability
Adaptability
Regulation
Relatively immature technology
Privacy
These issues are actively being researched in academia and industry to make blockchain more robust and
accessible.
Tiers of Blockchain Technology
Blockchain has evolved through different stages: Blockchain 1.0 focused on cryptocurrencies like
Bitcoin, while Blockchain 2.0 expanded to financial services and smart contracts. Blockchain 3.0
broadened its applications to various industries beyond finance.
Blockchain 1.0: Introduced with Bitcoin, primarily used for cryptocurrencies. Includes core applications
such as payments. This generation started in 2009 when Bitcoin was released and ended in early 2010.
Blockchain 2.0: Used by financial services and smart contracts. Includes various financial assets like
derivatives, options, swaps, and bonds. Applications beyond currency, finance, and markets are
incorporated. Ethereum, Hyperledger, and other newer blockchain platforms are considered part of
Blockchain 2.0. This generation started when ideas related to using blockchain for other purposes
emerged in 2010.
Blockchain 3.0: Used to implement applications beyond financial services, such as government, health,
media, arts, and justice. Ethereum, Hyperledger, and newer blockchains with smart contract capabilities
are considered part of this tier. This generation emerged around 2012 when multiple blockchain
applications in different industries were researched.
Blockchain X.0, representing a future where there will be a public blockchain service available to
anyone, providing services for all realms of society. It will be a public and open distributed ledger with
general-purpose rational agents (Machina economicus) running on a blockchain, making decisions, and
interacting with other intelligent autonomous agents on behalf of people, regulated by code instead of
law or paper contracts.
Features of a Blockchain
Distributed Consensus: The primary underpinning of a blockchain, allowing a single version of the
truth to be agreed upon by all parties without a central authority.
Append-Only: Once data is added to a blockchain, it cannot be altered, ensuring data integrity.
Immutability: Once data is added to a blockchain, it is extremely difficult to change, making the records
essentially immutable.
Updateable via Consensus: Changes to a blockchain can only be made if all participants agree,
maintaining trust and transparency.
Transaction Verification: Transactions are verified based on predetermined rules, with only valid
transactions selected for inclusion in a block.
Smart Contracts Platform: Programs can run on a blockchain to execute business logic when certain
conditions are met. Not all blockchains support smart contracts, but it is a desirable feature available on
newer platforms like Ethereum.
Value Transfer: Blockchains enable the transfer of value between users via tokens.
Cryptocurrency Generation: Some blockchains create cryptocurrency as an incentive for miners who
validate transactions and secure the network.
Smart Property: Digital or physical assets can be linked to a blockchain in a secure way that prevents
double-ownership or double-spending.
Security: Blockchains use cryptography to ensure data integrity and availability, though confidentiality
is generally not provided due to transparency requirements.
Uniqueness: Blockchains ensure each transaction is unique and has not been previously spent, crucial
for preventing double-spending in cryptocurrencies.
These features enable blockchains to perform functions like transferring value, managing assets, and
executing agreements in a decentralized, secure, and transparent manner.
Types of blockchain
The types of blockchain can be categorized as follows:
Distributed Ledgers: These are shared databases where all blockchains technically fall under this
category. Not all distributed ledgers consist of blocks of transactions like a blockchain does. Examples
include R3's Corda, which focuses on managing agreements in the financial services industry.
Distributed Ledger Technology (DLT): The terms DLT and blockchain are often used interchangeably,
especially in the finance sector. DLTs are permissioned blockchains shared among known participants,
serving as a shared database without the need for cryptocurrency or mining to secure the ledger.
Public Blockchains:

Open to the public, anyone can participate as a node.

Users may or may not be rewarded for participation.

Users maintain a copy of the ledger and use distributed consensus to decide the state.

Examples include Bitcoin and Ethereum.
Private Blockchains:

Open only to a consortium or group of individuals/organizations sharing the ledger

Examples include HydraChain and Quorum

Can optionally run in public mode, but primary purpose is to provide a private blockchain.
Semi-Private Blockchains:

Part of the blockchain is private, part is public (still just a concept, no real-world examples yet).

Private part controlled by a group, public part open for participation by anyone.

Can use PoW to secure both private and public parts, providing consistency and validity.
Permissioned Ledgers:

Participants are known and trusted, no need for distributed consensus

Use an agreement protocol to maintain a shared truth about the state of records

Verifiers preselected by a central authority, typically no mining needed

Can be public with regulated access control.
The key distinction is between public blockchains open to anyone, and private/permissioned blockchains
restricted to known participants. Semi-private blockchains aim to combine aspects of both. All
blockchains are fundamentally distributed ledgers, but not all distributed ledgers use blocks like a
blockchain.
Sidechains:

Sidechains allow coins to move between different blockchains and back, enhancing flexibility
and functionality.

They can be one-way or two-way pegged, enabling the movement of coins for various purposes
like creating new altcoins.

Proof of Burn (PoB) is a mechanism used in sidechains, where coins are sent to an unspendable
address to introduce scarcity and increase coin value.

Sidechains like Rootstock enable smart contract development for Bitcoin, providing faster
throughput by allowing a two-way peg with the Bitcoin blockchain.
Permissioned Ledger:

In a permissioned ledger, participants are known and trusted, eliminating the need for a distributed
consensus mechanism.

An agreement protocol is used to maintain a shared truth about the state of records, with verifiers
preselected by a central authority.

Permissioned ledgers can be public with regulated access control, ensuring identity verification
before granting access.
Shared Ledger:

A shared ledger is a generic term describing any application or database shared by the public or a
consortium.

Generally, all blockchains fall under the category of a shared ledger, emphasizing transparency
and data sharing among participants.
Fully private and proprietary blockchains:
Fully private and proprietary blockchains deviate from the core concept of decentralization in blockchain
technology and have no mainstream applications. However, in specific private settings within an
organization, there could be a need to share data and provide some level of guarantee of data authenticity.
An example is allowing collaboration and data sharing between government departments. In such cases,
no complex consensus mechanism is required, just simple state machine replication and an agreement
protocol with known central validators.
Tokenized blockchains:
Tokenized blockchains are standard blockchains that generate cryptocurrency as a result of consensus
via mining or initial distribution. Bitcoin and Ethereum are prime examples. Tokens are not really
required in private blockchains, but can be used to transfer value or represent real-world assets.
Tokenless blockchains:
Tokenless blockchains do not have a basic unit for value transfer. However, they are valuable for sharing
data among trusted parties where value transfer is not needed. This is similar to fully private blockchains,
but without requiring tokens. Tokenless blockchains provide immutability, security and consensusdriven updates, but are not used for common blockchain applications like value transfer or
cryptocurrency.
Consensus
Consensus involves reaching an agreement among distrusting nodes on the final state of data. While it
is relatively easy to achieve agreement between two nodes in client-server systems, achieving consensus
among multiple nodes in a distributed system can be challenging. This process of attaining a common
state or value among multiple nodes, despite potential node failures, is known as distributed consensus.
Consensus mechanism
The consensus mechanism in blockchain technology is a critical set of steps taken by most or all nodes
in a blockchain to agree on a proposed state or value. Consensus mechanisms ensure that all parties in
the network agree on the final state of data, providing a shared truth that is resolutely agreed upon as
accurate.
Key Requirements of a Consensus Mechanism include:

Agreement: All honest nodes must decide on the same value.

Termination: Honest nodes should eventually reach a decision and terminate the consensus
process.

Validity: The agreed-upon value by honest nodes must match the initial proposal by at least one
honest node.

Fault Tolerance: The consensus algorithm should function even in the presence of faulty or
malicious nodes (Byzantine nodes).

Integrity: No node should be able to make a decision more than once in a single consensus cycle.
These requirements ensure the reliability, security, and integrity of the consensus process in blockchain
networks, facilitating trust and agreement among participants.
The types of consensus mechanisms
A consensus algorithm is a mechanism used in distributed systems to agree on the same data among
different computers. This allows a system to operate like a single computer but with more resources,
such as the number of requests it can handle.
1. Byzantine Fault Tolerance (BFT)-based:

This mechanism relies on a simple scheme where nodes publish signed messages, and an
agreement is reached when a certain number of messages are received.

It does not involve compute-intensive operations like partial hash inversion seen in
Bitcoin's Proof of Work (PoW) mechanism.
2. Leader Election-based Consensus Mechanisms:

Nodes compete in a leader-election lottery, and the winning node proposes a final value.

An example is the PoW mechanism used in Bitcoin, where nodes compete to solve
complex mathematical puzzles to propose new blocks.
3. Crash Fault Tolerance (CFT):
CFT is a term given to the algorithms that solve the problem of nodes crashing simply. So, even
if we have a decentralized system where nodes can halt or disconnect from the network, we
maintain the same state of truth on the system. From a security perspective, the strength of a
consensus protocol is usually measured by the number of faulty components it can tolerate.
Specifically, if a consensus protocol can tolerate at least one crash failure, we call it crash-fault
tolerant (CFT).
Paxos and RAFT

Paxos: Introduced by Leslie Lamport in 1989, it assigns nodes roles like Proposer,
Acceptor, and Learner to achieve consensus in the presence of faulty nodes by agreement
among a majority of nodes.

RAFT: This mechanism assigns nodes states like follower, candidate, or leader. A leader
is elected after a candidate node receives enough votes, and all changes must go through
the leader for approval.
These consensus mechanisms play a crucial role in ensuring agreement and finality in distributed systems
like blockchain networks, providing a foundation for trust and reliability in decentralized environments.
Consensus Mechanisms in Blockchain:
Consensus mechanisms play a vital role in blockchain networks, ensuring agreement and finality among
participants. various consensus mechanisms:
1. Proof of Work (PoW):

Relies on computational resources to propose a value for network acceptance.

Used in Bitcoin and other cryptocurrency blockchains.

Successful against collusion attacks like the Sybil attack.
2. Proof of Stake (PoS):

Based on the idea that a node's stake in the system deters malicious behavior.

Introduced by Peercoin and to be used in Ethereum's Serenity version.

Coin age influences the chances of proposing and signing the next block.
3. Delegated Proof of Stake (DPoS):

Allows nodes to delegate transaction validation to others by voting.

Implemented in the BitShares blockchain.
4. Proof of Elapsed Time (PoET):

Introduced by Intel, uses Trusted Execution Environment for leader election.

Requires Intel Software Guard Extensions (SGX) for security.
5. Proof of Deposit (PoD):

Nodes must make a security deposit to participate in the network.

Utilized in the Tendermint blockchain.
6. Proof of Importance (PoI):

Monitors token usage and movement to establish trust and importance.

Used in the NEM coin blockchain.
7. Federated Consensus:

Nodes retain a group of trusted peers and propagate validated transactions.

Implemented in the Stellar consensus protocol.
8. PBFT (Practical Byzantine Fault Tolerance):

Achieves state machine replication, providing tolerance against Byzantine nodes.

Used in various distributed systems and blockchains.
9. Proof of Activity (PoA):

Combines PoS and PoW to select stakeholders in a pseudorandom but uniform manner.

More energy-efficient compared to PoW.
10. Proof of Capacity (PoC):

Utilizes hard disk space for mining blocks, known as hard drive mining.

Introduced in the Burstcoin cryptocurrency.
11. Proof of Storage (PoS):

Allows outsourcing of storage capacity, based on the concept of data storage by nodes.

Variations include Proof of Replication, Proof of Data Possession, Proof of Space, and
Proof of Space-Time.
BFT-based consensus mechanisms perform well when there are a limited number of nodes, but they do
not scale well. On the other hand, leader-election lottery based (PoW) type consensus mechanisms scale
very well but perform very slowly. These consensus mechanisms cater to different needs within
blockchain networks, ensuring trust, security, and agreement among participants.
CAP theorem and blockchain:
The CAP theorem, introduced by Eric Brewer in 1998 and proven in 2002, states that a distributed system
cannot simultaneously achieve consistency, availability, and partition tolerance.

Consistency ensures all nodes in a distributed system have an identical copy of the
data. Availability means the nodes are up, accessible, and responding with data as
required. Partition tolerance ensures the system operates correctly even if a group of nodes can’t
communicate with others due to network failures.

In a scenario where a partition occurs and nodes can no longer communicate with each other, both
availability and consistency are unachievable due to partition tolerance.

Blockchain seems to violate the CAP theorem, especially in its most successful implementation,
Bitcoin. However, in blockchains, consistency is sacrificed in favor of availability and partition
tolerance. This is called eventual consistency, where consistency is achieved over time as a result
of validation from multiple nodes.

To achieve fault tolerance, replication is used. Consistency is achieved using consensus
algorithms to ensure all nodes have the same copy of the data. This is also called state machine
replication.

There are two types of faults that a node can experience: Fail-stop fault, where a node merely
has crashed, and Byzantine faults, where the faulty node exhibits malicious or inconsistent
behavior arbitrarily. State machine replication protocols such as PBFT were developed to address
Byzantine faults.

The concept of mining was introduced in Bitcoin to facilitate the achievement of consensus by
using the Proof of Work (PoW) consensus algorithm. Mining is a process that is used to add more
blocks to the blockchain.
Download