Download as pdf or txt
Download as pdf or txt
You are on page 1of 70

Analyzing Of Block Packing

Strategies By Bitcoin Mining


Pools

By
Ain Ul Zia
275309

Supervisor
Dr. Syed Taha Ali
Department of Electrical Engineering

A thesis submitted in partial fulfillment of the requirements for the degree


of Masters of Science in Electrical Engineering (MS EE)

In
School of Electrical Engineering and Computer Science,
National University of Sciences and Technology (NUST),
Islamabad, Pakistan.
(August 2021)
Abstract

Bitcoin, decentralised and conventionally produced in 2008, is a digital cur-


rency. Bitcoin nodes are continually creating and propagating blocks, a set of
newly approved transactions published in Bitcoin’s Ledger, distributed and
secure. In the Bitcoin network, mining pools play a major role in finding a
block. When a new block is being created, miners tend to pay the highest
fees for transactions. The best set of transactions that are targeted at the
highest overall charge rate reflects a classical NP-hard problem. To address
this issue, many of the solutions proposed have focused on sorting the col-
lection of pending transactions from the Bitcoin mempool by the fee/size
ratio.Consequently, miners can not concentrate too much of their computing
capacity on optimal transaction gathering, and transactions are also increas-
ing over time. Therefore, an effective plan is now desirable. This theoretical
and analytical thesis analyses the block packaging techniques of the mining
pools. Our data illustrates the strategy that is most common amongst min-
ers, which boosts the mining market. An analysis will also be made of other
dynamic tendencies in the strategies provided.

ii
Acknowledgment

To begin, I want to express my gratitude to Allah Almighty for endowing me


with the intelligence necessary to complete this work. Then I’m grateful to
Dr. Syed Taha Ali, my supervisor, for his enthusiasm, support, and direc-
tion. I’d want to convey my profound appreciation for his unfailing faith in
me during this research project, without which this study would have been
impossible. Finally, but certainly not least, I want to offer my heartfelt ap-
preciation to my adoring family for their uncompromising love, support, and
prayers.

v
Table of Contents

List of Figures ix

1 Introduction 1
1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Problem Definition . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Objectives and Research Goals . . . . . . . . . . . . . . . . . 2
1.4 Thesis Organization . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Background 5
2.1 A Brief Overview of Blockchain . . . . . . . . . . . . . . . . . 5
2.1.1 Blockchain Network Characteristics . . . . . . . . . . . 6
2.1.2 Blockchain Applications . . . . . . . . . . . . . . . . . 6
2.2 Bitcoin Cryptocurrency . . . . . . . . . . . . . . . . . . . . . . 6
2.2.1 Centralized and Decentralized System . . . . . . . . . . 7
2.2.2 The Bitcoin system in contrast to our current system . 8
2.3 What is the operation of a Bitcoin? . . . . . . . . . . . . . . . 9
2.3.1 Transactions . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.2 Bitcoin Block . . . . . . . . . . . . . . . . . . . . . . . 10
2.3.3 Hashing . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.4 Mining . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

vi
TABLE OF CONTENTS vii

2.3.5 Proof of Work-PoW . . . . . . . . . . . . . . . . . . . . 13


2.3.6 Mempool . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.4 Mining Process . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.4.1 Mining Reward . . . . . . . . . . . . . . . . . . . . . . 17
2.4.2 Identifying difficulty . . . . . . . . . . . . . . . . . . . 17
2.4.3 Mining and Energy . . . . . . . . . . . . . . . . . . . . 18

3 Literature Review 19
3.1 Mempool Specifications . . . . . . . . . . . . . . . . . . . . . . 23
3.2 Importance of Mining Pools in Bitcoin . . . . . . . . . . . . . 24
3.3 Mining hardware . . . . . . . . . . . . . . . . . . . . . . . . . 26

4 Bitcoin Mining Pools 28


4.1 Methods of Mining . . . . . . . . . . . . . . . . . . . . . . . . 28
4.1.1 Solo Mining . . . . . . . . . . . . . . . . . . . . . . . . 28
4.1.2 Pool mining . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2 Mechanism of Reward . . . . . . . . . . . . . . . . . . . . . . 29
4.3 Principles of Pooled Mining . . . . . . . . . . . . . . . . . . . 31
4.3.1 Concentration of Pools in China . . . . . . . . . . . . . 31
4.3.2 Miners’ Migration behaviour to Pools . . . . . . . . . . 31
4.4 Top Bitcoin Mining Pools . . . . . . . . . . . . . . . . . . . . 32
4.4.1 Poolin.com . . . . . . . . . . . . . . . . . . . . . . . . 33
4.4.2 ANTPool . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.4.3 f2pool . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.4.4 Slush Pool . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.5 The Knapsack problem???? . . . . . . . . . . . . . . . . . . . 35

5 Simulation Results and Analysis 38


5.1 Block Packing Algorithms . . . . . . . . . . . . . . . . . . . . 38
TABLE OF CONTENTS viii

5.1.1 Greedy Algorithm . . . . . . . . . . . . . . . . . . . . . 39


5.1.2 Greedy Algorithm with Advice . . . . . . . . . . . . . 40
5.1.3 Sorting based algorithm-Delta . . . . . . . . . . . . . . 41
5.2 The process of collecting and processing data . . . . . . . . . . 41
5.2.1 Bitcoin Node Configuration . . . . . . . . . . . . . . . 42
5.2.2 Processing of JSON Log files . . . . . . . . . . . . . . . 43
5.2.3 Data Extraction through APIs . . . . . . . . . . . . . . 43
5.3 Simulations And Analysis . . . . . . . . . . . . . . . . . . . . 44
5.3.1 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.3.2 Experiments And Analysis . . . . . . . . . . . . . . . . 45

6 Conclusion and Future Work 53


6.0.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . 53
6.0.2 Future Directions in Research . . . . . . . . . . . . . . 54
List of Figures

2.1 Centralized System . . . . . . . . . . . . . . . . . . . . . . . . 7


2.2 Decentralized System . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 working of bitcoin network . . . . . . . . . . . . . . . . . . . . 9
2.4 Chain of blocks . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.5 Structure of a block . . . . . . . . . . . . . . . . . . . . . . . . 12
2.6 A flowchart depicting the Bitcoin mining process . . . . . . . . 15

4.1 Every 210,000 blocks, or approximately every four years, the


rewards for successfully completing one block are halved. . . . 30
4.2 Top rated bitcoin mining pools in 2021 . . . . . . . . . . . . . 33
4.3 demonstrating the notion of the knapsack problem . . . . . . . 36

5.1 The total number of Bitcoin transactions that are currently


pending in the mempool. The spikes in the middle correspond
to the exponential growth and decline of the Bitcoin price at
the end of 2017 and the beginning of 2018. When markets ex-
perience volatility, the number of pending transactions rapidly
increases [3]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2 Block diagram demonstrating data collection and processing
procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

ix
LIST OF FIGURES x

5.3 snapshot of a BTC.com Explorer presenting numbers of mined


blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.4 The number of blocks generated between 13 and 19 May 2019
by several mining pools utilising various techniques at various
timestamps is displayed. . . . . . . . . . . . . . . . . . . . . . 46
5.5 The number of blocks generated between 04 and 08 Dec 2020
by several mining pools utilising various techniques at various
timestamps is displayed. . . . . . . . . . . . . . . . . . . . . . 46
5.6 Between 13 May and 19 May 2019, a pie chart depicts the
most often utilised technique among miners and also indicates
the presence of other techniques. . . . . . . . . . . . . . . . . . 47
5.7 The following line graph illustrates the various mining pools’
nonlinear behaviour. . . . . . . . . . . . . . . . . . . . . . . . 48
5.8 The power law relationship between timestamp count and al-
gorithm is illustrated in a graph from the dataset from 13 May
to 19 May 2019. . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.9 The power law relationship between timestamp count and al-
gorithm is illustrated in a graph from the dataset from 04
December to 08 December 2020. . . . . . . . . . . . . . . . . . 49
5.10 The scatter plot depicts the dataset from December 04, 2018
to December 08, 2020. utilises two unique methods to demon-
strate the interplay between generated fees in blocks: Delta
and Greedy+Advice. . . . . . . . . . . . . . . . . . . . . . . . 50
5.11 Line graph displaying the produced block fees using the Delta,
Greedy+Advice, and Greedy algorithms from 04 December to
08 December 2020. . . . . . . . . . . . . . . . . . . . . . . . . 51
LIST OF FIGURES xi

5.12 The graph depicts the difference in fees between Delta, Greedy,
and Greedy+Advice for all three algorithms from December
04 to December 08, 2020. . . . . . . . . . . . . . . . . . . . . . 52
List of Tables

2.1 block header structure . . . . . . . . . . . . . . . . . . . . . . 11

xii
Chapter 1

Introduction

