0% found this document useful (0 votes)
10 views23 pages

Blockchain Lecture 3

Uploaded by

Love Jhala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views23 pages

Blockchain Lecture 3

Uploaded by

Love Jhala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Course:

Introduction to Blockchain: Technologies, Approaches


and Applications

Lecture 3
Blockchain – Technical Details
Sanjay Chaudhary

School of Engineering and Applied Science


Ahmedabad University
Ahmedabad, Gujarat, India
Structure of Block

Lecture 3 Blockchain Technical Details 2


Block
• Block is a container data structure that aggregates
transactions for inclusion in public ledger

Version Header
Previous Block Hash
Merkle Root (Hash Value)
Time Stamp
Difficulty Target
Nonce
Transaction 1
Transaction 2
Transaction 3
Transaction 4
Transaction 5

Lecture 3 Blockchain Technical Details 3


Blockchain
• The blockchain data structure is an ordered, back-linked
list of blocks of transactions.

Block # 0 Block # 1 Block # 2 Block # 3

Genesis Block

Lecture 3 Blockchain Technical Details 4


The Structure of a Block
Size Field Description
4 bytes Block Size The size of the block, in bytes, following this field
80 bytes Block Header Several fields form block header
1-9 bytes Transaction Counter How many transactions follow
Variable Transactions The transactions recorded in this block

Lecture 3 Blockchain Technical Details 5


The Structure of a Block Header
Size Field Description
4 bytes Version Version number of Software/Protocol
32 bytes Previous Block Hash Hash of the parent block in the chain
32 bytes Merkle Root Hash of the root of Merkle tree of this block’s
transactions
4 bytes Timestamp Creation of time of this block
4 bytes Difficulty Target PoW difficulty target for this block
4 bytes Nonce Counter used for PoW

Lecture 3 Blockchain Technical Details 6


Merkle Root
Block # 0 Block # 1 Block # 2 Block # 3

Merkle Root
Tx 1
Tx 2
Tx 3
Tx 4

Genesis Block
Root Hash ()

Hash (H1 | H2) Hash (H3 | H4)

Hash(Tx 1) Hash(Tx 2) Hash(Tx 3) Hash(Tx 4)

Tx 1 Tx 2 Tx 3 Tx 4

Lecture 3 Blockchain Technical Details 7


Identification of a Block
• Block Header Hash
• Block Height

Lecture 3 Blockchain Technical Details 8


Block Header Hash
• Primary identifier of the block
• Identifies a block
• Uniquely
• Unambiguously
• Can be independently derived by any node
• Digital Fingerprint
• Block’s Cryptographic Hash
• Block header is hashed twice with SHA256
• 32 byte hash

Lecture 3 Blockchain Technical Details 9


Block Height
• When Blockchain is visualized as a vertical stack, with
blocks layered on top of each other.
• Height refers to the number of blocks connected
together in the block chain.
• For example, Height 0, would be the very first block,
• which is also called the Genesis Block.
• May not be unique

Lecture 3 Blockchain Technical Details 10


Fork
• creation of an ongoing alternative version of the
blockchain, by creating two blocks simultaneously on
same height

Lecture 3 Blockchain Technical Details 11


Fork
• A blockchain fork can persist for several block
• The protocol determines that the correct blockchain is
the longest one
• The discarded block is called an orphan block

Lecture 3 Blockchain Technical Details 12


Types of Forks
• Soft Fork
• Tightening the rules (e.g. 1MB -> 0.5MB)
• Backwards Compatible
• Old nodes accept new blocks

Blocks
Follows Follows Follows Old Rules Follows
From Non-
Old Old But Violates Old
Upgraded
Rules Rules New Rules Rules
Nodes

Blocks
Follows Follows
From
Old & New Old & New
Upgraded
Rules Rules
Nodes

A Soft Fork: Blocks Violating New Rules Are Made Stale By The Upgraded Mining Majority

Lecture 3 Blockchain Technical Details 13


Types of Forks
• Hard Fork
• Expanding the rules (e.g. 1MB -> 2MB)
• Not backwards compatible
• Old nodes don't accept new blocks

Blocks
Follows Follows Follows Follows
From Non-
Old Old Old Old
Upgraded
Rules Rules Rules Rules
Nodes

Blocks
Follows Follows Follows Follows
From
New New New New
Upgraded
Rules Rules Rules Rules
Nodes

A Hard Fork: Non-Upgraded Nodes Reject The New Rules, Diverging The Chain

Lecture 3 Blockchain Technical Details 14


Decentralized Consensus
• Four Processes
1. Independent Verification of Each Transactions
2. Independent Aggregation of Transactions
3. Independent Verification of New Blocks
4. Independent Selection of Chain

Lecture 3 Blockchain Technical Details 15


[1] Independent Verification of Tx
• Once a Tx is created by client
• Sent to neighboring nodes
• Propagated across network
• As soon as a Node Receives Tx,
• Its validated before its propagated further
• Invalid Tx are discarded by first node that encounters them
• Tx Verification Criteria
• Blockchain Specific
• Each nodes builds a pool of valid (but unconfirmed Tx)

Lecture 3 Blockchain Technical Details 16


Tx Verification Criteria
• If Syntax and Data Structure are correct
• Inputs / outputs are not empty
• Values are within permissible limit
• Size in bytes valid
• Other blockchain-specific criteria
• Such Criteria / Conditions change over time

Lecture 3 Blockchain Technical Details 17


Pool of Valid Tx
• Pool of valid (but unconfirmed) Tx are known as
• Transaction Pool
• Memory Pool
• Mempool

Lecture 3 Blockchain Technical Details 18


[2] Aggregating Tx in New Blocks
• Tx in Pool are waiting to be added in to new block
• Few hundreds Tx
• Node will aggregate Tx in to Candidate Block
• If Node receives new block,
• It will first validate block
• Remove Tx from MemPool which are already included in the
new block
• First Tx in any block is special Tx
• Coinbase Transaction
• Reward of mining effort

Lecture 3 Blockchain Technical Details 19


Candidate Block
• Block Header is Constructed
• Version,
• Previous Block Hash
• Merkle Tree,
• Time Stamp,
• Target for PoW,
• Nonce=0
• Continues to find solution for mining puzzle
• Hashing the header repeatedly changing value of Nonce
• Until resulting hash matches a specific target

Lecture 3 Blockchain Technical Details 20


Proof of Work
• Puzzle
• Guess a value of Nonce within specified target range
• Target sets a threshold
• Only a hash below this threshold is acceptable
• Hash that is numerically less than the target
• As target decreases, finding hash less then that becomes
more and more difficult
• Virtually impossible to predict/determine a value to
produce output within desired range
• Trial and error – Random inputs
• Discovery of solution (valid hash) below the target
implies that certain amount of work has been done to
produce the result

Lecture 3 Blockchain Technical Details 21


Proof of Work Target
• Target determines the difficulty
• Affecting how long it takes to find solution to the PoW
• Miners resort to
• Specialized Hardware (GPU, ASIC..)
• Mining Rigs
• Mining Pools
• Proof of Work Target (in Bitcoin Blockchain)
• Is a dynamic parameter
• Adjusted periodically
• To meet 10 min block interval goal
• Defined to Retarget every 2016 blocks
• New Target = Old Target * (Actual Time Taken for Last 2016 Blocks /
20160 minutes)

Lecture 3 Blockchain Technical Details 22


Summary
• This Lecture
• Structure of Block, Blockchain
• Block Creation
• Mining Process

• Next Lecture
• Demonstration
• Types of Consensus Strategies
• Attacks
• Stakeholders

Lecture 3 Blockchain Technical Details 23

You might also like