Skip to content

Commit

Permalink
[docs] update to explanation.md file
Browse files Browse the repository at this point in the history
  • Loading branch information
theghostmac committed Dec 21, 2023
1 parent 8275f9e commit c120cb4
Showing 1 changed file with 38 additions and 23 deletions.
61 changes: 38 additions & 23 deletions explanation.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Blockchain Engineering from first principles

This article is for people who already know what the blockchain is, and probably already build software
around it. It is inspired by my journey to relearn blockchain technology beyond the surface. While I do
this, I try to build a blockchain from scratch using the Go programming language.

# Introducing blockchain
## Introducing blockchain

Blockchain is a peer-to-peer, distributed ledger that is cryptographically secure, append-only, immutable,
and update-able only via consensus among peers.
## Definition of terms.
and update-able only via consensus among peers.\

## Definition of terms

1. Peer-to-peer means there is no central controller of the network, and all participants (called nodes)
talk to each other directly.
2. Distributed ledger means that the ledger is spread across the network among all peers in the network,
Expand All @@ -20,19 +24,22 @@ on the blockchain.

From the following fundamental definition of blockchain, it is obvious that a blockchain
engineer must be versed in:
1. distributed systems - I recommend Distributed Systems for Practitioners book
2. writing immutable code,
3. cryptography - I recommend Cryptographic Algorithms
4. mathematics, and

1. distributed systems - I recommend Distributed Systems for Practitioners book.
2. writing immutable code.
3. cryptography - I recommend Cryptographic Algorithms
4. mathematics, and
5. computer networking.

In addition to all of these recommendations, you can add Wikipedia, and any other resources you find.
It's helpful to listen to experts talk, so videos might be good too.

# Blockchain Architecture
## Blockchain Architecture

Blockchain is a network with different layers. It is similar to HTTP, FTP, etc., which
runs on the TCP/IP model. Just as the TCP/IP networking model has 4 layers, the blockchain networking model
has 6 layers:

- Application:
- Smart contracts
- Decentralized applications
Expand All @@ -58,16 +65,18 @@ has 6 layers:
- The internet
- TCP/IP

From the list, it is obvious that the Network layer is the lowest layer. So in building a
From the list, it is obvious that the Network layer is the lowest layer. So in building a
blockchain from scratch, it is best to start from the Network layer.

## The Network layer
### The Network layer

Blockchain nodes communicate using remote procedure calls.

Network connections are also built on top of hardware that will also fail at some
Network connections are also built on top of hardware that will also fail at some
point and we should design our systems accordingly.

### Basics and Mechanics of the Network layer
#### Basics and Mechanics of the Network layer

The mechanics of the blockchain can be broken down into the following:

1. **Node Communication**: In a blockchain, nodes communicate via a peer-to-peer network protocol. While it's not exactly like a normal web server, you can think of it as a distributed network where nodes share information directly.
Expand All @@ -84,11 +93,15 @@ The mechanics of the blockchain can be broken down into the following:

7. **Data Propagation**: Nodes in a blockchain network communicate to propagate new transactions and blocks. This is done through a consensus protocol, ensuring that all nodes eventually agree on the state of the blockchain.

## The Execution layer
### The Execution layer

I particularly started the execution layer in order to have considerably real-world payload to feed the nodes for their communication. To
understand the execution layer, you must first understand the generic elements of a blockchain:
### Generic elements of a blockchain

#### Generic elements of a blockchain

The generic elements of a blockchain include the following:

1. The address
2. Transactions
3. Blocks
Expand All @@ -97,13 +110,15 @@ The generic elements of a blockchain include the following:
I have already done the implementation of this in this article.

Let's walk through them in a high level fashion:

1. The Block header - which has the following parts:
- Previous block header's hash (except the genesis block)
- Nonce (the contract wallet and the external/user wallet have different nonces)
- Timestamp (the time of the transaction)
- Height
- Merkle root (a bit complex, but we will look at them later).
2. Block body - which has the following part:
- Transactions.

Headers are important for saving state.

- Previous block header's hash (except the genesis block)
- Nonce (the contract wallet and the external/user wallet have different nonces)
- Timestamp (the time of the transaction)
- Height
- Merkle root (a bit complex, but we will look at them later).

2. Block body - which has the following part: Transactions.

Headers are important for saving state.

0 comments on commit c120cb4

Please sign in to comment.