This chapter of the offered thesis introduces the research issue and discusses
the primary motivation for conducting research on block packing structures.
It elaborates on the thesis’s problem statement, main objectives, and re-
search goals. The chapter closes by explaining the chapter’s organisation
and providing a brief synopsis of each chapter’s contents.

1.1 Motivation
With a market capitalization of $68 billion as of January 2019, the Bit-
coin network has garnered considerable attention from both industry and
academia. Mining pools, the network’s primary component, control the
majority of computing resources and are critical for network security and
performance. While numerous metrics of the Bitcoin network exist, little
is known about the specific behaviour of mining pools (e.g., empty blocks,
mining revenue, transaction gathering, or block packing tactics) and their
impact on Bitcoin end users [44].This void must be filled by conducting a
comprehensive analysis of mining pools and their behaviour. A miner’s goal

1
CHAPTER 1. INTRODUCTION 2

is to identify transactions with the highest total fee. The transactions vol-
ume in the Mempool is an exponential rise due to the volatile nature of and
changing behaviour of the cryptocurrency market. Meanwhile, the number
of transactions for active cryptocurrencies such as Bitcoin has been steadily
increasing over time. As a result, it’s critical to have an efficient system that
chooses transactions in a timely manner while providing the most total block
fees without breaching Bitcoin’s rules and regulations [19].

1.2 Problem Definition


Typically, a miner will select a group of transactions that have the greatest
total fees and do not exceed the block size [33]. The incentive for a miner
to add blocks is both the block reward and transaction fees. In the early
days of Bitcoin, the value of the reward dominated the fees. But the Bit-
coin protocol, on the other hand, gradually reduces the value of the reward
over time. To be more specific, the reward is halved for every 210k blocks
mined. As a result, fees have increased in importance, and they are pre-
dicted to eventually outweigh the total value to miners when adding blocks.
As a result, choosing a group of transactions with higher fees is becoming in-
creasingly important.Therefore, it is preferable to examine and notice which
strategy gives the best block with the highest fees and in the shortest amount
of time. Additionally, it is critical to understand the most recent trends in
block packing strategies used by bitcoin mining pools.

1.3 Objectives and Research Goals


The following are the primary goals of this research project:
CHAPTER 1. INTRODUCTION 3

• To learn more about various mining strategies and evaluate the be-
havioural patterns that influence the generating block.

• Analyze the influence of ”halving the block reward” on the transaction


fee element as well.

• To determine which is a critical aspect in Bitcoin mining.

• To analyze the impact of mempool size on Bitcoin network.

• To analyse the specifics of mining techniques and the technological


obstacles encountered throughout the mining process in order to select
the optimal one. And perhaps come up with a better solution as well.

1.4 Thesis Organization


The provided thesis has been divided into chapters, each of which covers a
different area of our research. This is how the thesis is organized:
Chapter 1: Introduction This chapter discusses the thesis work’s intro-
duction, motivation, problem definition, objectives, research goals, and thesis
organisation.
Chapter 2: Background The history and introduction of blockchain tech-
nology are discussed, as well as the mining process.
Chapter 3: Literature Review This chapter contains a review of prior
related research studies, as well as problem identification and analysis.
Chapter 4: Bitcoin Mining Pools This chapter includes a detailed dis-
cussion of the significance of various bitcoin mining pools, as well as a thor-
ough examination of their mining behaviour.
Chapter 5: Simulation Results and Analysis This chapter contains
CHAPTER 1. INTRODUCTION 4

data graphs compiled from multiple simulation outcomes, as well as an anal-


ysis and comparison of several algorithms.
Chapter 6: Future Work and Conclusion This chapter finishes the
thesis by presenting the collected results and discussing shortfalls and future
work.
Chapter 2

Background

This chapter provides an overview of blockchain technology, its fundamental


features and characteristics, and how it works. It goes on to explain the
Bitcoin cryptocurrency, its network, the mining process, and a few other
crucial points.

2.1 A Brief Overview of Blockchain


Satoshi Nakamoto created blockchain technology in 2008 to enable the un-
derlying infrastructure of the crypto-currency ‘Bitcoin’ [30]. Blockchain is
known as a distributed ledger technology which stores data in the form of a
continuous list of blocks that are securely and cryptographically linked to-
gether in such a way that the data stored inside the blocks is immutable.
Each block records the hash of the block before it. Any change in data will
be reflected in the hash of the block. As a result, changing data becomes
impossible without changing the hash of each succeeding block in sequence.

5
CHAPTER 2. BACKGROUND 6

2.1.1 Blockchain Network Characteristics

A blockchain network is a peer-to-peer network that is decentralised and


dispersed. It is made up of interconnected nodes. There is no need for
a middleman or a central institution because two parties can interact and
transact directly with each other. Every node keeps a copy of the public
database. It is an append-only database, which means that once data is
added, it cannot be modified. The data’s ownership may also be monitored
because each transaction is signed by a user’s private key and then validated
by his public key. As a result, while transferring transactions through the
network, both integrity and attribution are preserved.

2.1.2 Blockchain Applications

Due to the transparency, immutability, and distributed nature of the Blockchain


network, it has found its way into a variety of secure application areas such
as identity management, stock trading, decentralised voting, and property
or asset ownership tracking applications. Crypto-currencies are also one of
the Blockchain applications, in which traditional banking involving a central
banking authority does not apply. The exchanges are stored in the form of
transactions, which are then aggregated into data blocks.

2.2 Bitcoin Cryptocurrency


These days, digital currencies are extremely popular. Bitcoin is the most
widely used digital money, with a market valuation of USD 71,882,552,340.
It is a cryptocurrency, which is a decentralised, distributed and peer-to-peer
virtual currency [4]. Satoshi Nakamoto is the pseudonym used by the creator
of Bitcoin. Satoshi Nakamoto’s identity is still unknown. Because it is a
CHAPTER 2. BACKGROUND 7

decentralised cryptocurrency, it lacks the centralised control that banks do.


It does not rely on a third party for moving funds from one user to another.
It enables users to transmit money via the internet as easily as sending an
email, without the need for an intermediary.

2.2.1 Centralized and Decentralized System

These days, we use fiat currencies that are centralised. If two parties wish
to transfer money, they must go through a third party who initiates and
verifies the transaction. If user A wishes to send money to user B, user A
initiates the procedure, then a third party (in this case, a bank) receives the
notification, verifies the data, and confirms the transaction. After approval,
the money goes to user B. This requires a lot of time and money from the
bank.

Figure 2.1: Centralized System

Nodes or ”peers” in the network maintain Bitcoin transactions. That


eliminates the need for a central server or hub. As part of the Bitcoin network,
CHAPTER 2. BACKGROUND 8

each user has access to each transaction. Users verify transactions as well
as approve them if they are valid. If the public ledger of the transaction is
approved by all users on the network, the sum is transferred from user A to
user B. Compared to centralised systems, this takes less time and has lower
transaction fees.

Figure 2.2: Decentralized System

2.2.2 The Bitcoin system in contrast to our current


system

Bitcoin is an entirely new system. As can be seen, Bitcoin is fundamentally


different from the conventional banking system. The current system is based
on a centralised financial system. It accepts payment in a variety of currencies
(USD, ASD, NPR, and INR, for example). On the other hand, the Bitcoin
protocol is a decentralised system that accepts virtual currency (Bitcoin) as
a payment method. Bitcoin and other cryptocurrencies are based on the
blockchain protocol. [18].
CHAPTER 2. BACKGROUND 9

2.3 What is the operation of a Bitcoin?


When we talk about transferring bitcoins between other identities or entities,
we are not referring to those identities in real life. This means that these
identities are unrelated to real-world identities. They are seen as a series
of numbers, or as pseudonyms. This is done to give the users with whom
we want to transact over the bitcoin network some privacy. In the world
of bitcoin, we talk about transactions,block,hashing, mining, proof of work,
mempool and so on. Let’s find out what these terms genuinely signify.

Figure 2.3: working of bitcoin network

2.3.1 Transactions

Coins are commonly used in the Bitcoin system. These virtual coins do not
exist in reality; rather, they are transactions with some ownership rights.
(2016, Tschorsch and Scheuermann) A transaction is a digitally signed state-
ment or declaration between two parties that is predicated on the exchange
of bitcoins. (Narayanan and colleagues, 2016). When we talk about a wallet
CHAPTER 2. BACKGROUND 10

in real life, we are referring to a physical item that can be touched. Similarly,
the coins we use are real objects that can be used in a variety of ways. A
Bitcoin does not function in the same way that a wallet does. We never
physically hold a bitcoin; instead, we have rights to it. In the case of a bit-
coin, the rights are transferred from one holder to another in the same way
as coins are transferred from person to person. These rights are referred to
as transactions.
Unspent bitcoins are transferred from one user’s address to another. Ev-
ery bitcoin owner has two keys, a private and a public. The private key is
kept secret and only the owner knows it, whereas the public key is known to
everyone and can be used to send bitcoins to the owner. The coins are owned
by an individual whose public key can validate the coins’ digital signature.
Unspent Transaction Output (UTXO) sets contain all the spendable money
on the Bitcoin network. A transaction to send bitcoins from one address
to another requires at least one unspent input and one spendable output.
A transaction has its own unique identity, which is a transaction hash, in
addition to inputs and outputs.

