Unit 2
Unit 2
INTRODUCTION
The blockchain is a distributed database of records of all transactions or digital events that
have been executed and shared among participating parties. Each transaction is verified by
the majority of participants of the system.
It contains every single record of each transaction. Bitcoin is the most popular
cryptocurrency an example of the blockchain. Blockchain Technology first came to light
when a person or group of individuals name ‘Satoshi Nakamoto’ published a white paper
on "BitCoin: A peer-to-peer electronic cash system" in 2008.
Blockchain Technology Records Transaction in Digital Ledger which is distributed over the
Network thus making it incorruptible. Anything of value like Land Assets, Cars, etc. can be
recorded on Blockchain as a Transaction.
Blockchain Decentralization
There is no Central Server or System which keeps the data of the Blockchain. The data is
distributed over Millions of Computers around the world which are connected to the
Blockchain. This system allows the Notarization of Data as it is present on every Node and
is publicly verifiable.
Blockchain nodes
A node is a computer connected to the Blockchain Network. Node gets connected with
Blockchain using the client. The client helps in validating and propagating transactions
onto the Blockchain. When a computer connects to the Blockchain, a copy of the
Blockchain data gets downloaded into the system and the node comes in sync with the
latest block of data on Blockchain. The Node connected to the Blockchain which helps in
the execution of a Transaction in return for an incentive is called Miners.
Is Blockchain Secure?
Nowadays, as the blockchain industry is increasing day by day, a question arises is
Blockchain safe? or how safe is blockchain? As we know after a block has been added to
the end of the blockchain, previous blocks cannot be changed. If a change in data is tried to
be made then it keeps on changing the Hash blocks, but with this change, there will be a
rejection as there are no similarities with the previous block.
Just imagine there is a who hacker runs a node on a blockchain network, he wants to alter a
blockchain and steal cryptocurrency from everyone else. With a change in the copy, they
would have to convince the other nodes that their copy was valid.
They would need to control a majority of the network to do this and insert it at just the right
moment. This is known as a 51% attack because you need to control more than 50% of the
network to attempt it.
Timing would be everything in this type of attack—by the time the hacker takes any action,
the network is likely to have moved past the blocks they were trying to alter.
Mixed
Semi-
Decentralized Centralized governance
decentralized
Governance structure
High
High Moderate
Limited scalability scalability
scalability scalability
Scalability potential
Various
Enterprise Supply chain,
Cryptocurrencies, applications
solutions, data banking,
decentralized apps need
privacy collaborations
Use Cases flexibility
MINING MECHANISM
Bitcoin Mining is the process of verifying bitcoin transactions and storing them in a
blockchain(ledger). It is a process similar to gold mining but instead, it is a computer
process that creates new bitcoin in addition to tracking Bitcoin transactions..
For the miners to earn rewards from verifying the bitcoin Transactions, two things must be
ensured:
1. The miners must verify the one-megabyte size of the transaction.
2. For the addition of a new block of transaction in the blockchain, miners must have the
ability to solve complex computational maths problems called proof for work by finding
a 64-bit hexadecimal hash value.
Why Do Bitcoin Needs To Be Mined?
Bitcoin is a digital currency where there are chances of copying, counterfeiting, or double-
spending the same coin more than once. Mining solves these problems by making the above
illicit activities extremely expensive and resource-intensive. Thus, it can be concluded that
it is more beneficial and cost-effective to join the network as a miner than to try to
undermine it.
The nodes of the blockchain network are based on the concept that no one in the network
can be trusted. Proof of work is accepted by nodes to validate any transaction. Proof of
work involves doing hefty calculations to find a 32-bit hash value called nonce to solve the
mathematical puzzle. The miners create new blocks by abiding by the fact that the
transaction volume must be less than 21 million. 21 million is the total number of bitcoins
that can be generated. The verified transaction gets a unique identification code and is
linked with the previous verified transaction.
Let's understand this with the help of an example-
Suppose Alice wants to transfer 10 BTC to Bob.
Now the transaction data of A is shared with the miners from the memory pool. A
memory pool is a place where an unconfirmed or unverified transaction waits for its
confirmation.
Miners start competing with themselves to solve the mathematical riddle in order to
validate and verify the transaction using proof of work.
The miner who solves the problem first shares his result with other nodes(miners).
Once maximum nodes agree with the solution, the transaction block is verified and is
then added to the blockchain.
At the same time, the miner who solved the puzzle gets a reward of 6.25 bitcoins.
Now, after the addition of the transaction block, the 10 BTC associated with the
transaction data is transferred to Bob from Alice.
In past, users of the system used to mine bitcoins using their home computers but as the
technology has improved, this is no longer the case. The general time a bitcoin network
takes to verify a new transaction is 10min. Within that time, there are more than one million
miners competing with each other to find the hash value. When there is more computing
power working together to mine for bitcoins, the difficulty level of mining increases.
Therefore, in order to mine bitcoins, the user must possess-
Specialized mining hardware is called "application-specific integrated circuits," or
ASICs.
A Bitcoin mining software to join the Blockchain network.
Powerful GPU (graphics processing unit).
DISTRIBUTED CONSENSUS
What is the Distributed Consensus in Distributed Systems?
Distributed consensus in distributed systems refers to the process by which multiple nodes
or components in a network agree on a single value or a course of action despite potential
failures or differences in their initial states or inputs. It is crucial for
ensuring consistency and reliability in decentralized environments where nodes may
operate independently and may experience delays or failures. Popular algorithms like Paxos
and Raft are designed to achieve distributed consensus effectively.
Importance of Distributed Consensus in Distributed Systems
Below are the importance of distributed consensus in distributed systems:
Consistency and Reliability:
o Distributed consensus ensures that all nodes in a distributed system agree on
a common state or decision. This consistency is crucial for maintaining data
integrity and preventing conflicting updates.
Fault Tolerance:
o Distributed consensus mechanisms enable systems to continue functioning
correctly even if some nodes experience failures or network partitions. By
agreeing on a consistent state, the system can recover and continue
operations smoothly.
Decentralization:
o In decentralized networks, where nodes may operate autonomously,
distributed consensus allows for coordinated actions and ensures that
decisions are made collectively rather than centrally. This is essential
for scalability and resilience.
Concurrency Control:
o Consensus protocols help manage concurrent access to shared resources or
data across distributed nodes. By agreeing on the order of operations or
transactions, consensus ensures that conflicts are avoided and data integrity
is maintained.
Blockchain and Distributed Ledgers:
o In blockchain technology and distributed ledgers, consensus algorithms (e.g.,
Proof of Work, Proof of Stake) are fundamental. They enable participants to
agree on the validity of transactions and maintain a decentralized, immutable
record of transactions.
Challenges of Achieving Consensus
Achieving consensus in distributed systems presents several challenges due to the inherent
complexities and potential uncertainties in networked environments. Some of the key
challenges include:
Network Partitions:
o Network partitions can occur due to communication failures or delays
between nodes. Consensus algorithms must ensure that even in the presence
of partitions, nodes can eventually agree on a consistent state or outcome.
Node Failures:
o Nodes in a distributed system may fail or become unreachable, leading to
potential inconsistencies in the system state. Consensus protocols need to
handle these failures gracefully and ensure that the system remains
operational.
Asynchronous Communication:
o Nodes in distributed systems may communicate asynchronously, meaning
messages may be delayed, reordered, or lost. Consensus algorithms must
account for such communication challenges to ensure accurate and timely
decision-making.
Byzantine Faults:
o Byzantine faults occur when nodes exhibit arbitrary or malicious behavior,
such as sending incorrect information or intentionally disrupting
communication. Byzantine fault-tolerant consensus algorithms are needed to
maintain correctness in the presence of such faults.
Distributed Consensus Algorithms in Distributed Systems
Distributed consensus algorithms are fundamental in ensuring that nodes in a distributed
system can agree on a single value or decision despite potential failures, delays, or
differences in their initial states. These algorithms play a crucial role in maintaining
consistency, reliability, and coordination across decentralized networks. Here’s an in-depth
explanation of key distributed consensus algorithms:
1. Paxos Algorithm
Paxos is a classic consensus algorithm which ensures that a distributed system can agree on
a single value or sequence of values, even if some nodes may fail or messages may be
delayed. Key concepts of paxos algorithm include:
Paxos Algorithm
Roles:
o Proposer: Initiates the proposal of a value.
o Acceptor: Accepts proposals from proposers and communicates its
acceptance.
o Learner: Learns the chosen value from acceptors.
Phases:
o Phase 1 (Prepare): Proposers send prepare requests to a majority of
acceptors to prepare them to accept a proposal.
o Phase 2 (Accept): Proposers send accept requests to acceptors with a
proposal, which is accepted if a majority of acceptors agree.
Working:
o Proposers: Proposers initiate the consensus process by proposing a value to
be agreed upon.
o Acceptors: Acceptors receive proposals from proposers and can either
accept or reject them based on certain criteria.
o Learners: Learners are entities that receive the agreed-upon value or
decision once consensus is reached among the acceptors.
Safety and Liveness:
o Paxos ensures safety (only one value is chosen) and liveness (a value is
eventually chosen) properties under normal operation assuming a majority of
nodes are functioning correctly.
Use Cases:
o Paxos is used in distributed databases, replicated state machines, and other
systems where achieving consensus among nodes is critical.
2. Raft Algorithm
The Raft algorithm is a consensus algorithm designed to achieve consensus among a cluster
of nodes in a distributed system. It simplifies the complexities of traditional consensus
algorithms like Paxos while providing similar guarantees. Raft operates by electing a leader
among the nodes in a cluster, where the leader manages the replication of a log that
contains commands or operations to be executed.
Key Concepts:
o Leader Election: Nodes elect a leader responsible for managing log
replication and handling client requests.
o Log Replication: Leader replicates its log entries to followers, ensuring
consistency across the cluster.
o Safety and Liveness: Raft guarantees safety (log entries are consistent) and
liveness (a leader is elected and log entries are eventually committed) under
normal operation.
Phases:
o Leader Election: Nodes participate in leader election based on a term
number and leader’s heartbeat.
o Log Replication: Leader sends AppendEntries messages to followers to
replicate log entries, ensuring consistency.
Use Cases:
o Raft is widely used in modern distributed systems such as key-value stores,
consensus-based replicated databases, and systems requiring strong
consistency guarantees.
3. Byzantine Fault Tolerance (BFT) Algorithm
Byzantine Fault Tolerance (BFT) algorithms are designed to address the challenges posed
by Byzantine faults in distributed systems, where nodes may fail in arbitrary ways,
including sending incorrect or conflicting information. These algorithms ensure that the
system can continue to operate correctly and reach consensus even when some nodes
behave maliciously or fail unexpectedly.
BFT Algorithm
Key Concepts:
o Byzantine Faults: Nodes may behave arbitrarily, including sending
conflicting messages or omitting messages.
o Redundancy and Voting: BFT algorithms typically require a 2/3 or more
agreement among nodes to determine the correct state or decision.
Examples:
o Practical Byzantine Fault Tolerance (PBFT): Used in systems where
safety and liveness are crucial, such as blockchain networks and distributed
databases.
o Simplified Byzantine Fault Tolerance (SBFT): Provides a simpler
approach to achieving BFT with reduced complexity compared to PBFT.
Use Cases:
o BFT algorithms are essential in environments requiring high fault tolerance
and security, where nodes may not be fully trusted or may exhibit malicious
behavior.
A practical Byzantine Fault Tolerant system can function on the condition that the
maximum number of malicious nodes must not be greater than or equal to one-third of all
the nodes in the system. As the number of nodes increase, the system becomes more secure.
pBFT consensus rounds are broken into 4 phases.
The client sends a request to the primary(leader) node.
The primary(leader) node broadcasts the request to the all the secondary(backup) nodes.
The nodes(primary and secondaries) perform the service requested and then send back a
reply to the client.
The request is served successfully when the client receives ‘m+1’ replies from different
nodes in the network with the same result, where m is the maximum number of faulty
nodes allowed.
4. Challenges and Considerations:
Network Partitions and Delays: Algorithms must handle network partitions and
communication delays, ensuring that nodes eventually reach consensus.
Scalability: As the number of nodes increases, achieving consensus becomes more
challenging due to increased communication overhead.
Performance: Consensus algorithms should be efficient to minimize latency and
maximize system throughput.
Understanding and Implementation: Many consensus algorithms, especially BFT
variants, are complex and require careful implementation to ensure correctness and
security.
In summary, distributed consensus algorithms are crucial for enabling cooperation and
coordination among nodes in distributed systems. They ensure that all nodes agree on a
consistent state or decision, providing reliability, fault tolerance, and consistency across
decentralized networks in various applications from distributed databases to blockchain
networks.
Each algorithm has its strengths and trade-offs, making them suitable for different use
cases depending on the system's requirements for performance, fault tolerance, and
security
Practical Applications of Distributed Consensus in Distributed Systems
Below are some practical applications of distributed consensus in distributed systems:
Blockchain Technology:
o Use Case: Blockchain networks rely on distributed consensus to agree on the
validity and order of transactions across a decentralized ledger.
o Example: Bitcoin and Ethereum use consensus algorithms (like Proof of
Work and Proof of Stake) to achieve decentralized agreement among nodes.
Distributed Databases:
o Use Case: Consensus algorithms ensure that distributed databases maintain
consistency across nodes, ensuring that updates and transactions are applied
uniformly.
o Example: Google Spanner uses a variant of Paxos to replicate data and
ensure consistency across its globally distributed database.
Cloud Computing:
o Use Case: Cloud providers use distributed consensus to manage resource
allocation, load balancing, and fault tolerance across distributed data centers.
o Example: Amazon DynamoDB uses quorum-based techniques for
replication and consistency among its distributed database nodes.
Blockchain Distributed Consensus Mechanism
Blockchain uses a specific kind of distributed consensus to manage transactions and
maintain a secure, decentralized record (ledger). Key mechanism include:
Proof of Work (PoW):
o Concept: Computers (miners) solve difficult math puzzles to validate and
add new blocks of transactions to the blockchain.
o Consensus: The longest chain with the most computational effort is
considered the valid chain, ensuring agreement on the transaction history.
Proof of Stake (PoS):
o Concept: Validators are chosen based on the amount of cryptocurrency they
hold and stake in the network.
o Consensus: Validators are selected to propose and validate blocks of
transactions based on their stake, promoting fairness and security.
Practical Byzantine Fault Tolerance (PBFT):
o Concept: Nodes agree on the order of transactions through a voting process
where two-thirds of the nodes must agree.
o Consensus: Used in networks where participants are known and trusted,
ensuring fast transaction confirmation and high throughput.
Delegated Proof of Stake (DPoS):
o Concept: Token holders vote for delegates who are responsible for
validating transactions and producing blocks.
o Consensus: Delegates with the most votes perform block production,
balancing decentralization with efficiency and governance.
Challenges and Considerations for Scalabilty, Fault Tolerance and Resilience
1. Scalability Issues:
Scalability refers to a system's ability to handle increasing amounts of work or users
without compromising performance or efficiency.
Challenge: As the number of nodes (computers) in a distributed system grows,
achieving consensus becomes more complex due to increased communication overhead
and potential delays.
Considerations:
o Sharding: Partitioning data into smaller subsets (shards) to distribute the
workload and reduce the burden on individual nodes.
o Optimized Protocols: Developing efficient communication protocols and
algorithms to minimize message exchanges and latency.
o Parallel Processing: Utilizing parallel processing techniques to handle
multiple tasks simultaneously, improving overall throughput.
2. Fault Tolerance and Resilience:
Fault tolerance refers to a system's ability to continue operating in the presence of hardware
or software failures, ensuring data integrity and availability.
Challenge: Nodes in a distributed system can fail unexpectedly or behave maliciously
(Byzantine faults), disrupting consensus and potentially compromising the system's
reliability.
Considerations:
o Redundancy: Implementing redundant nodes or replicas to replicate data
and tasks across multiple nodes, ensuring continuity even if some nodes fail.
o Consensus Mechanisms: Using robust consensus algorithms (e.g., Practical
Byzantine Fault Tolerance - PBFT) that can tolerate a certain percentage of
faulty or malicious nodes.
o Monitoring and Recovery: Implementing monitoring systems to detect
failures promptly and automated recovery mechanisms to restore system
integrity.
MERKLE 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
Structure of Merkle
tree
1. A blockchain can potentially have thousands of blocks with thousands of transactions in
each block. Therefore, memory space and computing power are two main challenges.
2. It would be optimal to use as little data as possible for verifying transactions, which can
reduce CPU processing and provide better security, and this is exactly what Merkle trees
offer.
3. In a Merkle tree, transactions are grouped into pairs. The hash is computed for each pair
and this is stored in the parent node. Now the parent nodes are grouped into pairs and their
hash is stored one level up in the tree. This continues till the root of the tree. The different
types of nodes in a Merkle tree are:
Root node: The root of the Merkle tree is known as the Merkle root and this Merkle
root is stored in the header of the block.
Leaf node: The leaf nodes contain the hash values of transaction data. Each transaction
in the block has its data hashed and then this hash value (also known as transaction ID)
is stored in leaf nodes.
Non-leaf node: The non-leaf nodes contain the hash value of their respective children.
These are also called intermediate nodes because they contain the intermediate hash
values and the hash process continues till the root of the tree.
4. Bitcoin uses the SHA-256 hash function to hash transaction data continuously till the
Merkle root is obtained.
5. Further, a Merkle tree is binary in nature. This means that the number of leaf nodes
needs to be even for the Merkle tree to be constructed properly. In case there is an odd
number of leaf nodes, the tree duplicates the last hash and makes the number of leaf nodes
even.
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)
Merk
le 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
PATICIA TRIE
Trie is a data structure used in applications like search engines and natural language
processing tools involving extensive string processing & retrieval operations. In
the Ethereum blockchain, Merkle-Patricia Trie is used for data representation within a
block. We’ll see the symphony of Patricia Trie and blockchain in the soon-coming read.
However, to get started, this article reads you the data structure fondly called Patricia Trie- an
inevitable blockchain thing.
The trie (pronounced “try”) is widely used for storing string data sets. Though it was first
introduced by Rene de la Briandais in 1959, the term “trie” was later coined by Edward
Fredkin, derived from the middle syllable of the word “retrieval.”
Trie as above- mentioned is a tree-like data structure. Here, the root node stores nothing.
Edges are labeled with letters and a path from the root to the node represents a string. The
nodes come with an indicator, which indicates whether that node represents the end of a string.
Our agenda is to make the operation- data reTRIEval faster.
In our example, we have marked such nodes. All other nodes are for branching purposes only
and do not store any actual data. Let us see an example.
Searching for a string in a trie is very simple. Just start moving down the tree from the root
node, selecting the branches based on the characters in the string. If we find a path that
represents the sequence of characters in the search string, check whether the node at the end of
the path is marked. If we get stuck at some node or reach an unmarked node at the end of the
path, it is assumed that the search is unsuccessful.
Though the trie representation allows faster search operations, the space requirement is high.
We have to store a big tree with too many nodes and too many edges. However, there is a
technique to compress the trie.
The majority of the nodes have just one child. Should we really construct a separate node for
representing them ?. If we can combine these nodes we can reduce the size of the tree. This is
the basic idea behind Patricia Trie.
Patricia Trie
In a Patricia Trie, if a parent node has only a single child node, they will be combined. This is
done to compress long paths without any branches into single edges. Finally, we get a trie
where every node has at least two branches as shown below.
Edges are labeled with single characters or a sequence of characters. The branches are chosen
based on a prefix of a string rather than a letter in the string. In search operations, character by
character comparisons is replaced by string comparisons which reduce the number of
comparisons required.
For a better understanding of trie’s advantages and applications, we first need to understand
trie’s representation in detail.
Tries are not limited to string representations. They can be used to represent (key, value) pairs,
where we have a list of keys and a value associated with each key. Keys are strings
represented by the trie and the value will be stored in the node which is at the end of a key
path.
Branch Node: A node that has more than one child node. It stores links to child nodes.
Extension Node: A non-leaf node that represents a sequence of nodes that has only one
child. It stores a key value that represents the combined nodes, and a link to the next
node.
Leaf Node or Value Node: It is similar to an extension node. But instead of the link, it
stores a value.
For example, below is an example representation of nodes of a Patricia trie. It shows the
mapping (XYBDE, 999)
We will understand it based on an example. Let us create a key-value mapping for the strings
in our previous example.
(BIN, 10) (BINARY, 8) (MOVE, 30) (MOVIE, 55) (TREE, 20) (TRIE, 48)
The final Patricia trie for the above data set looks like below.
In our set of keys, the first letter of a key can be B or M, or T. So the main branch node has
links for each of them.
After ‘B’, we have a common prefix “IN”. There is an extension node combining the nodes
for I and N. The extension node has a field that points to the next branch node. Since BIN is a
key whose value is 10, insert 10 to the value field of the branch node (end node of the path
BIN). Next, we need to represent the key BINARY. From the branch node, create a link for A,
which connects a leaf node with key RY. The value of the key BINARY will be stored in the
leaf node.
In the case of the keys MOVE and MOVIE, the extension node for the common
prefix MOV is created like the previous case. From the branch node, there is a link
from E pointing to the leaf node of MOVE and a link from I pointing to the leaf node
for MOVIE. The leaf node for MOVE is at the end of path MOVE, so the key field is left
empty and the value is stored in it.
The nodes for TRIE and TREE are also constructed similarly. A branch node is created at the
end of the common prefix TR. It has links for E of TREE, and I of TRIE. Finally, the leaf
nodes store the value for each key.
Searching for a key is the same as before. Compare the links and key values at each node with
the characters in the search key. At the end of the path, if you reach a node that stores a value,
the search is successful. If you get stuck at some node or if the node at the end of the path does
not have a value stored, the search is unsuccessful.
GAS LIMIT
Ethereum Gas is a section that calculates the quantity of calculation action that it takes to
perform specific functions. Every function that carries position in Ethereum like
transactions and smart contracts etc. performance needs some part of gas. It is essential to
the blockchain P2P network because it is the power that authorizes it to accomplish exactly
what an automobile needs fuel to drive. Gas refers to the cost required to complete a deal
on the Ethereum network.
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
Gwei is a combination of "giga" and "wei". It is a sect of the blockchain technology ETH,
this coin is operated on the Ethereum P2P network. ETH is a blockchain medium, like
Bitcoin and Binance, where users can make transactions with respect to buying and selling
interests and benefits without the involvement of an intermediator.
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.
The ETH efficiency advancements should eventually manage some of the gas cost
points, allowing the medium to process thousands of trades globally per moment.
Second layer scaling is a direct ambition to significantly enhance gas prices, user
knowledge, and scalability.
The recent proof-of-stake(POS) sample based on the Beacon Chain, should decrease
heightened control consumption and dependence on technological hardware.
This chain resolve permits decentralized ETH P2P networks to compromise and support
network security while restricting gas consumption by rather demanding an economic
responsibility.
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 Transaction gas price estimator ", and " Blocknative ETH Gas Estimator
Gas " for evaluating Chrome attachment backing both Class 0 inheritance trades and
Class 2 EIP-1559 trades, and" ETH Gas Station " which is client instructed metrics for
the Ethereum gas demand, " Cryptoneur Gas Fees Calculator " is used for calculating
gas prices in the local currency for various trade.
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.
For institutional investors and individual traders alike, navigating crypto transaction fees is
foundational to digital asset strategies. These fees are standard to virtually every blockchain
transaction but can vary significantly depending on the asset, network demand, and
platform.
Though small and on a per-transaction basis, these fees can add up quickly, especially at
scale. For institutions, managing these costs efficiently is critical to protecting long-term
margins and maximizing returns.
This piece explores the types of crypto fees, the factors that influence them, and practical cost
mitigation strategies like crypto staking.
Key Takeaways
Crypto transaction fees incentivize network validators and prevent spam. Factors such as
digital asset type, network congestion, and transaction speed preferences dictate the size
of these fees.
Comparing exchange fee structures helps traders and institutions choose the most cost-
effective platforms.
There are several types of fees: network, trading, withdrawal, and deposit fees.
Institutions can reduce crypto transaction costs through techniques like batching, off-
peak transactions, and fee optimization tools like replace-by-fee (RBF).
Strategic wallet management and participation in staking and restaking can help offset or
mitigate transaction expenses.
On networks like Bitcoin, transaction fees fluctuate based on block space demand. When the
network is busy, fees increase as users compete for limited space in each block. This dynamic
pricing model ensures the network remains operational, even under heavy load.
Fees also help prioritize which transactions process first. Users who pay higher fees typically
receive faster confirmation times, which is crucial during periods of high traffic.
These mechanisms apply across various blockchain ecosystems, including Ethereum, where
gas fees fluctuate based on activity and wallet behavior. Efficient ETH wallet
management can reduce unnecessary costs. For example, institutions might employ
techniques such as adjusting gas settings or timing transactions.
In addition to user demand and network conditions, fee structures may also reflect a project's
governance philosophy. Some blockchains, such as Solana, aim for lower fees to promote
mass adoption. Others use more complex mechanisms to adjust for validator incentives and
system sustainability.
Understanding the context of each network’s fee logic gives deeper insight into why certain
transactions cost more than others.
Clear visibility into crypto transaction fee structures helps institutions and retail traders
navigate the digital asset ecosystem more effectively. Here are the primary categories:
Network Fees (Miner/Validator Fees): Paid directly to miners or validators for
processing transactions. These fees fluctuate based on supply and demand.
Trading Fees: Charged by exchanges for executing buy-and-sell orders. These are
usually a percentage of the trade value and may vary for makers and takers.
Withdrawal Fees: Charged when transferring crypto from an exchange to an external
wallet. This can be a fixed amount or based on network fees.
Deposit Fees: Less common but occasionally imposed by some platforms when
receiving funds.
Some platforms may include hidden costs such as spreads—the difference between the buy
and sell price. While not listed as explicit fees, they still impact the effective cost of a trade.
Several variables influence the size of crypto transaction fees. Here is what has the greatest
impact on how much institutions and traders pay per transaction:
Network Congestion: When too many transactions go through simultaneously, the
limited block space causes fees to rise.
Block Size and Time: Smaller blocks or longer block times mean fewer transactions
can be processed per second, increasing competition and fees.
Asset-Specific Rules: Different cryptocurrencies have different fee models. For
example, Ethereum uses a gas model, where each computational operation (like sending
ETH or interacting with a smart contract) consumes a specific amount of gas. Bitcoin,
on the other hand, uses satoshis per byte—the number of satoshis (the smallest unit of
BTC) paid per byte of transaction data.
User Preferences: Faster transactions often require higher fees. Some users voluntarily
pay more for speed.
Transaction timing can dramatically impact costs, too. For example, Ethereum gas prices
typically spike during decentralized finance (DeFi) or non-fungible token (NFT) booms.
Similarly, Bitcoin transaction fees can rise quickly in periods of market panic or excitement.
Institutions also often use algorithmic fee optimization tools to help determine the best
moment to send transactions based on predictive analytics. These tools also consider
historical congestion data, pending transaction queues, and even miner behavior to make
cost-efficient decisions.
While solutions like batching or replace-by-fee (RBF) help minimize on-chain fees, broader
strategies such as restaking also play a role in optimizing institutional capital use (more on
these strategies later in this piece).
Reducing crypto transaction fees requires a strategic approach, particularly for institutions
executing large volumes. Here are several proven methods:
Batching Transactions: Instead of sending multiple individual transactions, combine
them into one. This significantly reduces total network fees.
Transact During Off-Peak Hours: Fees tend to be lower when the network is less
congested. Monitor traffic patterns to find optimal times.
Use Replace-by-Fee (RBF): Replace-by-fee allows users to resend a Bitcoin transaction
with a higher fee if it's stuck, improving confirmation time without overpaying up front.
Choose Efficient Wallets and Custodians: Solutions that support automated fee
optimization, such as gas-efficient ETH wallet management, help institutions minimize
costs at scale.
Consider Staking or Restaking: Some institutions offset transaction costs through
crypto staking or restaking, earning rewards on idle assets.
Another strategy is to use Layer 2 (L2) scaling solutions like the Lightning Network for
Bitcoin or Optimism and Arbitrum for Ethereum. These technologies process transactions off
the main chain and settle them in batches, dramatically reducing the cost per transaction.
Institutions might also explore custom fee profiles available through some custody providers.
These offer advanced features like pre-approval workflows, automated low-fee routing, and
multi-transaction bundling, all designed to answer how to reduce crypto transaction costs at
scale.
Institutional custodians like BitGo offer powerful features that directly support transaction
cost efficiency, such as custom fee profiles, pre-approved workflows, and intelligent
transaction bundling. These tools help institutional clients reduce overhead while maintaining
compliance and security.
These techniques can help both institutions and individuals take greater control over their
crypto-related expenses and improve their ROI.
ANONYMITY
In the era of digital surveillance, privacy has become a paramount concern, and blockchain
technology offers a potential solution through various anonymity techniques. While
blockchain is often associated with transparency, several methods have emerged to obfuscate
transaction details and user identities.
“Anonymity” is one of the most discussed, and most likely misinterpreted features of
blockchain technology. It is a critical aspect of decentralized systems, addressing the need for
privacy and confidentiality in transactions conducted on public ledgers.
Unlike traditional financial systems, blockchain networks aim to provide pseudonymity and
confidentiality without relying on centralized authorities.
The concept of anonymity in blockchain revolves around obscuring transaction details such
as sender addresses, recipient addresses, and transaction amounts. Various techniques such as
cryptographic methods, ring signatures, zero-knowledge proofs (ZKPs), and mixing services
are employed to enhance privacy.
Anonymity in blockchain has gained prominence due to concerns over data privacy and the
desire for financial autonomy. Privacy-focused cryptocurrencies like Monero and Zcash have
emerged, emphasizing strong anonymity features. Understanding blockchain anonymity is
essential for individuals and organizations navigating the evolving landscape of digital
finance.
First and foremost, blockchain was envisioned to offer a decentralized and censorship-
resistant system for financial transactions. Anonymity plays a pivotal role in preserving
individual privacy and freedom within this framework. Without adequate anonymity,
transactions on public blockchains like Bitcoin can be traced back to specific individuals or
entities, potentially exposing sensitive financial information.
2. Fosters Inclusivity
Another critical aspect is the protection against identity theft and fraud. With pseudonymous
addresses and cryptographic techniques, blockchain anonymity reduces the risk of personal
information being exploited for malicious purposes.
4. Exchange of Cryptocurrency
Anonymity on blockchains, while offering valuable privacy benefits, comes with a set of
challenges. Let’s explore these potential drawbacks:
The lack of user identification can create a breeding ground for illegal activities. Criminals
can exploit anonymity for money laundering, financing terrorism, or facilitating illegal trade
through anonymous transactions. This undermines the core principles of trust and
transparency that blockchain aims to establish.
2. Regulatory Hurdles
Anonymity poses a significant roadblock for regulators who strive to maintain financial
stability and prevent crime. Without the ability to identify users, tracking suspicious
transactions and enforcing regulations like anti-money laundering (AML) becomes
significantly more difficult. This struggle can hinder the mainstream adoption of blockchain
technology.
3. Erosion of Trust
Complete anonymity can breed distrust. In anonymous marketplaces, buyers and sellers lack
the ability to verify each other’s identities, potentially leading to fraud or scams. This can
discourage legitimate users from participating in the ecosystem.
An important aspect of any financial system is fair and efficient dispute resolution. However,
anonymity makes it difficult to identify and hold accountable parties involved in fraudulent
transactions. This lack of accountability can discourage users and hinder the growth of
decentralized marketplaces.
1. Cryptographic Techniques
2. Ring Signatures
Ring signatures enable transaction mixing, where the sender’s transaction is grouped with
others in a ‘ring.’ This masks the sender’s identity, making it challenging to trace transactions
back to a specific user among the participants in the ring.
3. Stealth Addresses
Stealth addresses enhance recipient privacy by generating unique, one-time addresses for
each transaction. When a sender transfers funds to a stealth address, the transaction appears
on the blockchain without revealing the recipient’s actual address. This prevents address
reuse and enhances transaction privacy.
ZKPs allow users to prove possession of certain information (e.g., knowledge of a secret key)
without revealing the information itself. In blockchain, ZKPs are used to verify transactions
without disclosing sender, recipient, or transaction amount details. This protects privacy
without compromising the blockchain’s integrity.
Mixing services and protocols like CoinJoin enable users to combine their transactions with
others, obscuring the link between input and output addresses. This mixing process makes it
difficult to trace individual transactions, thereby enhancing privacy and anonymity.
6. Privacy Coins
Some cryptocurrencies are specifically designed with built-in privacy features. For example,
Monero uses a combination of ring signatures, stealth addresses, and confidential transactions
to provide strong privacy guarantees. Zcash employs zero-knowledge proofs to enable
selective transparency, allowing users to disclose transaction details only to authorized
parties.
CHAIN POLICY
In blockchain, a "chain policy" generally refers to the rules and guidelines that govern how a
blockchain network operates, including how data is added to the chain, how transactions are
validated, and how the network maintains its integrity. These policies ensure the security,
transparency, and immutability of the blockchain.
Here's a more detailed explanation:
Key Aspects of a Chain Policy:
Data Structure and Linking:
Blockchain uses a chain of blocks, where each block contains a set of transactions and a
cryptographic hash of the previous block. This linking mechanism ensures that once data is
recorded, it cannot be altered without affecting the entire chain, providing immutability.
Consensus Mechanisms:
At the heart of any blockchain's chain policy is its consensus mechanism.
They are crucial for maintaining the security and integrity of the blockchain by
preventing issues like double-spending and ensuring data consistency.
Examples include:
o Delegated Proof of Stake (DPoS): Token holders vote for delegates to validate
transactions and create blocks.
Chain policy incorporates solutions like sharding (dividing the blockchain into smaller
segments) and Layer 2 protocols (building additional layers on top of the main chain) to
improve transaction throughput and efficiency.
However, enhancing scalability often involves tradeoffs with decentralization and security, a
concept known as the blockchain scalability trilemma
Each block's hash is linked to the previous block's hash, creating an irreversible chain
that ensures data integrity
Interoperability:
With the emergence of numerous blockchain networks, interoperability – the ability
for different blockchains to communicate and share data – is becoming increasingly
important.
This facilitates the growth of decentralized finance (DeFi) and other applications that
require interaction across multiple blockchain platforms
Use Case Validation: Determine if blockchain is the most suitable technology for the
identified problem, considering factors like security, transparency, immutability, and
decentralization.
Feasibility Analysis: Evaluate the technical, economic, and market viability of the project.
Defining Scope and Objectives: Clearly outline what the application will achieve and its
boundaries.
Consensus Mechanism: Select the method by which the network verifies and validates
transactions (e.g., Proof of Work, Proof of Stake).
Data Structure and Block Design: Define how data will be organized and stored within the
blockchain, including the contents of each block.
Network Topology: Decide on the network's structure and how nodes will interact.
UI/UX Design: Create an intuitive and user-friendly interface for the application.
Frontend Development: Build the user-facing interface, including web and mobile
applications.
Backend Development: Develop the server, databases, and APIs to connect the frontend to
the blockchain.
Node Setup and Infrastructure: Establish the necessary hardware and software
infrastructure to run the blockchain network.
API Development: Create interfaces for seamless interaction between the application and the
blockchain network.
Database Design: Structure any off-chain databases to store data not placed directly on the
blockchain.
4. Testing and quality assurance
Unit Testing: Verify that individual components, including smart contracts, function as
expected.
Integration Testing: Ensure that different modules of the application interact correctly with
each other.
Security Audits: Conduct thorough reviews to identify and address vulnerabilities in the
smart contracts and network.
Performance Testing: Simulate real-world usage to assess the application's performance and
scalability.
Smart Contract Deployment: Deploy the smart contracts to the chosen blockchain network.
Bug Fixing and Security Patching: Address any issues or vulnerabilities that emerge after
launch.
Implementing Upgrades and Patches: Update the application and network components as
needed.
Managing Forks and Versioning: Handle potential forks in the blockchain and manage
different versions of the application.
Data Privacy and Protection: Ensure compliance with data protection laws like GDPR to
protect sensitive user information.
By carefully navigating each stage of this lifecycle, businesses and developers can create
secure, scalable, and impactful blockchain applications that address real-world challenges and
unlock new opportunities for various industries, according to Rapid Innovation.
Compatibility
Old nodes can't validate new Old nodes can still validate
Impact on Nodes transactions. transactions.
Consensus
Requires majority consensus. Requires less consensus.
Requirement
Smaller-scale updates to
Can improve scalability drastically
improve performance or
(e.g., by increasing block size).
Scalability security.