Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add P10 Forks notes #44

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This course focuses on the fundamental concepts and implementation principles of
7. **Mining Difficulty**
8. **Mining**
9. **[Scripting](./src/BTC/scripting.md)**
10. **Forks**
10. **[Forks](./src/BTC/forks.md)**
11. **[Q&A](./src/BTC/Q&A.md)**
12. **Anonymity**
13. **Reflections on Bitcoin**
Expand Down
16 changes: 16 additions & 0 deletions src/BTC/forks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# P10 Forks

**Fork**: Originally there was one chain, but now it is divided into two chains. This is called a fork.

The possible reasons for the fork are:

- **State Fork**: A fork is caused by a disagreement about the current state of the Bitcoin blockchain. For example, if two nodes mine at about the same time, both nodes can publish blocks, and a temporary fork will occur.
- **Forking Attack**/**Deliberate Fork**: A forking attack is also a state fork, except that the disagreement in the fork attack is intentionally caused by humans.
- **Protocol Fork**: A fork is caused by a change in the Bitcoin protocol. To modify the Bitcoin protocol, a software upgrade is required. In a decentralized system, there is no way to ensure that all nodes upgrade the software at the same time. We assume that most nodes have upgraded their software, but a few nodes have not upgraded their software for various reasons, and a fork will occur at this time. According to the different contents of the protocol change, it can be divided into:
- **Hard Fork**: Hard fork is usually extensions of consensus rules. Hard fork is usually permanent and may create two parallel chains. For example, [BCH](https://bch.info) was created as a result of a hard fork.
- **Soft Fork**: Soft fork is usually tighten of consensus rules. Soft fork is usually temporary.

Let’s use the change in Bitcoin’s block size limit to understand hard forks and soft forks:

- Suppose we increase the block size limit of Bitcoin from 1M to 4M, and assume that most new nodes have upgraded their software, and a few old nodes have not upgraded their software. The new nodes will generate 4M blocks, and the old nodes will generate 1M blocks. The new nodes recognize the blocks generated by the old nodes, and the old nodes do not recognize the blocks generated by the new nodes. Since the new nodes account for the majority, two parallel chains will eventually be formed.
- Suppose we reduce the block size limit of Bitcoin from 1M to 0.5M, and assume that most new nodes have upgraded their software, and a few old nodes have not upgraded their software. The new nodes will generate 0.5M blocks, and the old nodes will generate 1M blocks. The new nodes do not recognize the blocks generated by the old nodes, and the old nodes recognize the blocks generated by the new nodes. Since the new nodes account for the majority, a chain will eventually be formed.