2.3.2 Bitcoin Block

Bitcoin is made out of chained blocks which are linked together. Thus, every
block serves as a building block for a blockchain. The Genesis block was the
first block created in the history of Bitcoin. The Genesis block has a height of
0. All subsequent blocks constructed after the Genesis block are stacked on
top of it. Each block put on top of the Genesis block raises the height of the
blockchain by one. Each block contains specific information. A block stores
information such as the size of the block, the total number of transactions
grouped in the block, the transaction itself, and also the block header.
CHAPTER 2. BACKGROUND 11

Figure 2.4: Chain of blocks

Version Version No.


Previous block hash In the blockchain, this is a reference to the hash of the parent block
Merkle root Hash of the block transaction’s Merkle tree’s root
Timestamp The block’s generation time
Difficulty target The Proof of Work algorithm’s difficulty target
Nonce The Proof of Work algorithm employs a counter.

Table 2.1: block header structure

A block header is one of the block’s components. The block header is a


summary of the contents of the block. As stated in Table 2.1, it is made up
of the six components listed below.
The root in this case is a handy summary of every present transaction
in the block that can be accessed without looking at each transaction indi-
vidually. A blockchain’s blocks are linked together in a way that the current
block contains the hash of the preceding block. Because each new block in
a blockchain is linked to the previous ones, we can trace any block all the
CHAPTER 2. BACKGROUND 12

way back to the Genesis block [4]. Due to this dependency and the inter-
connection of the blocks, it is extremely difficult for potential hackers to edit
any block in a blockchain. This is because each change to the data in any
block on the blockchain results in a change to the hash of the current block,
which results in an error in the previous block, which results in an error in
the preceding block, and so on. The figure depicts the general structure of a
block.

Figure 2.5: Structure of a block

2.3.3 Hashing

Bitcoin transactions are hashed using cryptographic hash algorithms. The


technique of translating digital data of any arbitrary size to data of a definite
CHAPTER 2. BACKGROUND 13

size is known as hashing [5].In other words, a hash is a data’s digital signa-
ture. It is the procedure of transforming readable information into something
that is absolutely meaningless. SHA (Secure Hash Algorithm) is a collec-
tion of cryptographic hash algorithms published by the National Institute
of Standards and Technology (NIST) [6]. The Bitcoin system employs the
SHA-256 hashing algorithm. The algorithm always returns a 256-bit value
in the hexadecimal number system. The SHA-256 function’s result is fre-
quently referred to as the hash of its input. The SHA family of algorithms
is subdivided into four subgroups: SHA-0, SHA-1, SHA-2, and SHA-3 [11].

2.3.4 Mining

A block of data is contributed to the blockchain by a group of nodes called


miner nodes, managed by miners. Miners compete to find a given hash value
by continually hashing the block data with a nonce value. Proof Of Work
is the consensus algorithm (PoW). When one of them solves the riddle first,
it adds a block to the blockchain. The new block is distributed to all net-
work nodes. The nodes next verify the block and update their local database
copies. The miners are compensated for their investments in processing power
and hardware resources required to solve such complicated mathematical rid-
dles. The more miners contribute to hashing power, the safer the blockchain
network is. The data put on the blockchain is public and its integrity can be
confirmed by anybody, providing transparency for all parties involved.

2.3.5 Proof of Work-PoW

PoW is a consensus algorithm developed by Bitcoin that is widely used by


many other cryptocurrencies as well. It is made up of a complicated cryp-
tographic mathematical puzzle. It searches for a value known as a nonce (a
CHAPTER 2. BACKGROUND 14

number that is only used once). Nonce is a counter in the block header that
miners use to modify the hash value of a block to meet the hash criterion.
When the nonce value is hashed with SHA-256, the resulting output hash
begins with a particular number of zeros [29]. The average amount of work
required for a specific block is determined by multiplying the exponential
by the number of zeros in the right hash. This indicates that the Proof of
Work contains a high level of computation in the verification process. Min-
ers’ hardware achieves this high level of computing. Miners usually mine the
blocks by computing the hash of that block with a changing nonce. So there
is no set formula or pattern for varying the nonce. It is changed in a random
order. The miner changes the nonce until the resulting hash value equals or
is less than a given goal value.

2.3.6 Mempool

When a user initiates a transaction using a wallet, it is broadcast to all


network nodes. Each node on the network has its own data structure in
memory called the mempool that temporarily stores unconfirmed transac-
tions. Transactions are then picked up by miners and added to the block.
When a new block comes, the mempool re-syncs its content transactions and
eliminates those that were added to the block. Because of their lower cost,
certain transactions may never be picked up by miners and are eventually
purged from the mempool after their expiration time. Each Bitcoin network
node has its own version of the mempool contents, which is determined by
the node’s connectivity, network throughput, and latency. A newly broadcast
transaction may appear in the mempool of certain nodes, while others may
take some time to get it, depending on how strongly the node is connected
to its nearby peers on the network.
CHAPTER 2. BACKGROUND 15

2.4 Mining Process


To become a Bitcoin miner, you must first join the Bitcoin network and link
to other nodes. Miners are required to accomplish six tasks in total.

Figure 2.6: A flowchart depicting the Bitcoin mining process

1. The miner must monitor the network for broadcast transactions. They
must validate the transactions by ensuring that the signatures are cor-
CHAPTER 2. BACKGROUND 16

rect and that the outputs have not been spent previously. This is done
to alleviate the issue of double spending.

2. Miners should possess all previous blocks that comprise the blockchain
prior to joining the network. They monitor the network for new blocks.
Then they must validate each received block by validating each trans-
action contained within. Additionally, they must verify that the clock
has the proper time.

3. Miners can begin creating their own blocks once they acquire the most
recent copy of the blockchain. To accomplish this, the miner aggregates
all transactions into a new block that extends the most current block.

4. Miners must now discover a nonce that validates the block. This is a
critical step in the mining process and demands considerable effort.

5. Assume that the block is approved following the discovery of a nonce.


Even if the block is accepted, there is no certainty that it will be in-
cluded in the consensus chain. If more miners accept and begin mining
on top of the same block, the block becomes a member of the consensus
chain [31].

6. If all miners accept the block and add it to the relevant section of the
consensus chain, the miner who worked on determining the nonce for
that block will be rewarded. At the moment, the block reward is 6.25
Bitcoins. Additionally, if any of the transactions included in the block
include transaction fees, the miner takes those costs as well.
CHAPTER 2. BACKGROUND 17

2.4.1 Mining Reward

The reward for Bitcoin mining decreases as the quantity of Bitcoins mined
increases. The maximum amount of Bitcoin that may be mined is 21 Mil-
lion. After successfully mining 210,000 blocks, the payout is halved. Mining
210,000 blocks will take approximately four years. The current prize is 6.25
Bitcoins. At first, the payout for mining Bitcoin was set at 50 Bitcoin. Apart
from the reward for mining, miners also receive a fee for each successful trans-
action added to the blockchain [2].

2.4.2 Identifying difficulty

Every 2016 blocks, the difficulty of mining Bitcoin varies. The time required
to mine 2016 Bitcoin blocks is approximately two weeks. This means that
the Bitcoin mining difficulty is recalculated approximately every two weeks.
Below the following mentioned formula is used to determine the difficulty of
Bitcoin mining:

new dif f iculty = (old dif f iculty∗2016∗10min)/(total time to mine previous 2016 blocks)

Thus, mining 2016 blocks would take around two weeks if a block was
created exactly every ten minutes. The difficulty of the mining process is
always a self-adjusting in response to the network’s aggregated mining power.
But if additional miners join the Bitcoin network, the difficulty increases,
making it more difficult to solve the problem; if a large number of them
leave, the difficulty falls, making it easier to solve [1]. The difficulty rate
must be increased or decreased to maintain control over the rate of new
block production.
CHAPTER 2. BACKGROUND 18

2.4.3 Mining and Energy

Mining is an energy-intensive process, necessitating the use of powerful com-


putational hardware. Mining consumes megawatts of electricity and has
substantial operational expenses (Narayanan et al. 2016; Tschorsch and
Scheuermann 2016). Initially, CPUs were employed, followed by GPUs, FP-
GAs, and now ASCIs.Energy is required for mining. In terms of mining,
energy can be classified as Embodied Energy, which is the physical energy
used to engineer mining equipment such as chips; electricity, which is neces-
sary to do complex computations; and cooling, which is required to safeguard
the equipment and prevent it from malfunctioning.
Chapter 3

Literature Review

This chapter reviews earlier research in the field, as well as identifies and anal-
yses problems connected to Bitcoin networks, mempool, and mining hard-
ware and mining pools. It also discusses the used of mining hardware in the
mining process.

