Unit 1 2 3 4 5 BT NOTES Merged
Unit 1 2 3 4 5 BT NOTES Merged
Introduction:
What is Blockchain?
Need of Blockchain:
Application of Blockchain:
In the P2P network architecture, the computers connect with each other in a
workgroup to share files, and access to internet and printers.
Each computer in the network has the same set of responsibilities and
capabilities.
Each device in the network serves as both a client and server.
The architecture is useful in residential areas, small offices, or small
companies where each computer act as an independent workstation and
stores the data on its hard drive.
Each computer in the network has the ability to share data with other
computers in the network.
The architecture is usually composed of workgroups of 12 or more
computers.
How Does P2P Network Work?
Thus, it can be said that in the peer-to-peer network the file transfer load is
distributed among the peer computers.
Applications of P2P Network:
2. Race Condition: When two conflicting transactions spending the same funds
are broadcasted simultaneously or nearly so, the network may temporarily
accept both. However, only one transaction can eventually be added to the
blockchain, leading to a potential double-spend scenario.
2. Finney Attack: Named after Hal Finney, this attack involves a miner pre-
mining a block containing a transaction that spends the same coins they just
received. They secretly mine a longer chain that invalidates the original
transaction, benefiting from the block reward without the transaction being
included in the main chain.
Every node in the network has a copy of the digital ledger. To add a
transaction every node checks the validity of the transaction and if the
majority of the nodes think that it is a valid transaction then it is added
to the network. This means that without the approval of a majority of
nodes no one can add any transaction blocks to the ledger.
Any validated records are irreversible and cannot be changed. This
means that any user on the network won’t be able to edit, change or
delete it.
2. Distributed: 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.
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.
Public Blockchain.
Private Blockchain.
Hybrid Blockchain.
Consortium Blockchain.
Advantages:
Trustable: There are algorithms to detect no fraud. Participants need not
worry about the other nodes in the network
Secure: This blockchain is large in size as it is open to the public. In a
large size, there is greater distribution of records
Anonymous Nature: It is a secure platform to make your transaction
properly at the same time, you are not required to reveal your name and
identity in order to participate.
Decentralized: There is no single platform that maintains the network,
instead every user has a copy of the ledger.
Disadvantages:
Processing: The rate of the transaction process is very slow, due to its
large size. Verification of each node is a very time-consuming process.
Energy Consumption: Proof of work is high energy-consuming. It
requires good computer hardware to participate in the network
Acceptance: No central authority is there so governments are facing the
issue to implement the technology faster.
Use Cases: Public Blockchain is secured with proof of work or proof of stake
they can be used to displace traditional financial systems. The more advanced
side of this blockchain is the smart contract that enabled this blockchain to
support decentralization. Examples of public blockchain are Bitcoin, Ethereum.
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.
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.
Difference between Public and Private blockchain :
Basis of Public Blockchain Private Blockchain
Comparison
Access In this type of blockchain anyone can In this type of blockchain
read, write and participate in a read and write is done
blockchain. Hence, it is upon invitation, hence it is
permissionless blockchain. It is a permissioned blockchain.
public to everyone.
Network Don’t know each other Know each other
Actors
Decentralized A public blockchain is decentralized. A private blockchain is
Vs more centralized.
Centralized
Speed Slow Fast
Transactions Transactions per second are lesser in Transaction per second is
per second a public blockchain. more as compared to
public blockchain.
Security A public network is more secure due A private blockchain is
to decentralization and active more prone to hacks, risks,
participation. Due to the higher and data breaches /
number of nodes in the network, it is manipulation. It is easy for
nearly impossible for ‘bad actors’ to bad actors to endanger the
attack the system and gain control entire network. Hence, it is
over the consensus network. less secure.
Public Key: Public keys are designed to be public. They can be freely given to
everyone or posted on the internet. By using the public key, one can encrypt the
plain text message into the cipher text. It is also used to verify the sender
authentication. In simple words, one can say that a public key is used for closing
the lock.
Private Key: The private key is totally opposite of the public key. The private
key is always kept secret and never shared. Using this key we decrypt cipher
text messages into plain text. In simple words, one can say that the private key
is used for opening the lock.
Suppose, the sender wants to send some important message to the receiver.
The sender first creates a message in the form of plain text which is in a
readable format.
The sender knows the public key of the receiver but doesn’t know the
private key of the receiver because the receiver keeps secret his private
key. With the help of the public key of the receiver and the private key of
the sender, the sender generates the encrypted message i.e. called cipher
text. Cipher text is in an unreadable format. In this step, plain text
converts into cipher text.
Now, cipher text reaches the receiver end. The receiver knows its own
private key, and with the help of the private key receiver converts the
cipher text into readable format i.e. plain text.
Authentication: It ensures to the receiver that the data received has been
sent by the only verified sender.
Data integrity: It ensures that the information and program are changed only
in a specific and authorized manner.
Data confidentiality: It ensures that private message is not made available
to an unauthorized user. It is referred to as privacy or secrecy.
Non-repudiation: It is an assurance that the original creator of the data
cannot deny the transmission of the said data to a third party.
Key management: Public-key cryptography allows for secure key
management, as the private keys are never transmitted or shared. This
eliminates the need for a secure channel to transmit the private key, as is
required in symmetric key cryptography.
Digital signatures: Public-key cryptography allows for the creation of
digital signatures, which provide non-repudiation and can be used to verify
the authenticity and integrity of data.
Key exchange: Public-key cryptography enables secure key exchange
between two parties, without the need for a pre-shared secret key. This allows
for secure communication even if the parties have never communicated
before.
Secure communication: Public-key cryptography enables secure
communication over an insecure channel, such as the internet, by encrypting
the data with the public key of the recipient, which can only be decrypted by
the recipient’s private key.
One can encrypt and decrypt the fixed size of messages or data. If there is an
attempt to encrypt or decrypt a large size of the message then the algorithm
demands high computational power.
The main disadvantage of this algorithm is that if the receiver losses its
private key then data/message will be lost forever.
If someone has access private key then all data will be in the wrong hand.
There are many secret-key which is faster than public-key cryptography.
Key distribution: The process of securely distributing public keys to all
authorized parties can be difficult and time-consuming, especially in large
networks.
Performance: Public-key cryptography is generally slower than symmetric-
key cryptography due to its more complex algorithms, making it less suitable
for applications that require fast processing speeds.
Hash Functions:
What is Hash Functions?
Hash functions are mathematical algorithms that convert input data of any size
into a fixed-size string of characters, known as a hash value or digest. These
functions play a crucial role in cryptography by producing unique outputs for
specific inputs.
2. Deterministic Output: For the same input, a hash function always generates
the same output.
3. Fixed Output Size: Regardless of input size, the output hash length remains
constant.
4. Avalanche Effect: A small change in the input significantly alters the hash
output.
5. Collision Resistance: It's exceedingly rare for two different inputs to produce
the same hash output.
2. MD5 (Message Digest Algorithm 5): Once widely used but now considered
weak due to vulnerabilities.
3. Blake, Keccak, and Others: Various other hash functions designed with
specific features and security levels.
Uses of Hash Functions in Blockchain:
2. Merkle Trees: Hash functions help construct Merkle trees, efficient data
structures used in blockchain to summarize and verify large sets of data.
5. Smart Contracts: Hash functions are used to verify and execute smart
contracts by ensuring that the contract's code hasn’t been altered.
Hashing involves the conversion of input data, irrespective of its size or type, into
a fixed-size string of characters using a mathematical algorithm known as a hash
function. This process generates a unique output, called a hash, that serves as a
digital fingerprint representing the input data.
1. Fixed Output Size: Always generates a 256-bit output, regardless of the input's
size, ensuring consistency and predictability in hash length.
5. Final Hash Output: After processing the entire input data, the SHA-256
algorithm produces a 256-bit hash value.
3. Verification Process:
The signed transaction, along with the sender's public key, is broadcasted
to the network.
Other participants use the public key to verify the signature's authenticity
and integrity.
Verification confirms that the signature was indeed created by the
corresponding private key.
2. Integrity: Ensures that the transaction data has not been tampered with or
altered in transit.
Importance in Blockchain:
The concept of Merkle Tree is named after Ralph Merkle, who patented the idea
in 1979. Fundamentally, it is a data structure tree in which every leaf
node labelled with the hash of a data block, and the non-leaf node labelled with
the cryptographic hash of the labels of its child nodes. The leaf nodes are the
lowest node in the tree.
Merkle trees are created by repeatedly calculating hashing pairs of nodes until
there is only one hash left. This hash is called the Merkle Root, or the Root Hash.
The Merkle Trees are constructed in a bottom-up approach.
Every leaf node is a hash of transactional data, and the non-leaf node is a hash of
its previous hashes. Merkle trees are in a binary tree, so it requires an even number
of leaf nodes. If there is an odd number of transactions, the last hash will be
duplicated once to create an even number of leaf nodes.
The above example is the most common and simple form of a Merkle tree,
i.e., Binary Merkle Tree. There are four transactions in a
block: TX1, TX2, TX3, and TX4. Here you can see, there is a top hash which is
the hash of the entire tree, known as the Root Hash, or the Merkle Root. Each
of these is repeatedly hashed, and stored in each leaf node, resulting in Hash 0, 1,
2, and 3. Consecutive pairs of leaf nodes are then summarized in a parent node
by hashing Hash0 and Hash1, resulting in Hash01, and separately
hashing Hash2 and Hash3, resulting in Hash23. The two hashes
(Hash01 and Hash23) are then hashed again to produce the Root Hash or the
Merkle Root.
Merkle Root is stored in the block header. The block header is the part of the
bitcoin block which gets hash in the process of mining. It contains the hash of the
last block, a Nonce, and the Root Hash of all the transactions in the current block
in a Merkle Tree. So having the Merkle root in block header makes the
transaction tamper-proof. As this Root Hash includes the hashes of all the
transactions within the block, these transactions may result in saving the disk
space.
The Merkle Tree maintains the integrity of the data. If any single detail of
transactions or order of the transaction's changes, then these changes reflected in
the hash of that transaction. This change would cascade up the Merkle Tree to the
Merkle Root, changing the value of the Merkle root and thus invalidating the
block. So everyone can see that Merkle tree allows for a quick and simple test of
whether a specific transaction is included in the set or not.
Let us understand the various stages in a blockchain transaction life cycle with
the help of an example.
Sourav and Suraj are two Bitcoin users. Sourav wants to send 1 bitcoin to
Suraj.
Benefits of Blockchain:
1. Public Blockchain:
Open for anyone to join and participate, promoting decentralization and
self-governance.
Enables read, write, and audit activities openly, ensuring data immutability
once validated.
Advantages: Encourages network growth, immutability, rapid
transactions.
Disadvantages: Can be costly, potential identity issues, occasional slow
processing, integration challenges.
2. Private Blockchain:
Permission-based access limits network participation to authorized entities
in transactions.
Managed by an entity, controlling access rights and permissions within the
network.
Advantages: Controlled access, partial immutability.
Disadvantages: Trust issues due to restricted access, vulnerability with
increased participants.
3. Consortium Blockchain:
Governed by a group of organizations and possibly by the government,
fostering increased privacy and security.
Intermediate decentralization, designed and accessed by collaborating
organizations.
Advantages: Aims for faster outputs, scalability, low transaction costs.
Disadvantages: Relationship instability, lacks a clear economic model,
flexibility issues.
Hard forks create a permanent split in the blockchain, necessitating all nodes to
adopt the new rules, while soft forks maintain backward compatibility and can be
adopted by nodes without creating a split.
Consensus Algorithms in Blockchain:
Blockchain operates without a central authority, ensuring security, immutability,
and transparency. Consensus protocols are fundamental to Blockchain, enabling
nodes to reach agreement on ledger states. They establish trust among unknown
peers in a decentralized environment, ensuring that added blocks represent the
network's agreed truth.
Proof of Capacity:
Validators use hard drive space for mining.
Various other consensus algorithms exist, like Proof of Activity, Proof of Weight,
and Leased Proof of Stake, each tailored to specific network needs. The choice of
consensus mechanism is critical, as it ensures the proper functioning and
verification of transactions within Blockchain networks.
Proof of Work (PoW):
Proof of Work (PoW) is a consensus algorithm widely used in cryptocurrencies,
aiming to validate transactions and create new blocks in the blockchain. Initially
conceptualized in 1993, PoW was later employed by Satoshi Nakamoto in
Bitcoin's paper in 2008. The term "proof of work" was coined in a publication by
Markus Jakobsson and Ari Juels in 1999.
Principle and Purpose:
PoW requires complex computations to mine blocks, offering a solution
that's hard to find but easy to verify.
Its aim is to establish agreement among nodes in a trustless environment,
validating transactions and adding new blocks to the blockchain.
How PoW Works:
Miners, nodes engaged in mining, solve computational puzzles to create
blocks in the blockchain.
The process involves validating transactions and appending them in
chronological order to form a block.
Miners compete to solve these complex mathematical problems for
economic rewards, which decrease over time.
Mining and Energy Consumption:
Mining verifies transactions, but the energy-intensive aspect involves
linking new blocks to the existing blockchain.
Miners receive rewards (currently 6.25 bitcoins) for successfully mining a
block, with rewards halving periodically.
Bitcoin adjusts mining difficulty to maintain a steady block creation rate
(approximately one block every 10 minutes).
Bitcoin's PoW System:
The Hashcash Proof of Work system underpins Bitcoin's mining process.
Miners must find a nonce (unique value) that, when appended to data,
results in a hash lower than the target hash.
Cryptographic Protocols:
Commonly used cryptographic protocols include SHA-256 (used in
Bitcoin) and others like Scrypt, SHA-3, scrypt-jane, and scrypt-n.
Challenges with PoW:
Risk of majority control: A controlling entity owning 51% or more nodes
can manipulate the blockchain.
Time and resource consumption: Mining involves a time-consuming
process that requires substantial computing power, leading to resource
wastage.
Delayed transactions: Transaction confirmation might take 10-60 minutes
due to the mining process, causing delays.
Despite being widely used, PoW faces challenges regarding energy consumption,
time inefficiency, and the risk of centralized control.
Proof of Stake (PoS):
Proof of Stake (PoS) is a consensus algorithm used in Blockchain to attain
distributed agreement, initially proposed by Quantum Mechanic, and later
detailed by Sunny King, leading to the introduction of Proof-of-Stake-based
Peercoin.
Purpose: Addresses the energy-intensive nature of Proof-of-Work (PoW) used in
Bitcoin.
Mechanics:
Nodes stake a cryptocurrency amount, vying to validate a new block and
earn fees.
Selection combines stake quantity, coin-age, and randomization for
fairness.
Workflow:
1. Nodes transact; PoS pools these transactions.
2. Nodes stake to become the validator for the next block, selected via the
algorithm.
3. Validator verifies and publishes the block; stake remains locked until 'OK'-
ed by other nodes.
4. If verified, validator gets stake and reward; else, stake is lost, marked 'bad,'
and process restarts.
Features:
Limited circulating coins; no creation of new coins (initiated by PoW).
Transaction fees accumulate as rewards.
Prevents a 51% attack due to the expensive nature of owning 51% of the
cryptocurrency.
Advantages:
Energy-efficient, as nodes don't compete like in PoW.
Encourages decentralization by offering linear rewards, not exponential
like PoW.
Security against attacks due to the high cost of owning a majority stake.
Weaknesses:
Potential centralization if a group owns a substantial stake.
PoS is a relatively newer technology, still under research.
'Nothing at Stake' problem, where nodes face no disadvantage in
supporting multiple blockchains during forks.
Blockchains using PoS:
Ethereum (Casper update)
Peercoin
Nxt
Variants of PoS:
Regular PoS
Delegated PoS
Leased PoS
Masternode PoS
Practical Byzantine Fault Tolerance (pBFT):
Practical Byzantine Fault Tolerance (pBFT) is a consensus algorithm created in
the late 90s by Barbara Liskov and Miguel Castro. It efficiently operates in
asynchronous systems, optimizing for low overhead time. pBFT addresses issues
present in existing Byzantine Fault Tolerance solutions, finding applications in
distributed computing and blockchain.
What is Byzantine Fault Tolerance?
Byzantine Fault Tolerance ensures network consensus, even if some nodes fail to
respond or provide incorrect information. It's derived from the Byzantine
Generals' Problem, where a collective decision-making mechanism is employed
to reduce the influence of faulty nodes.
How pBFT Works:
Nodes are ordered, with a primary and secondary node configuration.
All honest nodes aim to reach a consensus through the majority rule.
A practical BFT system can function when the number of malicious nodes
is less than one-third of all nodes, enhancing security as nodes increase.
Phases of pBFT Consensus Rounds:
1. Client sends a request to the primary node.
2. Primary node broadcasts the request to all secondary nodes.
3. Nodes perform the service and send replies to the client.
4. Successful service occurs when the client receives 'm+1' matching replies
from different nodes.
Advantages of pBFT:
Energy efficiency without complex computations (unlike PoW).
Transaction finality without multiple confirmations.
Low reward variance, incentivizing all nodes participating in decision-
making.
Limitations of pBFT:
Inefficiency with large networks due to high communication overhead.
Vulnerability to Sybil attacks as the network size increases.
Proof of Burn (PoB):
What is Proof of Burn?
PoB is a consensus algorithm used in Blockchain networks, addressing
drawbacks of Proof of Work (PoW).
Validators 'burn' coins irretrievably, sacrificing them to earn the right to
mine, replacing the computational power utilized in PoW.
By sending coins to an inaccessible address, validators earn the privilege
to mine via a random selection process.
Purpose of Proof of Burn:
PoB addresses PoW's energy-intensive nature and high capital
requirements.
Validators demonstrate commitment to the currency by sacrificing coins
for long-term potential gains.
How Proof of Burn Works:
Validators send coins to inaccessible addresses, reducing the coin supply
permanently.
Reduced availability potentially increases coin value.
Continuous burning maintains mining capacity, ensuring fairness for
latecomers.
Comparison with Proof of Stake (PoS):
PoB ensures permanent scarcity compared to PoS, where coins return to
circulation after validators unlock them.
Advantages of PoB include reduced energy consumption, fairer coin
distribution, and long-term commitment incentives.
Disadvantages involve risk, potential resource wastage, and the "rich
getting richer" scenario due to accumulated coins.
Proof of Burn presents an innovative approach to consensus algorithms,
balancing sustainability, fairness, and commitment within Blockchain networks.
Proof of Elapsed Time (PoET):
Proof of Elapsed Time (PoET) is a consensus algorithm developed by Intel in
2016 for blockchain networks, aiming to reduce energy consumption and
resource intensity associated with other methods like Proof of Work (PoW).
What is Proof of Elapsed Time (PoET)?
PoET determines the next block creator in a permissioned blockchain. It works
on a randomized timer system that allocates a wait time to each network node.
The node with the shortest wait time wakes up, generates a new block, and
broadcasts this to the network.
How Does PoET Work?
1. Random Wait Time: Every node generates a random wait time and sleeps for
that duration.
2. Block Creation: The node with the shortest wait time becomes the block
leader, creates a new block, and adds it to the chain.
3. Network Broadcasting: Information about the new block spreads across the
network, and the process repeats for the next block.
PoET Benefits:
Low Power Consumption: Nodes can conserve energy by 'sleeping' for
specified periods.
Resource Efficiency: Reduces resource intensity and scales well for faster
transaction processing.
High Transaction Rate: Can achieve up to a million transactions per
second.
Equal Opportunity: Fair opportunity for all network participants with the
time object activation.
Permissioned Security: Ensures network security against cyber threats.
PoET Limitations:
Specialized Hardware: Requires specific hardware, limiting widespread
adoption.
Compatibility Challenges: Relies on Intel's technology, which might pose
compatibility issues with other tools.
Comparison between PoW, PoS, and PoET:
History of Ethereum:
Voting: Voting systems are adopting Ethereum. The results of polls are
available publicly, ensuring a transparent fair system thus eliminating
voting malpractices.
Agreements: With Ethereum smart contracts, agreements and contracts
can be maintained and executed without any alteration. Ethereum can be
used for creating smart contracts and for digitally recording transactions
based on them.
Banking systems: Due to the decentralized nature of the Ethereum
blockchain it becomes challenging for hackers to gain unauthorized
access to the network. It also makes payments on the Ethereum network
secure, so banks are using Ethereum as a channel for making payments.
Shipping: Ethereum provides a tracking framework that helps with the
tracking of cargo and prevents goods from being misplaced.
Crowdfunding: Applying Ethereum smart contracts to blockchain-
based crowdfunding platforms helps to increase trust and information
symmetry. It creates many possibilities for startups by raising funds to
create their own digital cryptocurrency.
Benefits of Ethereum:
Drawbacks of Ethereum:
Gas prices are delivered in the form of Ethereum’s born money, the
currency of Ethereum is ETH.
Gas costs are indicated in “gwei” which is a movement of Ethereum,
every single “gwei” is equivalent to 0.000000001 ETH.
For sample, rather than stating that the gas costs 0.000000001 ether,
say, the gas costs 1 “gwei”.
The term “gwei” means “Giga-wei”, which is equivalent to
1,000,000,000 “wei”.
“Wei” is called after “Wei Dai” that is the creator of b-money (least unit
of ETH).
GWEI:
Example:
For example, Rahul needs to give 1 ETH to Shubham. During the transaction, the
gas boundary is 21000 units, and the gas price is 200 gwei.
Total fee costs = Gas units (limit) Gas price per unit
= 21000 200
= 4,200,000 gwei (0.0042 ETH)
When Rahul dispatched the funds, 1.0042 ETH would be subtracted
from Rahul’s account.
Shubham would be credited 1.0000 ETH only as 0.0042 is the fess of
Miner.
Now after upgradation, increased advantages presented by the difference
contain more profitable trade fee computation, typically more rapid trade
inclusion, and canceling the ETH distribution by burning a portion of trade fees.
Beginning with the peer-to-peer network upgrade, each block unit has
a ground fee, the lowest price per unit of gas for inclusion in this block
unit, estimated by the network founded on request.
Because the ground fee of the trade fee is burnt, users are also hoped to
put a tip in their dealings.
The information pays miners for managing and breeding user trades in
blocks and is hoped to be set automatically by most wallets.
Total fee after upgradation = Gas units (limit) (Base fee + Tip)
For example, Shubham has to pay 1 ETH to Rahul. This process has a gas limit
of 21000 units and a base fee of 100 gwei. Shubham includes a tip of 10 gwei.
Total fee after upgradation = Gas units (limit) (Base fee + Tip)
= 21000 (100 + 10)
= 2,310,000 gwei (0.00231 ETH).
When Shubham sends the funds, 1.00231 ETH will be subtracted from
Shubham’s account.
Rahul will be credited 1.0000 ETH and 0.00021 ETH will be received
by the miner as the tip.
A ground fee of 0.0021 ETH is ignited.
Gas Fees:
The gas fees include Base, Priority, Max, and calculating fees. Let’s discuss these
terms in detail.
1. Base fees:
Each alliance has a ground fee which serves as a fund price.
The ground fee is figured alone of the existing alliance and is rather
specified by the alliances before it pushes trade prices better for users.
When the block is excavated the base fee is “burned”, dragging it from
regulation.
The ground fee is evaluated by instructions that compare the length of the
earlier block with the marked size.
The base fee intention rise by a max of 12.5% per block if the marked block
size is surpassed.
2. Priority fee:
Apart from the base fee obtained, the advancement presented a priority fee
i.e. tip to miners to contain a trade in the alliance.
Without tips, miners can see it financially possible to drill cleared blocks
because they can obtain the exact alliance prize.
Under normal circumstances, a little tip provides miners with the slightest
encouragement to maintain a transaction.
For dealings that require getting preferentially conducted ahead of different
trades in the same block, a more elevated tip will be essential to endeavor
to outbid contending trades.
3. Max fee:
To conduct trade on the P2P network, users can select the greatest limit
they are inclined to spend for their dealing to be completed.
This additional circumference is called the max fee/Gas.
For a trade to be completed, the max fee must surpass the aggregate of the
base and priority fees.
The trade sender is repaid the contrast between the max fee and the total of
the ground(base) fee and tip.
4. Calculating fees:
The main benefit of the upgrade is enhancing the user’s knowledge when
charging trade fees.
In the wallets that sustain the upgrade rather than explicitly commenting to
pay the transaction from a wallet, providers will automatically set a
suggested transaction fee (base fee + suggested priority fee) to decrease the
quantity of complexness loaded on their users.
Strategies to decrease gas costs for ETH, Users can select a direction to
display the important status of the user’s transaction.
Miners intention perform trades that suggest a more increased tip per gas,
as they hold the tips that users spend and resolve be slightly tilted to
conduct transactions with more down tips specified.
If users like to observe gas costs, then they can send ETH for smaller, user
can utilize multiple other tools given below:
Etherscan, Blocknative ETH Gas Estimator, ETH Gas Station, and
Cryptoneur Gas Fees Calculator aid in assessing Ethereum gas prices for
both Class 0 and Class 2 EIP-1559 transactions.
Why do gas fees exist?
Gas prices assist maintain the Ethereum grid safe. By demanding a price
for every analysis performed on the grid, it controls harmful attackers from
spamming the grid.
To bypass unexpected code, every trade needs to set a limitation to the
multiple computational efforts of regulation performance.
The absolute unit of analysis is “gas”.
Moreover, a trade contains a limitation, any gas not operated in a
transaction is produced to the user (i.e. max fee – (base fee + tip) is
produced).
The base fee is computed by a procedure that resembles the dimensions of the
last block (the part of gas utilized for all the trades) with the target size. The base
fee will rise by a most of 12.5% per alliance if the target block size is
overextended.
The World State:
The "world state" in a blockchain context refers to the current state of the entire
system at any given point in time. It's a crucial concept in understanding how
blockchain networks function, particularly in systems like Ethereum.
What is the World State?
1. Data Structure: The world state is essentially a database or data structure
that represents the current status of all accounts and their balances, as well
as other essential information in a blockchain network.
2. Immutable State: In a blockchain, once a block is added and validated, it
contributes to the world state. This state reflects the result of all
transactions executed and accepted in the network. Once a block is
appended to the chain, the world state gets updated accordingly.
3. Account Information: The world state contains detailed information
about all accounts (externally owned accounts and smart contracts),
including their current balances, code, storage, and nonce (a value
representing the number of transactions sent from an account).
4. Historical Records: Every change in the world state is recorded, but the
world state itself represents the current state of the system. The historical
data is retained in the blockchain as a sequence of blocks.
Role of World State in Blockchain:
1. Efficiency: It streamlines the process of verifying transactions by allowing
nodes to quickly access the current state of all accounts without needing to
recompute from the beginning of the blockchain.
2. Transaction Verification: When a new transaction occurs, nodes verify its
validity by checking against the world state. For instance, they check if the
sender has enough balance to complete the transaction.
3. Consistency and Integrity: As the blockchain is immutable and append-
only, the world state maintains the integrity and consistency of the system
by reflecting the cumulative effects of all transactions.
4. Smart Contract Execution: For Ethereum and similar platforms, the
world state is vital for executing smart contracts. When a contract is
executed, it modifies the world state by updating account balances or other
data as per the contract's logic.
How it's Represented:
Merkle Trees: To efficiently represent the world state, blockchain
networks often use Merkle trees—a data structure that enables quick and
secure verification of large data sets by hashing them into a tree-like
structure.
State Roots: In Ethereum, the world state is represented by a state root,
which is essentially the root hash of a Merkle Patricia tree. This root is
included in each block header, providing a quick way to check the integrity
of the world state.
The world state concept provides an efficient means for blockchain networks to
maintain a comprehensive and verifiable representation of the system's state at
any given moment, crucial for ensuring the network's reliability and consistency.
Ethereum Virtual Machine (EVM):
Introduction:
EVM serves as the runtime environment for executing smart contracts within the
Ethereum network. Isolated from the system, it ensures that operations within it
do not impact external data or programs. It interprets and executes smart contract
code written in languages like Solidity.
Purpose of EVM:
Acts as Ethereum's "world computer," executing smart contracts securely.
Supports complex scripts, enabling the creation of crypto-contracts.
Facilitates automated execution of conditions within smart contracts,
ensuring predetermined outcomes.
How Does EVM Work?
EVM executes scripts defining operations on Ethereum's blockchain.
Smart contracts define exchanges of assets and information based on preset
conditions.
Utilizes a Turing-complete environment, enabling execution of virtually
any computer-based task.
Forms the foundation for decentralized applications (DApp’s) within the
Ethereum ecosystem.
Consists of the EVM component (running Solidity) and facilitates
metadata storage (uncles).
How Gas Relates to EVM's Performance:
Gas measures computational power, determining the execution time for
transactions and contracts.
Each transaction has a gas limit; complexity increases gas consumption.
Benefits of EVM:
Executes untrusted code securely without risking data.
Allows complex smart contracts to interact across platforms.
Provides deterministic processing and facilitates distributed consensus.
Downsides of EVM:
Incurs high costs for storing data and executing transactions.
During network congestion, gas prices rise, impacting transaction
processing.
Requires technical expertise for smart contract development and use.
Conclusion:
The Ethereum Virtual Machine serves as the backbone of Ethereum's smart
contract functionality, allowing for the secure execution of code and the creation
of decentralized applications. While powerful, it comes with complexities and
cost implications, necessitating technical proficiency for its effective use.
Ethereum Accounts:
Ethereum is a blockchain-based open-source cryptocurrency platform that
encompasses smart contract functionality. Ether (ETH) serves as Ethereum's
cryptocurrency, utilized for transactions and executing smart contracts. Ethereum
extends beyond mere transactional capabilities, enabling app development and
contract implementation.
What Are Ethereum Accounts?
Ethereum accounts function akin to bank accounts for holding, transferring Ether,
and executing smart contracts. These accounts comprise an Ethereum address and
a private key—20 bytes of the SHA3 hashed public key determine the Ethereum
address.
Types of Ethereum Accounts:
1. Externally Owned Account (EOA): Similar to Bitcoin accounts, EOAs are
controlled by a private key. They're created with wallets, enabling balance checks,
transactions, and smart contract interactions. EOAs can trigger code execution in
contract accounts.
Advantages:
Enable diverse actions like token transfers or contract creation.
Incapable of listing incoming transactions.
2. Contract-Based Account: Formed upon deploying contract code, these
accounts are governed by contracts and accessed through unique addresses. They
list incoming transactions and support Multisig Account functionality.
Advantages:
Can initiate incoming transactions.
Disadvantages:
Incurs gas costs for creation.
Cannot independently trigger transactions.
Types of Contract Accounts:
Three types:
Simple Account: Single owner account.
Multisig Account: Contains multiple owner accounts.
Simplest Account: Functions similarly to Multisig Account.
Externally Owned Accounts vs Contract-Based Accounts:
S. Externally Owned Accounts Contract Accounts
No.
1. This account is controlled by This account is controlled Contract
humans. Code.
2. The private key is needed to No key is needed to access Contract
access EOAs. Accounts.
3. EASs are created automatically CA require EOAs to be activated.
on creating a wallet.
4. EOAs do not have their own CAs have their own associated code.
associated code.
5. No execution fee is associated The execution fee is associated with
with EOAs. CAs.
6. Code hash is an empty string. Code hash represents the code
associated with the account.
3. Project Ubin:
Project Ubin, initiated by the Monetary Authority of Singapore (MAS) and
collaborating financial institutions, explores blockchain's potential in
enhancing the efficiency of interbank payments and securities settlements. The
project aims to develop prototypes and test blockchain-based systems for
interbank payments, cross-border transactions, and securities settlements. By
leveraging blockchain technology, Project Ubin seeks to modernize
Singapore's financial infrastructure and foster innovation in the banking
sector.
4. Food Security:
Blockchain's transparency and traceability features are instrumental in
ensuring food security. Through blockchain-powered supply chain solutions,
consumers can access comprehensive information about the journey of food
products—from farm to table. Details about sourcing, production,
transportation, and storage are recorded on an immutable ledger, enhancing
food safety measures. This transparency minimizes food fraud and ensures
adherence to quality and safety standards.
5. Supply Chain Financing:
Blockchain-enabled supply chain financing optimizes financing processes by
offering real-time visibility into transactions and inventory movements. Smart
contracts on blockchain automatically trigger financing upon fulfilment of
predefined conditions, reducing delays and improving cash flow for suppliers.
Financial institutions benefit from reduced risks, as they gain real-time
insights into the status of goods in transit.