Mining and Proof of Work

Mining and Proof of work (PoW)

Mining

  • 3 key points about mining:
  1. mining is a process of creating a new block of transactions to be added to a proof of work blockchain.

    • could also be defined as just extending a PoW chain with a new block.
  2. peers in the mining process are called miners.

  • 2 questions for who are miners?:

    1. who are the miners according to the network?
  • Answer 1: To the network : miner is just a node that contains miner software processes.
    miners in network
    miner software processes

    1. who are miners according to other humans?
      Answer 2: it just a human that setup the hardware that runs the miner software.
  1. Mining is just an automated software that people run.
  • there is no human element to mining except the setup and hardware maintenance

  • Mining as whole has 2 main functions:

  1. Enforcement of consensus rules(EXTREMELY IMPORTANT):
    • no double spending, block size, validate all transactions
    • Consensus rules are what guide decentralized systems come to agreement on the state of blockchain.
    • bool CheckBlock function from bitcoin that checks the block to be added to bitcoin blockchain and verifies that block adheres to the consensus rules.
  2. Currency issuance(not as important):
    • to incentivize miners they get a part of network's currency issuance/ a part of network's inflation
    • it is a consequence of first one (Enforcement of consensus rules)

Proof of work

So, how does a miner get rewards for their efforts?

  • Answer: Proof of work : i.e miner has to provide some sort of proof of work they provide to the network that proves they did a valid work.

  • PoW is a Consensus Mechanism

    1. Consensus Mechanism is how decentralized networks like bitcoin and ethereum decide what blocks/transactions are considered valid? and who gets to add new block to the blockchain?
    2. proof of work and proof of state are two different types of consensus mechanisms.
    3. In PoW for a miner to receive a reward, they must present some type of proof that indicates they have spent significant resources securing the network.
  • Proof of work is a solution to the mining process How?

PoW in mining Algorithm

  • Question: when a miner mines a block what is the miner actually doing?
  • Answer: Mining software repeatedly hashes a block of data(containing transactions) until a hash is found that meets a target difficulty.

PoW using pseudocode

  • step 1. take current block header
  • step 2. append a nonce, starting at nonce = 0
  • step 3: hash data from step 1 and step 2
  • step 4: check the hash output versus target(provided by protocol)
  • step 5: if hash < target, puzzle is solved (get rewarded)
  • step 6: else, restart the process from step 2 but increment the nonce

here is what a dummy data to be hashed might look like:

1
2
3
4
5
6
7
8
9
{
"prevBlock": "000000000000000000000000asdf2l2kj2iewou23kedkofbp32",
"new transactions": [
// ...,
"alice sends bob 4 BTC",
"benny gets 100 BTC"
],
"nonce": 0
}
  • what mining software will do is literally take prev block header, some transactions and nonce, hash all together to get an output that meets target difficulty set by network/protocol.

  • So, bitcoin has impressive target difficulty. it has 19 zeros to at a moment. So, miner in bitcoin, his goal is to find a hash with 19 leading zeros, with valid inputs used ofc, and that’s gonna be lower than the target difficulty issued by protocol. so, what happens if other miner finds the hash before you? So, that just means, you will update the prev block header with the new one then continue to hash till you win it.

Proof of Work + Mining: TLDR

  • PoW is consensus mechanism meant to provide decentralized networks like bitcoin and eth a way to come to consensus on what is actually valid.

    • solves Byzantine Generals’ Problem.
  • Mining is a function of proof of work process meant to secure a network against fraud.

    • Miner race to find a valid proof of work in-order to get compensated.

How does PoW solves Byzantine Generals’ Problem.

The Byzantine Generals’ Problem is a conceptual problem in computer science that deals with how a group of generals, each commanding a portion of an army, can come to a consensus on a coordinated attack or retreat.`` The challenge arises when some of the generals are potentially traitors who might send conflicting messages, leading to a breakdown in trust and consensus.