Bitcoin has become a global sensation. Recently, there has been a surge in
public interest in the Bitcoin cryptocurrency. Numerous individuals have
begun Bitcoin mining as a business, while numerous other businesses have
begun accepting Bitcoin as a payment mechanism. Given that Bitcoin was
launched only a few years ago, there is still a great deal of research being
conducted on the cryptocurrency. There are now a few research articles
discussing various elements of Bitcoin, including mining, security of the net-
work, and many attacks on mining pools. Satoshi Nakamoto [30] addressed
every facet of the Bitcoin protocol in his 2009 AD white paper. Although
Bitcoin is often considered to be the first digital cryptocurrency, the notion
of cryptocurrency and the cryptographic techniques that underpin it were
first suggested by David Chaum in his 1983 paper [16]. Bitcoin’s consen-

19
CHAPTER 3. LITERATURE REVIEW 20

sus technique is Proof of Work, and the concept was originally suggested in
1992 by Cynthia Dwork and Moni Naor in their article [21]. Bitcoin achieves
decentralisation through the use of the blockchain idea, which aids in the
resolution of Bitcoin’s double spending problem [17].
According to Dr. Saifedean Ammous [13], Satoshi Nakamoto, the inventor
of Bitcoin, never meant for it to be a new technology; rather, it was to be
a peer-to-peer version of electronic payment. When a transaction occurs,
it is recorded in a block by all nodes on the network. It is then confirmed
by all nodes using mathematical processes. The node that initially solves
the verification operation broadcasts the solution and transaction across the
network. All other nodes verify and approve the transaction and solution.
That first node is compensated with a certain quantity of cash. He mentioned
blockchain applications such as digital payments, which utilise a decentralised
currency system rather than a centralised one; this eliminates third-party in-
tervention and requires more processing power and time. SmartContracts
make use of blockchain currencies via multi-signature wallets and timed pay-
ments. database and record management functionality that is limited to
the native blockchain’s currency. The most successful method of payment is
digital. Additionally, blockchain technology has some challenges, including
redundancy, scalability, regulatory compliance, irreversibility, and security.

In their study paper, Florian Tschorsch and Bjorn [41] address bitcoin’s
fundamental principles, security risks, privacy, and other relevant observa-
tions. This article discusses bitcoin as a decentralised digital currency, in
which each node acts as a bank with a block-chain acting as a distributed
ledger. This is in contrast to the traditional centralised digital currency,
which exemplifies the banking model by issuing unique serial numbers to
CHAPTER 3. LITERATURE REVIEW 21

users and maintaining the ledger. The concept of double spending is briefly
discussed. It occurs when the same coin is sent to two distinct nodes or
users, resulting in the blockchain becoming inconsistent. This is avoided by
checking the legitimacy of all user transactions. Proof-of-work techniques are
used to prevent network assaults. These systems utilise the SHA-256 hash
algorithm to solve cryptographic riddles. A special phrase (discussed) is used
to describe the difficulty of locating a target’s hash. Additionally, Bitcoin
pays users through transaction fees and mining. Initially, the Bitcoin award
was 50BTC, which was halved every four years, and is currently at 12.5BTC.
Whereas transaction fees are almost certainly going to increase in the future.
Bitcoin transactions contain an identifier for the transaction, as well as inputs
and outputs. Each output is utilised as an input, producing a chain of blocks
that enables the transaction to be traced back. This output is a reference to a
script that has inputs, outputs, and a collection of arguments. To ensure the
security of bitcoin, each user is allocated a virtual wallet that contains both
a private and public key. This wallet can be a software wallet with a locally
running bitcoin instance, which is much more vulnerable to attack; a hard-
ware wallet with an offline operating device, which makes it more difficult to
gain access to for an attack; a paper wallet with keys stored in a document,
similar to cash money; or a brain wallet with passphrase hashing for private
and public keys. To strengthen the wallet’s security, multi-signature transac-
tions are employed. These transactions are signed independently. To secure
transactions, elliptic curve cryptography is utilised [27] and [28]. Addition-
ally, changing the transaction id without invalidating it relates to transaction
malleability, which is analogous to double-spending, with the difference be-
ing that the attacker is the receiver party in this situation. Due to the fact
that solo mining produces big but uncommon returns, miners collaborate to
CHAPTER 3. LITERATURE REVIEW 22

build a pool in which they earn continual small payments. The bitcoin net-
work is an unstructured peer-to-peer overlay network focused on transaction
processing and information delivery rather than on the search for specific
data items or files. In terms of scalability, the maximum size of a block is
1MB, which limits the number of transactions and the growth rate of the
block chain, hence preventing block chain extension. Increased scalability
will necessitate additional resources. A high internet speed combined with a
super peer-based overlay structure is required for a higher transaction rate.
The author delves into each of these issues, demonstrating how bitcoin is
continually expanding and developing.

Numerous cryptocurrencies were created in the aftermath of the Bitcoin


proposal. The majority of them use Proof of work as the consensus mecha-
nism for resolving a difficult puzzle. The Proof of Work algorithm, however,
is not the only one used by cryptocurrency developers. Several consensus
methods have been proposed for different cryptocurrencies, including Proof
of Stake, Proof of Activity, Proof of Capacity, and Proof of Burn. The
biggest disadvantage of the proof of work consensus technique is that it con-
sumes enormous amounts of energy. Following that, he then developed a
new consensus mechanism known as Proof of Stake [26]. This algorithm was
implemented to address the issue of excessive electricity use. Proof of Stake
is the consensus algorithm used by cryptocurrencies such as Peercoin, Dash,
Cardano, and KuCoin. However, in 2014, Andrew Poelstra [34] published
a paper entitled ”On Stake and Consensus” in which he demonstrated that
distributed consensus from Proof of Stake is unachievable, concluding that
Proof of Work can not be substituted by Proof of Stake.
Michael Bedford Taylor investigated the evolution of hardware of Bitcoin,
CHAPTER 3. LITERATURE REVIEW 23

from initial generation miners through the development of specialised silicon


ASICs [38]. The CUDA miner was the first publicly available miner, having
been launched in September 2010. Then, shortly afterwards, pool mining
began. Individual mining (also known as solo mining) has no chance in this
extremely competitive environment. The probability of discovering a valid
block and accounting for hardware and electricity costs is unmatched. The
Mining Pool allowed individual miners to pool their hashing power and split
the reward if they were able to mine a block. Also Andreas M. Antonopoulos
shows in his book ”Mastering Bitcoin” [14] that solo mining is a waste of
money at the moment unless one is really wealthy and can acquire a large
amount of ASIC hardware. He advises lone miners on a shoestring budget
to switch to pool mining for Bitcoin mining [32].

3.1 Mempool Specifications


The mempool of a Bitcoin node is a highly dynamic, manipulating, and
volatile storage space for unconfirmed transactions. The contents of the
mempool may vary by node, depending on the node’s network throughput.
The mempool is the first place where newly broadcast transactions on the
network appear. Then, by examining the aggregated batch of transactions,
miners sort and order them according to their fee rates, selecting the most
reasonable ones for the next block. Each node’s mempool is configured with
its own acceptance and rejection policies [35]. Certain mempools may require
transactions to pass through a predefined charge spike. Certain mempools
also establish an expiry time for transactions, such that they are deleted
from the mempool after a certain time period and new transactions can take
their place. At times, malevolent attackers may attempt to flood the network
CHAPTER 3. LITERATURE REVIEW 24

with low-cost spam transactions; thus, these regulations assist in preventing


these spam transactions from reaching the network. All nodes in the network
sync their contents with the current blockchain on a periodic basis, deleting
transactions that have been mined and validated into blocks [12].
The most critical mempool property that may be used to estimate block
fees is the measure of congestion or backlog of unconfirmed transactions.
The more unconfirmed transactions there are, the greater the charge rate for
that time period. This characteristic can also be discovered by calculating
the mempool’s total size in bytes. If the size of the mempool is tracked
over time, measuring the growth rate in bytes per second provides another
critical information for predicting near-future congestion levels. The inflow of
transactions or the number of transactions entering the mempool per second
indicates the incoming traffic rate for a given time interval and can be used
to forecast congestion levels and fee rates in the near future. Thus, mempool
congestion and transaction traffic may be simply determined by criteria such
as the number of unconfirmed transactions, the size of the mempool, the rate
at which the mempool grows, and the incoming rate of transactions.

3.2 Importance of Mining Pools in Bitcoin


The authors attempted to model the selection policy on the set of uncon-
firmed transactions in a Bitcoin node network as a binary classification task
in their work [23]. They then demonstrated that, while fees and transaction
size were predicted to be important factors in the selection procedure, other
network elements such as delay, IP, and even transaction priority were not.
This study extends previous work by applying the technique to specific min-
ing pools and tracking any material changes in their transaction selection
CHAPTER 3. LITERATURE REVIEW 25

