Unit II Ethereum
Unit II Ethereum
• Smart Contracts,
Ethereum
Structure,
Operations,
Consensus
Model, Incentive
Model.
What is Ethereum?
• Ethereum is like a decentralized computing
network.
• It allows developers to create and run applications
on its blockchain using smart contracts.
• Ethereum was initially released in 2015.
• used for creating various decentralized
applications(also called Dapps).
• The Ethereum network is fueled by its own
cryptocurrency called ‘ether’.
• Smart contracts uses ‘cryptographic bank lockers’
which contain certain values.
• These cryptographic lockers can only be unlocked
when certain conditions are met.
• Ethereum is often called Blockchain 2.0
Features of Ethereum
• Smart contracts: created mainly using a programming
language called solidity
• Ethereum Virtual Machine (EVM): It is designed to
operate as a runtime environment for compiling and
deploying Ethereum-based smart contracts.
• Ether: Only accepted currency.
• Decentralized applications (Daaps):backend code running
on a decentralized peer-to-peer network.
• Decentralized autonomous organizations (DAOs):works
in a democratic and decentralized fashion-relies on smart
contracts for decision-making or decentralized voting
Type of Ethereum Accounts
– Header
– Body
Head
Parent Block’s Hash
• Definition: Reference to the hash of the
previous block
• Purpose: Links blocks together in a chain
• Importance: Ensures tamper-evident and
transparent verification of the blockchain
Uncle Hash
• Definition: Reference to the hash of a valid
but non-main block
• Role in Ethereum: Recognition of work by
miners, even if block isn’t in the main chain
• Incentives: Smaller Ether rewards for uncle
blocks
• Network Security: Promotes continuous
mining efforts
State Root
• Definition: Reference to the root of the state
trie
• Components: Stores current state of the
Ethereum network
• Efficiency: Compact verification of the
network state
• Importance: Facilitates node synchronization
Transaction Root
• Definition: Reference to the root of the
transaction trie
• Function: Stores all transactions in a block
• Verification: Efficiently ensures integrity of
transactions
• Network Efficiency: Streamlines node
synchronization
Receipt Root
• Definition: Reference to the root of the receipt
trie
• Purpose: Stores receipts of all transactions in
a block
• Information: Transaction outcome, gas used,
contract addresses
• Importance: Validates transaction outcomes
and node sync
Logs Bloom
• Definition: Filter for log events in a block
• Construction: Bit array from log topics
• Usage: Efficiently checks for log events
• Performance: Improves log event search
efficiency
Difficulty
• Definition: Difficulty level of proof-of-work
algorithm
• Adjustment: Dynamically controlled to
maintain block time
• Purpose: Ensures consistent block addition
rate
• Security: Maintains blockchain security and
efficiency
Block Number
• Definition: Scalar value representing block
position
• Sequence: Monotonically increasing
• Role: Identifies and references specific blocks
• Importance: Determines blockchain state and
ensures security
Gas Limit
• Definition: Maximum gas usage for
transactions in a block
• Purpose: Controls transaction processing rate
• Adjustment: Set by miner, dynamically
adjustable
• Network Stability: Prevents network
congestion
Gas Used
• Definition: Total gas consumed by
transactions in a block
• Monitoring: Indicates network state and
congestion
• Importance: Tracks network usage and
informs adjustments
Timestamp
• Definition: Time at which the block was
mined
• Format: Unix timestamp
• Function: Orders blocks chronologically
• Network Integrity: Ensures correct block
order and prevents forks
Extra Data
• Definition: 32-byte optional field for
additional data
• Usage: Includes messages, signatures, or other
data
BODY
• The body of an Ethereum block, also known as
the “block payload” or “block data,” is a
collection of data that contains all the
information necessary to execute the
transactions included in the block.
Transactions Root
• Merkle root of the transaction list
• Function: Proves inclusion of a transaction
without listing all transactions
Block Reward
• Reward for the miner who mined the block
• Combination of block reward, uncle reward,
and transaction fee rewards
Value
• Amount of Ether transferred in a transaction
• 64-bit word, smallest unit is wei
• Used with "to" field for standard transactions
Data
• Contains all transactions included in the block
• Includes contract creation, execution, token
transfer
To
• Specifies the recipient address of the Ether
transfer
• 20-byte address, unique identifier for
Ethereum accounts
How Does Ethereum Work?
• The EVM is a crucial component of the Ethereum
network, serving as the execution environment for smart
contracts.
• When a transaction triggers a smart contract, the EVM
executes the contract’s code.
This execution is replicated across all nodes in the
network, ensuring that the outcome is the same
everywhere.
• The EVM runs during the block verification process:
– Nodes verify transactions in the block.
– Each transaction’s code is executed in the EVM.
• To maintain a consistent and synchronized ledger,
all nodes must perform identical calculations.
• This ensures that all nodes agree on the state of
the blockchain after executing the transactions.
• Each transaction in the Ethereum network must
include:Gas Limit: The maximum amount of gas
the sender is willing to use for the transaction.
• Transaction Fee: The fee the sender is willing to
pay to have the transaction processed.
Gas and Transaction Processing
• The gas limit is crucial for determining
whether a transaction will be processed.
• If the gas needed for a transaction is less than
or equal to the gas limit, the transaction will be
processed.
• If the gas needed exceeds the gas limit, the
transaction will not be processed, and the
sender will lose the transaction fee.
Real-World Applications of
Ethereum
• Voting
• Agreements
• Banking systems
• Shipping
• Domain names
Benefits of Ethereum
• Availability
• Privacy
• Security
• Less ambiguity
• Rapid deployment
• Network size
• Data coordination
Consensus Model
• Consensus mechanisms are the complete stack
of ideas, protocols and incentives that enable a
distributed set of nodes to agree on the state of
a blockchain.
TYPES OF CONSENSUS MECHANISMS
• Proof-of-work based
– Block creation
• Miners compete to create new blocks filled with
processed transactions.
• The race is won by the computer which is able to solve
a math puzzle fastest.
• The race is won by the computer which is able to solve
a math puzzle fastest.
– Security
The network is kept secure
• Proof-of-stake based
– Block creation
• Validators create blocks. One validator is randomly
selected in each slot to be the block proposer.
– Security
– secure crypto-economically
The Etherium Incentive Model
• Ethereum blockchain have gas fees.
• Gas points specify the fees in standard values.
• Operations on the blockchain such as loading
from memory, storing to memory, transaction
base fee, and creation of contracts all have
varying gas costs
Gas in blocks
• A gas limit is the maximum amount of gas a
block is willing to spend on a transaction.
Transactions and smart contract execution
have varying gas limits, the latter is more
computationally demanding compared to a
simple transaction