In the context of blockchain, the Byzantine Generals’ Problem is relevant because blockchain networks rely on decentralized consensus, where participants (like the generals) need to agree on the validity of transactions and the order in which they are added to the blockchain.

Proof of Work (PoW) helps address the Byzantine Generals' Problem in the following way:

  • Solving the Consensus Challenge: In a blockchain network, PoW serves as a mechanism for achieving consensus among participants. Miners, who are essentially competing generals in this analogy, solve complex mathematical puzzles (perform computational work) to validate and add new blocks to the blockchain. The solution is verified by other participants, and once a consensus is reached that the solution is correct, the block is added to the chain.

  • Resisting Byzantine Faults: Byzantine faults refer to the possibility of malicious actors (like the traitorous generals) attempting to disrupt the consensus process by providing conflicting or fraudulent information. The computational work required by PoW makes it difficult for any single participant to manipulate the consensus. In order to successfully alter the blockchain’s history, an attacker would need to control the majority of the network’s computational power, which is typically infeasible and economically impractical.

  • Incentivizing Honest Behavior: The concept of incentives is crucial in PoW. Miners who successfully validate and add new blocks to the blockchain are rewarded with cryptocurrency tokens or transaction fees. This incentivizes participants to act honestly and invest their computational resources to secure the network. By doing so, they contribute to the consensus process and make it economically unattractive for malicious actors to attempt attacks.

In summary, PoW helps solve the Byzantine Generals’ Problem in blockchain by providing a decentralized consensus mechanism that relies on computational work and economic incentives. It makes it difficult for malicious actors to manipulate the system, promotes trust among participants, and ensures the integrity and security of the blockchain network.

from alchemy notes

  • In a decentralized environment, common issues are:

  • How do all nodes agree on what the current and future state of user account balances and contract interactions is?

  • Who gets to add new blocks/transactions to a chain? How do we know any blocks added are “valid”?

  • How the heck are all of these things coordinated without any central actor in place?

The answer is consensus mechanism

Consensus Mechanisms

  • Blockchain consensus typically means at least 51% of nodes are in agreement over the current global state of the network

The main consensus rules for proof-of-work typically look like religious commandments:

  1. you cannot double spend money
  2. The "longest" chain will be the one the rest of the nodes accept as the one "true" chain, determined by a chain’s cumulative work. Also known as Nakamoto Consensus.
  • Bitcoin being a blockchain network, use a consensus mechanism called proof-of-work. Ethereum was previously using proof of work but has since moved to proof-of-stake

Proof of Work

  • In proof-of-work, mining is the "work" itself

  • The consensus mechanism ends up providing security to a blockchain network just because it demands that everyone follow the consensus rules if they want to participate! You might end up asking how does Poof of Work result in security of blockchain?

    • So, the security of blockchain is directly related to the length of the chain. i.e the longer the chain gets the secure it becomes. So, when you do mining in PoW, you are indirectly contributing to the security of blockchain by adding a new block of transactions to the chain, making it longer. So, how do you prevent anyone from adding a new block in PoW? Well, to add a new block you need to get a hash of previous block hash, new transactions, nounce then your output hash should meet the target difficulty set by the network. So, you cannot just get this value without spending significant computational resource. And by spending that computational resource and getting the new block hash for the new block, you’re providing the proof that you have spent sometime to get the required hash(based on target difficulty) , and adding a new block. indirectly securing the blockchain network by extending the chain.
  • "Mining" can be considered an industry misnomer. The term gained popularity as it has a close tie in to gold mining, where miners expend energy and resources in the pursuit of valuable rewards.

  • In proof-of-work, miners must present a proof (in the form of a hash output on valid input data) that they expended energy in order to successfully “mine” a block and have it extend a blockchain.

Excercise

Proof of Work Miner

  • We’re going to build a basic proof of work miner!

  • This miner will receive transactions from the network and add them to its mempool.

  • A mempool (a contraction of memory and pool) is a cryptocurrency node’s mechanism for storing information on unconfirmed transactions. It acts as a sort of waiting room for transactions that have not yet been included in a block.

  • When a block is ready to be mined, the miner will take those transactions from the mempool and include them into the mined block.

  • The miner will also calculate a basic proof of work below a constant TARGET_DIFFICULTY.