criteria. This will serve as an alarm system for all mining pool workers and
for the whole Bitcoin community in the event of this scenario.
To maximise their earnings, a mining pool must select the ideal subset
of transactions from the current mempool that maximises fees while keeping
the block’s overall size below the limit. This is a variant of the 0-1 knapsack
problem [39], with the best solution being NP-hard to find. As a result,
the majority of miners employ a selection policy.By default, the transaction
selection policy [8] selects transactions from the mempool in the following
manner:

• By fee-per-kilobyte, transactions are ordered and ranked in descending


order.

• Unselected transactions are retained in the mempool for future block


attempts.

During bitcoin’s early beginnings, an additional selection rule was to reserve


50 kilobytes of each block for high-priority transactions. And the priority of a
transaction is calculated as the value-weighted sum of the input age and the
transaction’s size in bytes [8], although this calculation is not performed by
default since Bitcoin Core v0.12 [7].But probably the most crucial aspect of
running a Mining Pool is how labour is distributed among member employ-
ees.Initially, miners used the default getwork interface; the server provided
the workers with block headers but no ability to modify transactions. This
meant that they could only try all conceivable nonce values before request-
ing further labour. With modern mining gear, this resulted in an excessive
number of queries.
Bitcoin subsequently began employing getblocktemplate, in which the
server offers the worker with block templates, which they can then use to
CHAPTER 3. LITERATURE REVIEW 26

try to build the next block. This gave workers the ability to choose which
transactions to use, but it also meant that bandwidth requirements were
increased. This was later enhanced to allow employees to experiment with
the timestamp as well, giving them even more choices to test before needing
to request more work. The server in Stratum [9] gives the worker a template
that they can use to construct their own work, as well as more fields than
the time and date. This allows cutting-edge miners to request less frequently.
Furthermore, it deviated from the HTTP protocol, making it faster than its
predecessors and also reducing bandwidth. Finally, it has systems in place to
expedite the introduction of new blocks, lowering the amount of stale work.
Most, if not all, significant mining pools now use Stratum and have disabled
their getwork interface.
Thus the authors in [23] suggest a method for monitoring the transaction
selection policy of Bitcoin mining pools and detecting any departures from
the policy. This is accomplished by developing a prediction model for each
block of the transaction selection policy and tracking any changes in future
importance as new blocks are received. We then offer a scenario in which
a mining pool rejects transactions from a specified country to demonstrate
how their technique would detect this policy change.

3.3 Mining hardware


Numerous experiments have been conducted on a variety of hardware con-
figurations. These trials are important to ascertain the performance of var-
ious pieces of hardware during the mining process. Karl J. O’Dwyer and
David Malone published a report titled ”Bitcoin Mining and its Energy Foot-
print” [32] in which they compared several pieces of hardware using factors
CHAPTER 3. LITERATURE REVIEW 27

such as hash rate, efficiency, power usage, and cost.


According to the authors’ comparison, we can see how hardware per-
formed during Bitcoin mining in 2014. They compared gear in terms of hash
rate, power consumption, cost, and efficiency.From their analysis, we can de-
duce that the Monarch BPU 600c achieves the maximum hash rate of 600,000
Mhash/sec but at a high power consumption and hardware cost.However,
the ATI 5770 is inexpensive and consumes only 108 watts of electricity while
delivering 214.5 Mhash/sec. This appears to be the most efficient hardware
available. Numerous miners and researchers experimented with various types
of CPU, GPU, and ASIC gear in order to determine the most efficient and
effective method of mining Bitcoin. Mining hardware and the number of
miners change throughout time. This raises the rivalry among miners for a
certain block to mine.
According to Calvin Ho’s research [24], multiple comparisons of differ-
ent hardware indicate that specialised ASIC miners such as Avalon ASIC 1,
Avalon ASIC 2, and Block Erupter Blade have demonstrated the best per-
formance at the lowest price and with the least power consumption. While
ASIC miners are intended specifically for mining, CPU and GPU miners are
designed for a variety of other tasks. The cost of a Core i7 CPU with high
specifications is comparable to that of an ASIC miner called Avalon ASIC 2,
but mining performance is significantly higher.
Chapter 4

Bitcoin Mining Pools

This chapter offers a thorough investigation into the mining behaviour of


several bitcoin mining pools as well as a detailed discussion of the significance
of pool mining and how it is related to knapsack problem.

4.1 Methods of Mining


To mine bitcoin, two main types of mining processes are used. Solo mining
is one approach, while pool mining is another.

4.1.1 Solo Mining

Solo mining is the process of mining Bitcoin by a person utilising their own
hardware and operating independently. Due to the fact that solo mining
refers to individual mining, it necessitates a significant investment in hard-
ware in order to compete with other miners and to get the mining reward for
solving the block. The miner collects the reward on his or her own and can
earn a substantial profit if the miner has sufficient hardware resources. The
primary disadvantage of solo mining is that, because of the limited hardware

28
CHAPTER 4. BITCOIN MINING POOLS 29

resources, it may take years for solo miners to produce a legitimate block.
Prior to the advent of pool mining in 2011, all miners operated indepen-
dently [43].

4.1.2 Pool mining

Pool mining enables miners to pool their resources in order to receive con-
sistent payments. Each pool mines Bitcoins using a unique ID [4]. Pool
mining combines the hardware resources of all miners, resulting in a large
amount of power and a considerably faster mining speed than solo mining.
Each member of a pool is assigned a lower difficulty value. Each miner in a
pool now has an easier time solving the hash problem and establishing proof
of work. Each pool miner sends their own work to the pool for verification
by submitting a hash value less than the pool’s target value (referred to as
shares). If a share falls below the network’s target value, the pool claims the
block and the pool operator distributes the reward to all pool miners. The
most often used compensation method in pool mining is ”Pay per share” [43].

4.2 Mechanism of Reward


Incentives [22], [37] are used to incentivize miners to work only on legitimate
blocks, ensuring that invalid blocks are rejected and eventually disappear
from the Bitcoin blockchain. Additionally, it attracts miners to join and
assist the Bitcoin network on a constant basis. Specifically, the miner who
creates a new block successfully receives a set number of mining rewards.
As discussed previously, mining rewards are composed of a predetermined
number of block rewards and a block’s transaction fees. Take note that
block rewards begin with a 50 BTC subsidy. However, the block reward
CHAPTER 4. BITCOIN MINING POOLS 30

subsidy is meant to be gradually reduced to zero BTC after every 210,000


blocks (about every four years) and will eventually reach zero BTC when all
21 million BTCs are minted. Until then, mining incentives will be derived
entirely from transaction fees.

Figure 4.1: Every 210,000 blocks, or approximately every four years, the
rewards for successfully completing one block are halved.

If you’re curious about the precise dates of these halvings, you can consult
the Bitcoin Clock, which provides this information in real time. Interestingly,
throughout its history, the market price of Bitcoin has tended to correlate
closely with the decrease in the number of new coins put into circulation. This
decreased inflation rate increased scarcity, which traditionally has resulted
in an increase in price [25]. If you’re curious about the total number of
blocks mined thus far, various websites, like Blockchain.info, provide this
information in real time [25].
CHAPTER 4. BITCOIN MINING POOLS 31

4.3 Principles of Pooled Mining


The fundamentals of pooled mining are often divided into two components:
share agreement and reward functions. The share agreement [36], [22] stipu-
lates that all members of a mining pool collaborate to mine a new block and
split mining money when one of them succeeds. This ensures that each min-
ing pool member receives reasonably steady mining earnings. The reward
function [36] is a method for allocating mining rewards to pool operators.
Miners submit their solutions to the pool operator after completing the min-
ing task. If the Bitcoin network accepts the solution, the operator collects
mining rewards and distributes them to miners according to a pre-agreed
reward function, such as PPS or PPLNS [23].

4.3.1 Concentration of Pools in China

Before we discuss the finest mining pools, it’s critical to realise that the
majority of mining pools are located in China. Numerous companies have
solely Chinese websites and support. The centralization of mining in China
is one of the most serious concerns confronting Bitcoin at the time. There
are approximately twenty big mining pools. When the percentage of hash
power owned by a pool is divided by the pool’s location, it was calculated
that Chinese pools control 65% of the network hash rate [42].

4.3.2 Miners’ Migration behaviour to Pools

Mining pools have risen to prominence as critical stakeholders in ensuring


the Bitcoin system remains secure, valid, and stable. Individual miners join
mining pools in order to increase their earning predictability.
Numerous unanswered questions remain surrounding the evolution of
CHAPTER 4. BITCOIN MINING POOLS 32

mining pools throughout Bitcoin’s history, as well as when and why min-
ers join or quit mining pools. Mining pools provide incentives to individual
miners and retain a portion of the awards for their profits (pool fee). Indi-
vidual miners commit computational resources in order to get a reward for
mining. They can choose to join a pool (new miners), to bounce between
pools (pool hoppers), to discontinue mining activities (dropout miners), or
to engage in numerous pools (cross-pooling miners) [40].The relocation of
miners has a direct effect on the market for mining pools. This is done by
automatically altering the mining difficulty every 2,016 blocks (two weeks)
based on the total hash rate to keep the block discovery rate at 10 minutes.
The network also pays miners and sets the block reward. The block reward
starts at 50 BTC each block (block 0) and is halved every 210,000 blocks (4
years).

