diff --git a/src/SUMMARY.md b/src/SUMMARY.md index c1445b1..74c7b64 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -63,6 +63,7 @@ - [Hello Solana](solana/hello-solana.md) - [Fetch balance](solana/fetch-balance.md) - [NFT Memberships](solana/nft-memberships.md) + - [Consensus](solana/consensus.md) - [ML](ml/mod.md) - [Large Language Model](ml/large-language-model.md) - [Inferences](ml/infer/mod.md) diff --git a/src/solana/asset/hash-event.png b/src/solana/asset/hash-event.png new file mode 100644 index 0000000..40cab3c Binary files /dev/null and b/src/solana/asset/hash-event.png differ diff --git a/src/solana/asset/net-design.png b/src/solana/asset/net-design.png new file mode 100644 index 0000000..58ba4ed Binary files /dev/null and b/src/solana/asset/net-design.png differ diff --git a/src/solana/asset/poh-hashing.png b/src/solana/asset/poh-hashing.png new file mode 100644 index 0000000..d481bdf Binary files /dev/null and b/src/solana/asset/poh-hashing.png differ diff --git a/src/solana/asset/poh-input.png b/src/solana/asset/poh-input.png new file mode 100644 index 0000000..2fb0e4a Binary files /dev/null and b/src/solana/asset/poh-input.png differ diff --git a/src/solana/asset/poh-tx.png b/src/solana/asset/poh-tx.png new file mode 100644 index 0000000..7eb7e70 Binary files /dev/null and b/src/solana/asset/poh-tx.png differ diff --git a/src/solana/asset/tx-flow.png b/src/solana/asset/tx-flow.png new file mode 100644 index 0000000..bd78d3a Binary files /dev/null and b/src/solana/asset/tx-flow.png differ diff --git a/src/solana/asset/tx-pipeline.png b/src/solana/asset/tx-pipeline.png new file mode 100644 index 0000000..0e83624 Binary files /dev/null and b/src/solana/asset/tx-pipeline.png differ diff --git a/src/solana/asset/verification.png b/src/solana/asset/verification.png new file mode 100644 index 0000000..cf1025a Binary files /dev/null and b/src/solana/asset/verification.png differ diff --git a/src/solana/asset/verify-diagram.png b/src/solana/asset/verify-diagram.png new file mode 100644 index 0000000..bc289d1 Binary files /dev/null and b/src/solana/asset/verify-diagram.png differ diff --git a/src/solana/consensus.md b/src/solana/consensus.md new file mode 100644 index 0000000..d4e7074 --- /dev/null +++ b/src/solana/consensus.md @@ -0,0 +1,97 @@ +# Consensus +Solana combine two consensus algorithms PoS and enhance with PoH +> 🚧 Main focus on Proof of History (PoH) + +> 🚧 Listen Approach to Scalability to understand what solana achieve [here](https://www.youtube.com/watch?v=50yhHe_NQ0g&t) + +## PoH (Proof of history) +> 🚧 Key point: ***Take notion of time into blockchain***, +PoH Create verifyable time ordering to allow validator nodes to determine the order of incoming blocks. + +Look at this diagram (a bit confusion) +![](./asset/tx-flow.png) +> ref: https://solana.com/solana-whitepaper.pdf + +![](/assets/kat.png) If you're confused, that's fine! Let's break it down part by part. + +Explain diagram +Transaction coming into solana cluster and then + +1. Select leader generator (PoH generator) by PoS engine (depending on weight of staking amount, ***more on later***). +2. Leader generates PoH with Hashing algroithm (SHA256) +3. Combine transaction hash with the hash generated by the leader node to produce an output that serves as input for the next hash. +3. validator node verify or recompute the hash that generate by leader and working in parallel with the same mechanism. to confirm each tx happening on correct time (state) + +![](/assets/kat.png) Time ordering and block is generate by leader node ! + +> 🚧 Unlike other protocols, this one doesn't require validator nodes to produce and broadcast blocks to the entire network. Instead, validators continuously process the hash in pararell to ensure no malicious leader exists. + +![](/assets/kat.png) That mean schedule with out communication ! + +## How Hashing ? +- PoH Hashing sequen + Leader node will generate hash (SHA256) and the hash can't predict output! + ```mermaid + graph LR + A["🤖 Leader node"]--->B["1️⃣ Hash1 (SHA256)"]--->C["2️⃣ Hash2 (SHA256)"]--->D["3️⃣ Hash3 (SHA256)"] + ``` + +- PoH Hashing + transaction hash + ```mermaid + graph LR + A["🤖 Leader node"]--->B["1️⃣ Hash1 (SHA256)"]--->C["2️⃣ Hash2 (SHA256) + Transaction 💵"]--->D["3️⃣ Hash3 (SHA256)"] + ``` + +Now user sending incoming transaction + +![](./asset/poh-input.png) + > combine transaction hash with previos hash as an input. + + There's a reason why Solana works this way. Let's see in the next topic. 👉 + +## Notion of the time in PoH +How solanana put the time to blockchain ? this is genious concept for solana PoH consensus, + + > Solana uses a sequence of hashes to record event data at the current index of the hashing sequence, like capturing an event at a particular point in the sequence. + +![](./asset/hash-event.png) + +> ref: https://solana.com/solana-whitepaper.pdf + +for example index 336 will use hash 335 output + tx hash (event) as input. + +![](/assets/kat.png) Now we can determine and know the period during which the transaction occurred: before hash 337 was created and after hash 335. + + +## How fast ? +![](/assets/kat.png) Generate hash (GPU) > Generate hash (CPU) + +Let's see transaction piplined +![](./asset/tx-pipeline.png) + +> ref: https://youtu.be/50yhHe_NQ0g?t=253 + +The verification process happens in the GPU section (utilizing the GPU's multiple cores to recompute the hash in parallel). That's why it's not slow even though it recomputes the hash. + +And exactly is implement by power of RUST!! 🦀 + +![](./asset/verification.png) + +> ref: https://solana.com/solana-whitepaper.pdf + +## How verifying ? + +now we don't worry about recompute will be slow, cause solana use multicore from GPU to recompute for verifying, + +now we focus on how it verifying process + +![](./asset/verify-diagram.png) + +> ref: https://youtu.be/079mUCjYpZs?t=798 + +> 🚧 Validator node will verify hash in pararell, by using the same machanism to recompute hash and after got final state that compute with final hash it will checking by sending final state to compare with final state from leader node and then Leader node will commit a block to the ledger. + +![](./asset/net-design.png) + +> ref: https://solana.com/solana-whitepaper.pdf +