Task - 1 The Mempool

  • Users who want to make transactions will broadcast their transactions to the blockchain network. The mempool is a place for miners to keep those transactions before adding them to a block.

  • Typically, the miner will take all the transactions with the highest transaction fees from the mempool. Then they'll add them to the block and attempt to find the proof of work.

  • 🏁 Your Goal: Add Transaction

  • Your goal is to implement the addTransaction function, which adds transactions to the mempool.

  • Take the transaction sent to the function and push it on top of the mempool array.

Answer for Task - 1 The Mempool:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// index.js
const SHA256 = require('crypto-js/sha256');
const TARGET_DIFFICULTY =
BigInt(0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
const MAX_TRANSACTIONS = 10;

const mempool = [];
const blocks = [];

function addTransaction(transaction) {
// TODO: add transaction to mempool
mempool.push(transaction);
}

function mine() {
// TODO: mine a block
}

module.exports = {
TARGET_DIFFICULTY,
MAX_TRANSACTIONS,
addTransaction,
mine,
blocks,
mempool,
};
  • Test to run against:
1
2
3
4
5
6
7
8
9
10
11
const { assert } = require('chai');
const { addTransaction, mempool } = require('../index');

describe('addTransaction', () => {
it('should add the transaction to the mempool', () => {
const transaction = { to: 'bob', sender: 'alice' };
addTransaction(transaction);
assert.equal(mempool.length, 1);
assert.equal(mempool[0], transaction);
});
});

Task - 2 Mine Block

  • Mining Blocks

  • In Bitcoin, blocks contain quite a bit of information in their header: the software version, a timestamp, the merkle root of its transactions, the previous block hash, and the difficulty.

  • You might ask what is Merkle root?

    • it is cryptographic hash that represents all the transactions included in that particular block. it is calculated by recursively hashing pairs of transaction hashes until a single hash remains, which becomes the Merkle root. The Merkle root is included in the block header and serves as a reference point for verifying the integrity of the transactions within the block
  • 🏁 Your Goal: Mine Block
    The goal of this stage is to update the mine() fuction to create a new block with a unique identifier and add it to our blocks array.

  • For the purposes of this mining exercise, our block will be an object with a single property: an id that is equal to the block height prior to it being mined.

  • Update the mine() function to create a new block object with a single property: id
    Set the id property to the block height prior to the new block being added
    Push the block object into the blocks array

Answer to Task 2 - Mine Block

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const SHA256 = require('crypto-js/sha256');
const TARGET_DIFFICULTY =
BigInt(0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
const MAX_TRANSACTIONS = 10;

const mempool = [];
const blocks = [];

function addTransaction(transaction) {
// TODO: add transaction to mempool
mempool.push(transaction);
}

function mine() {
// TODO: mine a block
console.log(blocks);

const block = { id: blocks.length };

blocks.push(block);
return blocks;
}

module.exports = {
TARGET_DIFFICULTY,
MAX_TRANSACTIONS,
addTransaction,
mine,
blocks,
mempool,
};

Test to run against:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { assert } = require('chai');
const { mine, blocks } = require('../index');
const SHA256 = require('crypto-js/sha256');

describe('mine', () => {
describe('first block', () => {
let hash;
before(() => {
hash = mine();
});
it('should add to the blocks', () => {
assert.equal(blocks.length, 1);
});
it('should store the expected id', () => {
const lastBlock = blocks[blocks.length - 1];
assert(
lastBlock.id != null,
'did not find an id property on the block'
);
assert.equal(lastBlock.id, 0);
});
});
describe('second block', () => {
let hash;
before(() => {
hash = mine();
});
it('should add to the blocks', () => {
assert.equal(blocks.length, 2);
});
it('should store the expected id', () => {
const lastBlock = blocks[blocks.length - 1];
assert(
lastBlock.id != null,
'did not find an id property on the block'
);
assert.equal(lastBlock.id, 1);
});
});
});

Task - 3: Block Hash

Block Hash

  • Typically, all the information in the header of the block is hashed together to create a unique hash based on those properties.

  • If anything changes in the header, it will affect the hash. Since each block also contains the hash of the block before it, it will affect every future block as well.

🏁 Your Goal: Add the Hash

  • Stringify the block object using JSON.stringify
  • Take the SHA256 hash of the stringified block object
  • Set the resulting value to a hash property on the mined block just before mining it
    ⚠️ Do not add the hash property on the block until after calculating the hash!

Answer for Task -3 Block Hash:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const SHA256 = require('crypto-js/sha256');
const TARGET_DIFFICULTY =
BigInt(0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
const MAX_TRANSACTIONS = 10;

const mempool = [];
const blocks = [];

function addTransaction(transaction) {
// TODO: add transaction to mempool
mempool.push(transaction);
}

function mine() {
// TODO: mine a block

const block = { id: blocks.length };
// strigifiy the block object
const stringifiedBlock = JSON.stringify(block);
// hash the stringfied object
const hash = SHA256(stringifiedBlock);
// add hash properyty to block, just before mining
block.hash = hash;
// mine block
blocks.push(block);
return blocks;
}

module.exports = {
TARGET_DIFFICULTY,
MAX_TRANSACTIONS,
addTransaction,
mine,
blocks,
mempool,
};

Tests to run against:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { assert } = require('chai');
const { mine, blocks } = require('../index');
const SHA256 = require('crypto-js/sha256');

describe('mine', () => {
describe('first block', () => {
let hash;
before(() => {
hash = mine();
});
it('should add to the blocks', () => {
assert.equal(blocks.length, 1);
});
it('should return the expected hash', () => {
const expectedHash = SHA256(JSON.stringify({ id: 0 }));
const lastBlock = blocks[blocks.length - 1];
assert(lastBlock.hash, 'did not find a hash property on the block');
assert.equal(lastBlock.hash.toString(), expectedHash.toString());
});
});
describe('second block', () => {
let hash;
before(() => {
hash = mine();
});
it('should add to the blocks', () => {
assert.equal(blocks.length, 2);
});
it('should return the expected hash', () => {
const expectedHash = SHA256(JSON.stringify({ id: 1 }));
const lastBlock = blocks[blocks.length - 1];
assert(lastBlock.hash, 'did not find a hash property on the block');
assert.equal(lastBlock.hash.toString(), expectedHash.toString());
});
});
});

Task 4 - Mine Tx

Block Size

  • In Bitcoin, there is a specific block size limit that cannot be exceeded. The number of transactions that will fit inside of a block varies due to transactions being of all different sizes.

For the purposes of this exercise, we will use the MAX_TRANSACTIONS constant.

📖 Deciding the block size in bitcoin has been quite controversial!

  • you might as how block size is controversial, so here is the reason.

  • The block size in bitcoin refers to max amount of data that can be included in a block of transactions. Deciding its size has been controversial because it affects the speed and cost of transaction on the bitcoin network.

  • One group argues, by increasing block size we can process more transactions at once. This improves network’s capacity and reduce congestion.

  • However, larger blocks require more computational resources to process, potentially leading to centralization as only larger and more powerful nodes can handle the increased demands.

  • On the other hand, some argue to keep block size small resulting more decentralization and ensure more people can participate in the network by running nodes on regular computer. They believe that larger blocks could lead to higher fees for users and make it harder for smaller player to participate in teh network.

  • You might also ask, wait are all transactions equal in size? I mean is it always the number of transactions that's gonna affect the transactions to be included in the block?

    • Each trnascation in bitcoin network has certain size, which is determined by the number of inputs and outputs, as well as other data associated with the transaction.

    • So, Transaction Size come into play here too. because not every transaction has the same size. i.e the larger one transaction is, more space it takes in block causing less number of transactions to included in the block than the block size.

    • To optimize the usage of block space, transaction fees play a role. Miners prioritize transaction with higher fees because they incentivize miners to include them in the the limited block space available. This fee market mechanism helps balance the demand for block space with the available capacity.

Your Goal: Mine Transactions

  • Inside the mine function, pull transactions off the mempool and include them in the block in an array called transactions
  • Remove each transaction you include in the block from the mempool
  • Add the transactions array to the block before hashing the block
  • ⚠️ Do not include more transactions in the block than the MAX_TRANSACTIONS limit.

Answer for Task-4 Mine Transactions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// index.js
const SHA256 = require('crypto-js/sha256');
const TARGET_DIFFICULTY =
BigInt(0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
const MAX_TRANSACTIONS = 10;

const mempool = [];
const blocks = [];

function addTransaction(transaction) {
// TODO: add transaction to mempool
mempool.push(transaction);
}

function mine() {
// TODO: mine a block

const block = { id: blocks.length };

const transactionsToBeIncludedInBlock = [];
// take transactions from mempool that meet max_transaction in block (in our case a block can contain 10 transactions)
// also need to handle if mempool has already less transactions to than the max_transactions to be included into block
while (
mempool.length &&
transactionsToBeIncludedInBlock.length < MAX_TRANSACTIONS
) {
transactionsToBeIncludedInBlock.push(mempool[mempool.length - 1]);
mempool.pop();
}
// add transactions property to block before hash
block.transactions = transactionsToBeIncludedInBlock;

// strigifiy the block object
const stringifiedBlock = JSON.stringify(block);
// hash the stringfied object
const hash = SHA256(stringifiedBlock);
// add hash properyty to block, just before mining
block.hash = hash;

// take transaction of memempool

// mine block
blocks.push(block);
return blocks;
}

module.exports = {
TARGET_DIFFICULTY,
MAX_TRANSACTIONS,
addTransaction,
mine,
blocks,
mempool,
};
  • tests to run against:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const { assert } = require('chai');
const { mine, blocks, mempool, addTransaction } = require('../index');
const SHA256 = require('crypto-js/sha256');

describe('mine', () => {
describe('with 5 mempool transactions', () => {
before(() => {
for (let i = 0; i < 5; i++) {
addTransaction({ sender: 'bob', to: 'alice' });
}
});
describe('after mining', () => {
before(() => {
mine();
});
it('should add to the blocks', () => {
assert.equal(blocks.length, 1);
});
it('should store the transactions on the block', () => {
assert.equal(blocks[blocks.length - 1].transactions.length, 5);
});
it('should clear the mempool', () => {
assert.equal(mempool.length, 0);
});
});
});
describe('with 15 mempool transactions', () => {
before(() => {
for (let i = 0; i < 15; i++) {
addTransaction({ sender: 'bob', to: 'alice' });
}
});
describe('after mining', () => {
before(() => {
mine();
});
it('should add to the blocks', () => {
assert.equal(blocks.length, 2);
});
it('should store the transactions on the block', () => {
assert.equal(blocks[blocks.length - 1].transactions.length, 10);
});
it('should reduce the mempool to 5', () => {
assert.equal(mempool.length, 5);
});
describe('after mining again', () => {
before(() => {
mine();
});
it('should add to the blocks', () => {
assert.equal(blocks.length, 3);
});
it('should store the transactions on the block', () => {
assert.equal(
blocks[blocks.length - 1].transactions.length,
5
);
});
it('should clear the mempool', () => {
assert.equal(mempool.length, 0);
});
});
});
});
});

Task - 5 Target Difficulty

  • In bitcoin, the difficulty is adjusted every 2016 blocks, which is about every two weeks with the blocks being mined on average every 10 minutes.

  • At that point, the difficulty is adjusted to attempt to keep the mining intervals around that 10 minute per block mark.

  • Remember, you got confused by 'you have a correct proof of work if you get a value that is less than TARGET_DIFFICULTY'.

    • im gonna tell you how is this related. For example, bitcoin has target difficulty with 19 zeros. So, your goal is to find a hash that has 19 zeros and less than the value set by TARGET_DIFFICULTY.
    • say TARGET_DIFFICULTY was 00000000000000002 so, you need to find a hash that is 00000000000000001 or 00000000000000000. This is the value that is lesser than the TARGET_DIFFICULTY.
    • and the only variable in this case will be the nounce you will start from 0 and go on to meet the demand.

🏁 Your Goal: Proof of Work

  • Now it’s time to actually mine the block. This is where we get the work part of proof of work!

  • In the mine function, prior to hashing the block, add a nonce property. This property should start at 0

  • Keep changing the nonce until you find a hash that is less than the TARGET_DIFFICULTY

  • You can compare a BigInt to another BigInt using the JavaScript comparison operators. You can convert from a hash to be a BigInt by:

    1
    2
    const hash = SHA256('example');
    const int = BigInt(`0x${hash}`);

Hashing and Proof of Work

  • Proof of Work is another component of Bitcoin that is essential to its success.

  • Let’s examine its origins and how it is accomplished before we dive into how it works for Bitcoin. 🧐

  • The term "Proof of Work" is used to describe the solution to a computationally expensive challenge for computers. For instance, we could program a computer to search for a hash starting with three 5's. That might take some time guessing:

    1
    2
    3
    4
    5
    sha256('0'); // 5feceb…
    sha256('1'); // 6b86b2…
    sha256('2'); // d4735e…
    // keep on guessing, keep on guessing…
    sha256('5118'); // 555850…
  • Phew, took us a few guesses! 😅

  • The difficulty to come up with this input gets exponentially harder the more 5s we require the output hash to start with. This is how it’s possible to control difficulty of Proof-Of-Work.

  • 🧐 Technically Bitcoin controls this on a finer level by specifying a target hash that the new block must be equal or lower to.

Why would you use Proof of Work?

  • One of the first use cases of Proof of Work was to prevent spamming. The idea is you can make each action a little bit difficult. If you want to send an email to your grandmother, maybe you need to come up with a hash that starts with three 5s. If a spammer wants to send an email to a million grandmas, they need to come up with a million hashes with three 5s. It becomes computationally expensive for them to do this kind of spamming.

  • 👵 Proof-Of-Work saving one Grandma at a time!

  • Now you might be wondering: Could the spammer just use the same hash for all 1 million emails?

  • Yes, certainly! Well, that is, unless we build requirements to make each hash unique. For instance, we could require that the hash input include the “to” address and contents in order to send the email. If I wanted to send my Grandma a message “Hi Grandma!”, I’d need to find a hash with my grandmas email address and the contents of the email plus some value to satisfy the hash:

    1
    2
    3
    4
    5
    sha256('Hi Grandma! coolgrandma555@hotmail.com 0'); // f2d9e2…
    sha256('Hi Grandma! coolgrandma555@hotmail.com 1'); // 4ee36e…
    sha256('Hi Grandma! coolgrandma555@hotmail.com 2'); // c25e5c…
    // keep on guessing, keep on guessing…
    sha256('Hi Grandma! coolgrandma555@hotmail.com 424'); // 5552ab…
  • ☝️ Found it! This didn’t take my computer very long. We can manage the difficulty by changing the number of 5s to make it take a minute on my machine. This way it takes a spammer 1 million minutes (or 11.5 days!) to do it on a machine with similar capabilities. As a user, I barely notice the difference, yet it’s much more troublesome for the spammer! 😁

  • 📖 The number that we're appending on the end of the message here is generally referred to as a nonce. We'll see how both Ethereum and Bitcoin make use of nonces in a few ways!

How does Bitcoin use Proof of Work?

  • You can think of Proof of Work as the security of the Bitcoin system. Thousands of nodes are working to find hashes of data in the Bitcoin network at any given time. These machines are financially incentivized through rewards when they find the hash. This process is known as mining. ⛏️

  • In order to overpower this network and force your own version of the truth, you would need to come up with more computing power than all the nodes in the entire system. This is referred to as a 51% attack because you need to have 51% of the total hashing power in the network. Even accomplishing this you are extremely limited in what you can actually accomplish.

  • ☝️ Understanding this part has quite a bit to do with the underlying data structure of the blockchain itself! We’ll go this in further detail later.

Supplemental Resources on Proof of Work

History

  • Adam Beck created the concept of HashCash as a way to combat email spamming. He presented this idea to the cypherpunk mailing list where several ideas were conceived afterwards:

  • Hal Finney invented Reusable Proofs of Work using the HashCash concept.

  • Wei Dai invented B-Money also using the HashCash concept.

Bitcoin Mining

  • Bitcoin uses Mining & Proof of Work to create a decentralized clearing house. Transactions are added to each mined block. Blocks are, on average, mined every 10 minutes. This, of course, varies due to the randomness of finding a valid hash.

  • The Target is adjusted so that, as more machines enter the network and the hash power increases, the difficulty of finding a new block increases (and vice-versa). This allows bitcoin to scale to its network size.

Mining Pools

  • There are many different types of Mining Pools in Bitcoin. As a user who wants to mine Bitcoin, you may join a mining pool so you get plenty of consistent, small rewards rather than one random large prize by finding the block (which, depending on your hash power, may not happen for a long time!).

  • 💰 The current bitcoin coinbase reward is 6.25, which is roughly $30,595.60 USD at the time of writing.

For a good comparison of the mining pools see this document.

B-money

  • B-money was a proposed digital currency system introduced by Wei Dai in 1998. It aimed to create a decentralized digital currency that would enable secure and anonymous transactions without the need for a central authority.

  • In simple terms, B-money envisioned a system where individuals could create digital tokens, known as “coins,” that could be transferred electronically. These coins would have unique digital signatures to prevent double-spending and ensure their authenticity. The B-money system would rely on a network of participants who validate and record transactions, similar to how miners validate transactions in Bitcoin.

  • Satoshi Nakamoto, the creator of Bitcoin, drew inspiration from Wei Dai's B-money concept and incorporated some of its ideas into the design of Bitcoin. While not a direct implementation, Bitcoin shares similarities with B-money's vision of a decentralized digital currency.

  • For example, both B-money and Bitcoin sought to eliminate the need for a central authority by relying on a network of participants to validate and secure transactions. They also emphasized the use of digital signatures to ensure the integrity of transactions. Satoshi Nakamoto’s Bitcoin whitepaper, published in 2008, introduced the concept of a blockchain, which is a distributed ledger that records all Bitcoin transactions.

  • Although Bitcoin expanded upon and refined these ideas, it’s important to note that Bitcoin’s design incorporates various additional features and innovations, making it a unique and influential cryptocurrency in its own right.

Reusable Proofs of Work

  • “Reusable Proofs of Work” (RPoW) is a concept that aims to enable the reuse of computational work done in one context for another purpose. In the context of cryptocurrencies like Bitcoin, it refers to the idea of using the work done to solve one cryptographic puzzle (proof of work) to potentially solve other puzzles as well.

  • In simple terms, think of it as completing a task that requires a certain amount of effort or computation. With reusable proofs of work, instead of discarding the result of that computation after it's done, it can be reused for other purposes.

  • For example, in Bitcoin, the mining process involves solving complex mathematical problems to secure the network and validate transactions. Reusable proofs of work suggest that once a miner has solved a particular puzzle, the solution can be utilized for other tasks beyond securing the network, thereby making the computational effort more versatile.

  • The concept of reusable proofs of work has been explored to potentially reduce energy consumption and improve efficiency by allowing the output of one computational task to be reused in another, rather than starting from scratch each time. However, it’s important to note that this concept is still in the research and experimental phase, and its practical implementation and implications are still being explored.