4.4 Top Bitcoin Mining Pools


Let’s have a look at a couple of the best bitcoin mining pools and also assess
their advantages and disadvantages. The below figure 4.2 illustrates the
industry’s largest bitcoin mining pools.
CHAPTER 4. BITCOIN MINING POOLS 33

Figure 4.2: Top rated bitcoin mining pools in 2021

4.4.1 Poolin.com

Poolin is a Bitcoin and multi-cryptocurrency mining pool that enables you


to easily invest in cryptocurrencies such as Bitcoin, Bitcoin Cash, Ethereum,
Litecoin, and ZCash [10]. Poolin is the world’s largest mining pool and
charges a significant price. It was founded by the same individuals who
founded BTC.com, which was subsequently acquired by Bitmain. It is a
Chinese-based mining pool with a large number of Chinese miners, but it is
open to all miners worldwide [42].
CHAPTER 4. BITCOIN MINING POOLS 34

4.4.2 ANTPool

Antpool began mining in March 2014, nearly four years after the first mining
pool, Slushpool [42]. Antpool is a top Bitcoin mining pool that enables
you to easily mine and exchange bitcoin [10]. Despite recent controversies,
Antpool continues to be the top Bitcoin mining pool by hash rate on the
Bitcoin network. Antpool controls around 15% of all Bitcoin mining pools’
overall hash rate [42].However, Antpool lacks a graphical user interface [10].

4.4.3 f2pool

F2Pool began operations in 2013 in Beijing. It quickly spread to other conti-


nents as a result of its popularity. The programme is now available in a num-
ber of countries, including Russia, Canada, and the United States. F2Pool
is the second-largest Bitcoin mining pool on the market today, controlling
17.5 percent of the market. Additionally, keep in mind that F2Pool has the
potential to become the largest pool in the near future. For comparison’s
sake, Poolin, the largest pool, only has a 0.7 percent market share advan-
tage over F2Pool. And Slush Pool, another of the largest pools, controls
somewhat more than half of what Poolin does [42]. Additionally, it supports
CHAPTER 4. BITCOIN MINING POOLS 35

Bitcoin trading via iOS and Android devices. This platform supports a va-
riety of languages, including English, Spanish, and Chinese. Additionally,
f2pool supports over 40 digital currencies [10].

4.4.4 Slush Pool

Slush Pool was the first mining pool, and its customers have mined over 1
million Bitcoins over the last decade using its services and software: Brai-
insOS and BraiinsOS+. The Slush Pool was founded in 2010 and was one
of the first Bitcoin mining pools. Initially, it was referred to as the ”Bitcoin
Pooled Mining Server,” or BPMS for short. This proportion places it among
the Internet’s top five Bitcoin mining pools [42].It is one of the largest mining
pools and notifies users when an issue is found. It enables the extraction of
bespoke data sets from the system using the API. The Slush Pool assists you
in minimising losses due to hardware breakdown and connection problems.
Additionally, it lacks a variety of coins [10].

4.5 The Knapsack problem????


Definition As defined, given a set of objects with specified weights and
values, the objective is to maximise the value contained within a knapsack
while maintaining the weight limit.It is a Dynamic Programming Problem
that falls under the subject of optimization.
CHAPTER 4. BITCOIN MINING POOLS 36

Figure 4.3: demonstrating the notion of the knapsack problem

The above example provides the weights of several honeycombs and the
values associated with them. The objective is to maximise the amount of
honey that fits into the bear’s knapsack.
Each transaction has a certain size, which is often determined by the
number of inputs and outputs. If these values are greater, the transaction size
will be greater. The bitcoin network broadcasts these transactions. Miners
receive these transactions and verify them before adding them to the Miner’s
memory pool (Mempool), where they wait to be confirmed. By confirmation,
we imply that transactions are added to the Block and deleted from the
Mempool. Mempools typically contain over 100,000 transactions. Whereas
Block has a finite size of 1MB and can only include a subset of transactions.
Those that have requested a transaction provide incentives to miners in order
for their transaction to be included in the block. This is referred to as the
Transaction Fee [15].So we can conclude that:

• Mempool contains a collection of transactions.


CHAPTER 4. BITCOIN MINING POOLS 37

• Each transaction has a size associated with it.

• If a transaction is to be included in the Block, a transaction fee is paid


to the Miner.

• A block with a limited capacity.

We can simply conclude from the foregoing that the issue at hand is compara-
ble to a knapsack. The knapsack problem is an illustration of combinatorial
optimization. Its name derives from a circumstance in which a large number
of objects with varying values and weights are compared to determine the
most profitable group of objects that can fit into a fixed-sized bagpack.
Chapter 5

Simulation Results and


Analysis

This chapter includes data graphs generated from different simulation results,
as well as an examination and comparison of several block packing techniques
used by bitcoin mining pools.

5.1 Block Packing Algorithms


The traditional knapsack problem, which is an NP-hard issue, is equivalent
to finding a set of transactions with the maximum total charge that fit into
a block. Meanwhile, miners are in a race to mine blocks and hence cannot
devote an excessive amount of processing effort to selecting the optimal col-
lection of transactions. The majority of previous solutions to this challenge
are based on categorising the set of pending transactions according to their
fee-to-size ratio. While sorting is not a barrier in normal circumstances,
transactions can expand explosively in the event of market turmoil such as
that experienced in 2017 shown in figure 5.1. Meanwhile, the total volume

38
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 39

of transactions continues to grow. As such, an efficient technique that does


not require sorting transactions prior to generating a block is preferable [20].
We will examine the three basic block packing techniques that are used by
practically all miners. Additionally, we will examine how miners constantly
vary their mining approach when generating blocks.

Figure 5.1: The total number of Bitcoin transactions that are currently pend-
ing in the mempool. The spikes in the middle correspond to the exponential
growth and decline of the Bitcoin price at the end of 2017 and the begin-
ning of 2018. When markets experience volatility, the number of pending
transactions rapidly increases [3].

5.1.1 Greedy Algorithm

• This is the simplest algorithm (pure online greedy algorithm).

• Process the transactions sequentially in any sequence, and choose any


transaction with greed.

• This algorithm is insensitive to transaction density.

Density T X = (T Xf ees)/(T Xsize)


CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 40

• On the positive side, the algorithm is pretty fast and runs in O(n) to
form a block from a mempool of n transactions.

Drawback: In the worst-case scenario, this algorithm performs pretty


poorly. For instance, if the initial transaction has a size of 1 and a density
close to 0, it will be chosen over smaller transactions with arbitrarily bigger
rewards.

5.1.2 Greedy Algorithm with Advice

• The advise in this algorithm specifies a lower bound on the transaction


density that should be accepted (online advice model).

• Selects transactions with a higher density than the value of α specified


in the advice.

• The α can be adjusted based on historical data. We can experiment


with 100,000 different α values and pick the one that maximises the
overall fee for a particular mempool state. Thus, by analysing previ-
ously mined blocks and miners’ behaviour in our simulation, we were
able to set the alpha optimal solution of an offline algorithm (in this
case, Delta) in order to increase its value by comparing the density of
each transaction to the total density of the offline algorithm’s block.

• It was anticipated that this method would outperform the greedy algo-
rithm. However, the presence of outliers leads to a quality metric that
is unbounded.

Drawback: If the initial transaction has a density greater than and a


size of 1, it will be chosen over smaller transactions with arbitrarily higher
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 41

fees.

5.1.3 Sorting based algorithm-Delta

• Sorting algorithms are the most prevalent and practical method for
picking cryptocurrency transactions, and the Delta algorithm is the
most well-known among miners.

• Delta is equivalent to first sorting the set of transactions by their density


and then performing the greedy algorithm.

• When a block is formed, the largest transaction (with the greatest


density) is repeatedly extracted. If the block contains sufficient space
for the extracted transaction, it is added to the block.

• They provide a high level of service in terms of the overall fee associated
with specified transactions.

• Additionally, our analyses indicate that this approach is blind to the


size of transactions with similar densities.

5.2 The process of collecting and processing


data
We followed the methods outlined in the block diagram below for data col-
lection and processing. We gathered the data for this thesis from the bitcoin
node itself, then built the Mempool image using the mempool exit and mem-
pool entrance JSON log files. We replicate the Miner’s Mempool in this
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 42

process by creating additional mempool snapshots at intervals of 1 or 10


seconds.

Figure 5.2: Block diagram demonstrating data collection and processing pro-
cedure

5.2.1 Bitcoin Node Configuration

A Bitcoin node runs the Bitcoin core code base and keeps an up-to-date full
copy of the Bitcoin database. It then maintains validating, listening, and
forwarding all current transactions, and syncs its database with the updated
blockchain. There are various ways to run a Bitcoin node. Bitcoin full nodes
can run in pruned or archived mode. In pruned mode, the node just keeps the
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 43

newest blockchain states and uses less disc space than in archival mode, which
keeps all past data and uses a lot of disc space. Bitcoin light nodes simply
store block headers and rely on full nodes for data. Installed a full Bitcoin
node in pruned mode with minor code changes. It took 4–5 days for the
node to fully sync with its peers. Once fully synced, it began receiving and
forwarding network transactions. The mempool is where new transactions
enter the Bitcoin network and are processed into the database before being
deleted. So the mempool code base was changed to extract transaction data
and log it independently into entry and exit log files.

5.2.2 Processing of JSON Log files

All fields were logged with a timestamp as the entry time in entry files. While
exit files also logged the same information with a timestamp indicating the
transaction’s exit time and an additional field (reason) indicating the cause
for the transaction’s exit from the mempool. This data was continuously
logged and two files (entry and exit) were dumped into the destination folder
every 24 hours. We integrated the JSON log files entry and exit using the
code in the tool Python. This specific output file JSON would resemble the
mempool of the miner. After the log files were processed, we made further
mempool snapshots of the JSON file using the C language code at an interval
of 1 or 10 seconds.

5.2.3 Data Extraction through APIs

Python was used to collect data from APIs programmatically. Through which
we downloaded the raw minned blocks from the BTC.com explorer and also
extracted certain information about the blocks, such as their weight, fees, and
size. On average, 144 blocks are mined every day, and each block contains
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 44

6.25 bitcoins. 144 x 6.25 equals 900, which is the average daily number of
new bitcoins mined.

Figure 5.3: snapshot of a BTC.com Explorer presenting numbers of mined


blocks

BTC.com Additionally, Explorer provides us with information on the


mining pools and the time period during which the block was generated.

5.3 Simulations And Analysis

5.3.1 Dataset

The node is first synchronised, and two weeks’ worth of transactions are
logged. Because the Bitcoin protocol specifies that, by default, transactions
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 45

can survive in the Miner’s Mempool for two weeks. After two weeks, the
Node’s Mempool will resemble that of the Miner. And from BTC.com Ex-
plorer, genuine data on mined raw blocks has been collected. In fact, there
are two distinct types of data sets used in the analysis. The first dataset
spans the period from 13 May 2019 to 19 May 2019, while the second spans
the period from 04 December 2020 to 08 December 2020. Mempool snap-
shots are created using Unix timestamps. Using the C code, thousands of
sets of mempools were constructed. In this thesis, these mempools were used
as inputs for the greedy algorithm, greedy with advice, and Delta (sorting-
based method). These methods are executed using Python code on a 3.20
GHz Intel Core i7 with 16 GB RAM.

5.3.2 Experiments And Analysis

To analyse and compare bitcoin miners’ block packing approaches, distinct


blocks were recreated using three different algorithms: greedy, greedy with
advice, and Delta, with mempool snapshots as input. These recreated blocks
were compared to the original mined blocks downloaded from the BTC.com
Explorer.
The simulation findings assisted in analysing the changing behaviour of
mining pools when generating a block and their shift to different block pack-
ing techniques at specific times, either periodic or ad hoc. It demonstrates
that miners do not adhere to a single strategy, but rather move between them
according to their needs.
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 46

Figure 5.4: The number of blocks generated between 13 and 19 May 2019
by several mining pools utilising various techniques at various timestamps is
displayed.

Figure 5.5: The number of blocks generated between 04 and 08 Dec 2020
by several mining pools utilising various techniques at various timestamps is
displayed.

The two above graphs illustrate how mining pools deviate from block
packing strategies. I compared the block fees, block size, and weight of
the downloaded blocks from the BTC.com explorer to the block fees, block
size, and weight of the original downloaded blocks, and then anticipated the
strategies used by miners to generate those particular blocks. According to
both datasets, the F2pool created the most blocks. According to the findings
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 47

obtained by the dataset of 13-19 May 2019, BTC.com was in second place,
whereas Poolin remained in second place according to the results generated
by the dataset of 04-08 December 2020. It is still seen in both datasets
that Delta is the most common strategy among miners, greedy+advice is the
second most popular technique, and greedy appears to be less popular among
miners.Additionally, you’ll see that certain blocks are labelled ”Unknown,”
indicating that we were unable to anticipate the algorithm used to generate
them. Thus, it is established that there are additional procedures known
only to miners, and that they were utilised for the particular goal of mining
a block.

Figure 5.6: Between 13 May and 19 May 2019, a pie chart depicts the most
often utilised technique among miners and also indicates the presence of other
techniques.
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 48

Figure 5.7: The following line graph illustrates the various mining pools’
nonlinear behaviour.

As the pie chart indicates, miners use Delta at a rate of 76 percent. We


can conclude that Delta has won the race and has surpassed all other block
packing techniques.
While the following line graph demonstrates the nonlinear behaviour of
the various mining pools. As can be seen, each mining pool deviates from
the block packing technique at some point, but we need to understand why
the miners of different mining pools exhibit such unpredictable behaviour.
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 49

Figure 5.8: The power law relationship between timestamp count and al-
gorithm is illustrated in a graph from the dataset from 13 May to 19 May
2019.

Figure 5.9: The power law relationship between timestamp count and al-
gorithm is illustrated in a graph from the dataset from 04 December to 08
December 2020.

The above two bar graphs from different datasets forecast the algorithm’s
utilisation by miners as a power law function of the timestamp count. A
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 50

power law is a functional relationship between two quantities in which a


change in one quantity leads to a proportional change in the other, regardless
of their original sizes one quantity varies as the power of the other.

Figure 5.10: The scatter plot depicts the dataset from December 04, 2018 to
December 08, 2020. utilises two unique methods to demonstrate the interplay
between generated fees in blocks: Delta and Greedy+Advice.

The above scatter figure compares the fees earned when two algorithms,
Delta and Greedy+Advice, were used to generate blocks. Thus, Delta’s fees
are on the Y-axis, whereas Greedy+Advice’s fees are on the X-axis. Both
numerical numbers are independent of each other. On a scatter plot, the
data points or dots reflect the individual values of the fees generated by the
Delta and Greedy+Advice algorithms. Delta fee data points have higher
values than Greedy+Advice fee data points and are also substantially more
dispersed than Greedy+Advice fee data points. Both quantities appear to
have a nonlinear connection. It is concluded that utilising both algorithms
would not result in the same fees.
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 51

Figure 5.11: Line graph displaying the produced block fees using the Delta,
Greedy+Advice, and Greedy algorithms from 04 December to 08 December
2020.

The accompanying line graph, which uses the dataset from 04 December
to 08 December 2020, illustrates the trend of generated block fees utilising
three algorithms: Delta, Greedy+Advice, and Greedy during a nearly one-
week period. These are the blocks that have previously been mined by the
various mining pools depicted on the graph. I replicated the blocks at the
exact timestamp using the three procedures discussed previously. The trend
indicates that Delta is the superior algorithm over the other two. However,
as seen in the preceding graphs, miners do not commit to a single block
packing approach; rather, they constantly swap between them. Additionally,
it was found that while recreating the blocks, Delta takes longer than the
other two.
CHAPTER 5. SIMULATION RESULTS AND ANALYSIS 52

Figure 5.12: The graph depicts the difference in fees between Delta, Greedy,
and Greedy+Advice for all three algorithms from December 04 to December
08, 2020.

The stacked column above graph demonstrates the difference in fees be-
tween Delta, Greedy and Greedy+Advice all three algorithms over the time
period from 04 December to 08 December 2020. The orange component
shows the Delta part covering more than two parts.It also illustrates that in
almost all circumstances the value of the Greedy fee is almost zero, but not
quite null.Additionally, this finding indicates that Delta generates the largest
block fees, which can be beneficial for miners’ incentives.
Chapter 6

Conclusion and Future Work

This chapter finishes the thesis and summarises the research’s primary find-
ings. The first section of this chapter discusses the goals and objectives of
this investigation. The second section discusses more studies that could be
conducted in the future based on the findings of this thesis.

6.0.1 Conclusion

The Bitcoin blockchain’s long-term stability and security are highly depen-
dent on the incentive it provides to miners. With block subsidies gradually
reduced every four years, miners will increasingly rely on transaction fees as
their main source of incentive.This research demonstrates that miners do not
adhere to a single technique for block packing. They continually alter their
techniques when erecting a block.
To analyse the behaviour of several mining pools, we initially created two
distinct datasets from different time periods: one from 2019 and another
from 2020. Furthermore, separate blocks were reconstructed using three
distinct algorithms: greedy, greedy with advice, and Delta, all of which were
fed mempool snapshots. We compared these rebuilt blocks to the real mined

53
CHAPTER 6. CONCLUSION AND FUTURE WORK 54

blocks retrieved from the BTC.com Explorer. Thus, by observing block costs,
block size, and weight, it is possible to forecast the applied block packing
algorithm by different mining pools.Additionally, it was noticed that the
Delta algorithm produces the best block fees, despite the fact that its block
creation time is longer than the other two methods. So, it is critical to
conduct further research into the mining pools’ behaviour, as well as the
possibility of additional strategies, as our simulations were unable to forecast
them, and thus they are labelled as ”Unknown”. So it is important to discover
those unknown strategies too.

6.0.2 Future Directions in Research

Based on the findings of this research, it is obvious that little research has
been conducted on the behaviour of mining pools and their transaction se-
lection policies when producing blocks. Our research indicates that miners
do not just rely on the single block packing strategy and that they also have
other secret strategies that will be used in the future. We can gain a thorough
understanding of their transaction selection strategies by utilising machine
learning methods. Additionally, it is required to overcome the disadvantages
of the previously described algorithms that are commonly employed by min-
ing pools and provide a better solution, as research results indicate that the
Delta algorithm generates superior results but takes longer to create a block.
Bibliography

[1] 99Bitcoins, ”99bitcoins.com,” [Online]. https://99bitcoins.com/


bitcoin-mining/. Last accessed 08 March 2019.

[2] BitcoinWiki. [Online]. https://en.bitcoinwiki.org/wiki/Bitcoin_


history. Last accessed 17 April 2019.

[3] Blockchain.com. [online]. https://www.blockchain.com/.

[4] MasterinBitcoin, ”MateringBitcoin,”[Online]. https://


masteringbitcoin.neocities.org/. Last accessed 16 Septem-
ber 2019.

[5] MinerHome, ”Minerhome,[Online]” . http://www.minerhome.com/


cryptocurrency-fordummies-bitcoin-and-beyond/. Last accessed
16 March 2019.

[6] Wikipedia, ”Wikipedia,”[Online]. https://en.wikipedia.org/wiki/


SHA-2. Last accessed 14 March 2019.

[7] bitcoin.org, “bitcoin core v0.12 release notes,” [online].


https://bitcoin.org/en/release/v0.12.0, 2016. Last accessed August
2019.

55
BIBLIOGRAPHY 56

[8] bitcoinwiki, “bitcoin transaction fees” [online].


http://en.bitcoin.it/wiki/Transaction fees/, 2016. Last accessed
August 2019.

[9] “stratum mining protocol,” [online]. https://en.bitcoin.it/wiki/Stratum


mining protocol, 2017. Last accessed December 2019.

[10] 10+ best bitcoin mining pools (high btc, ethereum payouts).
https://www.guru99.com/mining-pools-bitcoin-ethereum.html, August
2021.

[11] ] S. K. E. a. C. L. Mauro Conti. ”a survey on security and privacy issues


of bitcoin”. 2013.

[12] Karl-Johan Alm. Mempool optimized fees, and the correlation be-
tween user costs, miner incentives, and block capacity. https://bc-
2.jp/mempool.pdf, Oct 2017.

[13] S. Ammous. Blockchain technology: What is it good for? Banking &


Insurance eJournal, 2016.

[14] Andreas M Antonopoulos. Mastering bitcoin. 2019.

[15] Joseph Bonneau. Bitcoin mining is np-hard. https://freedom-to-


tinker.com/2014/10/27/bitcoin-mining-is-np-hard/, August 2021.

[16] D. L. Chaum. Untraceable electronic mail, return addresses, and digital


pseudonyms. 24(2):84–90, 1981.

[17] Usman W Chohan. The double spending problem and cryptocurrencies.


Available at SSRN 3090174, 2017.
BIBLIOGRAPHY 57

[18] LUKE CONWAY. Investopedia, ”Investopedia.com,” . https://www.


investopedia.com/terms/b/blockchain.asp, June 2021.

[19] Chukwuocha C. Kamali S. Thulasiram R. K Dos Santos, S. An efficient


miner strategy for selecting cryptocurrency transactions. In 2019 IEEE
International Conference on Blockchain (Blockchain), pages 116–123.
IEEE, 2019.

[20] Saulo Dos Santos, Chukwuka Chukwuocha, Shahin Kamali, and


Ruppa K Thulasiram. An efficient miner strategy for selecting cryp-
tocurrency transactions. In 2019 IEEE International Conference on
Blockchain (Blockchain), pages 116–123. IEEE, 2019.

[21] Naor M. Dwork, C. Pricing via processing or combatting junk mail. In


In Annual international cryptology conference, pages 139–147. Springer,
Berlin, Heidelberg, 1992.

[22] Ittay Eyal and Emin Gün Sirer. Majority is not enough: Bitcoin mining
is vulnerable. In International conference on financial cryptography and
data security, pages 436–454. Springer, 2014.

[23] Beltran Fiz, Stefan Hommes, et al. Confirmation delay prediction of


transactions in the bitcoin network. In Advances in Computer Science
and Ubiquitous Computing, pages 534–539. Springer, 2017.

[24] Calvin Ho. Adaptation of all-programmable SoC to hardware Bitcoin


miners and mining servers. PhD thesis, California State University,
Northridge, 2013.

[25] MANSA J. Hong, E. How does bitcoin mining work? what is


crypto mining?investopedia. https://www.investopedia.com/tech/how-
does-bitcoin-mining-work/, April 2021.
BIBLIOGRAPHY 58

[26] Sunny King and Scott Nadal. Ppcoin: Peer-to-peer crypto-currency


with proof-of-stake. self-published paper, August, 19(1), 2012.

[27] Jon Matonis. The bitcoin mining arms race: Ghash. io and the 51%
issue. New York, NY, USA: CoinDesk, Tech. Rep, 2014.

[28] Gregory Maxwell. Coinjoin: Bitcoin privacy for the real world. bit-
cointalk. org.(august 2013). 2013.

[29] R. P. Naik. ”optimising the sha256 hashing algorithm for faster and
more efficient bitcoin mining”. 2017.

[30] S. Nakamoto. Bitcoin: A peer-to-peer electronic cash system bitcoin: A


peer-to-peer electronic cash system. 2009.

[31] J. B. E. F. Arvind Narayanan. ”bitcoin and cryptocurrency technologies,


princeton publications”.

[32] Karl J O’Dwyer and David Malone. Bitcoin mining and its energy
footprint. 2014.

[33] D. Pisinger. Where are the hard knapsack problems? 32:2271–2284.,


2005.

[34] Andrew Poelstra. On stake and consensus.


https://download.wpsoftware.net/bitcoin/pos.pdf, March 2015.

[35] Beltran Borja Fiz Pontiveros, Robert Norvill, and Radu State. Monitor-
ing the transaction selection policy of bitcoin mining pools. In NOMS
2018-2018 IEEE/IFIP Network Operations and Management Sympo-
sium, pages 1–6. IEEE, 2018.
BIBLIOGRAPHY 59

[36] Okke Schrijvers, Joseph Bonneau, Dan Boneh, and Tim Roughgarden.
Incentive compatibility of bitcoin mining pool reward functions. In In-
ternational Conference on Financial Cryptography and Data Security,
pages 477–498. Springer, 2016.

[37] Yonatan Sompolinsky and Aviv Zohar. Bitcoin’s underlying incentives.


Communications of the ACM, 61(3):46–53, 2018.

[38] Michael Bedford Taylor. Bitcoin and the age of bespoke silicon. In
2013 international conference on compilers, architecture and synthesis
for embedded systems (CASES), pages 1–10. IEEE, 2013.

[39] Paolo Toth. Dynamic programming algorithms for the zero-one knapsack
problem. Computing, 25(1):29–45, 1980.

[40] Natkamon Tovanich, Nicolas Soulié, Nicolas Heulot, and Petra Isenberg.
An empirical analysis of pool hopping behavior in the bitcoin blockchain.
In 2021 IEEE International Conference on Blockchain and Cryptocur-
rency, 2021.

[41] Florian Tschorsch and Björn Scheuermann. Bitcoin and beyond: A tech-
nical survey on decentralized digital currencies. IEEE Communications
Surveys & Tutorials, 18(3):2084–2123, 2016.

[42] J. Tuwiner. 9 best bitcoin mining pools: Legit sites (2021 com-
panies). 9 best bitcoin mining pools: Legit sites (2021 companies).
https://www.buybitcoinworldwide.com/mining/pools/, June 2021.

[43] Luqin Wang and Yong Liu. Exploring miner evolution in bitcoin net-
work. In International Conference on Passive and Active Network Mea-
surement, pages 290–302. Springer, 2015.
BIBLIOGRAPHY 60

[44] Canhui and Yang Qin Xiaowen Chu, Wang. Measurement and anal-
ysis of the bitcoin networks: A view from mining pools. In 2020 6th
International Conference on Big Data Computing and Communications
(BIGCOM), pages 180–188. IEEE, 2020.

You might also like