-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #443 from Chia-Network/academy-bchain-basics
Academy bchain basics
- Loading branch information
Showing
6 changed files
with
703 additions
and
0 deletions.
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
docs/academy/blockchain-basics/block-formation-basics.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
--- | ||
title: How New Blocks are Formed | ||
slug: /block-formation-basics | ||
--- | ||
|
||
## Learning objectives | ||
- **Transaction Validation**: Learn how nodes validate transactions for inclusion in a block. | ||
- **Block Formation**: Understand farmers role in forming blocks. | ||
- **Mempool**: Review the mempool basics for transaction inclusion and removal. | ||
|
||
--- | ||
|
||
## Content | ||
In this lesson, we review the basics of block formation including the farmers role in validating transactions, forming blocks, and managing the mempool. | ||
|
||
<div class="videoWrapper"> | ||
<iframe width="100%" height="504" src="https://www.youtube.com/embed/5XAbF_gs07I" frameborder="0" allowfullscreen="allowfullscreen"></iframe> | ||
</div> | ||
|
||
--- | ||
|
||
## Script | ||
<details> | ||
|
||
<summary> Expand for the full script </summary> | ||
|
||
00:00 | ||
Every time a transaction occurs, it first gets sent to a full node (a node that is staying synced with the current state of the network), which verifies that it is a valid transaction. | ||
|
||
00:15 | ||
This verification ensures that the conditions and signatures are valid, and that the coins being spent are currently unspent and valid. The transaction is then added to the mempool waiting to be included in a block. | ||
|
||
00:30 | ||
A Farmer that wins the challenge will form a block by retrieving transactions from the mempool, usually based on fee amount, until the maximum block size is reached. The block is then signed and added to the chain, | ||
|
||
00:45 | ||
and the relevant transactions are cleared from the mempool. In this way, transactions are propagated throughout the network very quickly, through the mempool, but are only confirmed once included in a block. | ||
|
||
01:00 | ||
|
||
</details> | ||
|
||
--- | ||
|
||
## Common gotchas | ||
|
||
- **Transaction Validation:** Transactions are validated by all nodes not only while blocks are being formed but also when the newly infused blocks are sent from peers, this eliminates a malicious actors ability from altering transactions even if they have the fastest timelord and have farmed the block. | ||
- **Block Formation vs Infusion:** Block formation is the process of combining proofs of space with transactions (the foliage) and is performed by the farmer while block infusion is the process of adding blocks to the chain itself and is performed by timelords. | ||
- **Mempool:** All spend bundles (transactions) from the mempool that will be included in a block are aggregated together during block formation, this means that the specific spend bundle for a given transaction is not stored on-chain and is only available in the mempool. | ||
|
||
--- | ||
|
||
## Knowledge check | ||
|
||
:::tip Question 1 - Transaction Validation | ||
|
||
What system validates transactions in Chia? | ||
|
||
A. Timelords | ||
B. Farmers | ||
C. Harvesters | ||
D. Full Nodes | ||
|
||
::: | ||
|
||
<details> | ||
|
||
<summary> Answer (expand when ready to see the answer) </summary> | ||
|
||
D. Full Nodes | ||
|
||
</details> | ||
|
||
:::tip Question 2 - Block Formation | ||
|
||
Is the below statement True or False? | ||
|
||
Full nodes are responsible for infusing blocks while timelords are responsible for forming blocks. | ||
|
||
::: | ||
|
||
<details> | ||
|
||
<summary> Answer (expand when ready to see the answer) </summary> | ||
|
||
False, it is timelords that **infuse** blocks to the chain and the role of full nodes to **form** blocks while creating proofs of space. | ||
|
||
</details> | ||
|
||
:::tip Question 3 - Mempool | ||
|
||
What is the Mempool? | ||
|
||
A. Temporary storage on the network where transactions are queued before being confirmed. | ||
B. The amount of system memory the blockchain can access. | ||
C. The total size of all current plots on the network. | ||
D. Another name for the chia blockchain database. | ||
|
||
::: | ||
|
||
<details> | ||
|
||
<summary> Answer (expand when ready to see the answer) </summary> | ||
|
||
A. Temporary storage on the network where transactions are queued before being confirmed. | ||
|
||
</details> | ||
|
||
--- | ||
|
||
## Additional resources | ||
|
||
### Links | ||
|
||
- Transaction validation [overview](https://docs.chia.net/block-validation/#body-validation): dives into the requirements for validating the blocks body (which contains the transactions). | ||
- Block formation [overview](https://docs.chia.net/consensus-foliage): explores the intricacies of the full nodes role in block formation and when transaction blocks are formed. | ||
- Block Infusion [detailed documentation](https://docs.chia.net/signage-and-infusion-points/): detailed information on how and when blocks are infused in the chain. | ||
- Mempool [detailed documentation](https://docs.chia.net/mempool/): detailed information on all aspects of mempool inclusion scenarios and how the mempool is updated. | ||
- Support [in discord](https://discord.gg/chia): for further support join our discord server and ask in the #chialisp or #support channels. | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
--- | ||
title: Coin-Set Model Intro | ||
slug: /coinset-basics | ||
--- | ||
|
||
## Learning objectives | ||
- **Coin Contents**: Learn what data is stored in a coin. | ||
- **Coin Puzzle**: Understand the role of a coins puzzle. | ||
- **Coin Solution**: Learn about the importance of a coins solution. | ||
|
||
--- | ||
|
||
## Content | ||
In this lesson, we dive into the coinset model basics and learn what it means to spend a coin in Chia. | ||
|
||
<div class="videoWrapper"> | ||
<iframe width="100%" height="504" src="https://www.youtube.com/embed/-axXmWEor-Q" frameborder="0" allowfullscreen="allowfullscreen"></iframe> | ||
</div> | ||
|
||
--- | ||
|
||
## Script | ||
<details> | ||
|
||
<summary> Expand for the full script </summary> | ||
|
||
00:00 | ||
Chia uses the "coinset model" to keep track of the blockchain's state. | ||
|
||
00:10 | ||
In this model, every transaction is represented by a "coin" that contains a value, the rules by which the coin can be spent, and signature authorizing the spend. | ||
|
||
00:20 | ||
What this means is that a "coin" can have any value (in mojo) and as long as the rules are satisfied, anyone can spend the coin. | ||
|
||
00:30 | ||
There are no accounts represented in the system. | ||
|
||
When a coin is created, the value is locked away in that coin and is inaccessible until the coin is spent, | ||
|
||
00:40 | ||
at which point new coins will be created with values equal to the original. | ||
|
||
For example, if I want to send 1 XCH to someone else, | ||
|
||
00:50 | ||
I will create a coin with a value of 1 XCH (or 1 trillion mojos), and set the conditions of the coin to only allow the coin to be spent if given the signature of the other person. | ||
|
||
01:00 | ||
This in effect "sends" the coin to the other person, because they now control what happens to it. When they want to spend the coin, they provide the correct signature, and a new coin is created, | ||
|
||
01:10 | ||
with a value of 1 XCH, itself containing it's own rules of how it can be spent. | ||
|
||
In this way, each coin is only ever used once. | ||
|
||
01:20 | ||
Once it has been spent, it creates a new coin. In Chia, we call the set of conditions needed to unlock the coin the 'puzzle', and the provided data to unlock the coin is the 'solution'. | ||
|
||
01:30 | ||
The coin is represented in the chain as a hash of three attributes, the parent coin ID, (or the ID of the previous coin that created this new one), | ||
|
||
01:40 | ||
the hash of the puzzle that contains the conditions, and the value of the coin. | ||
|
||
01:50 | ||
</details> | ||
|
||
--- | ||
|
||
## Common gotchas | ||
|
||
- **Coinset vs Account:** Chia adopts the coinset model where everything is a coin that has its own set of rules, more information about the coinset model can be found [here](https://docs.chia.net/coin-set-vs-account/). This differs from the account model which instead uses contracts (or accounts) to represent users balances and these balances are what is stored on the chain (as opposed to coins and those coins values). | ||
- **Puzzles:** All requirements for spending a coin are contained in the coins puzzle. These puzzles can be simple or complex and effect how, when, and by whom the coin can be spent. The coins puzzle must be determined at the coins creation and cannot be altered thereafter. | ||
- **Solutions:** The ability to spend a coin is based on the users ability to provide a valid solution for the coins puzzle. | ||
|
||
--- | ||
|
||
## Knowledge check | ||
|
||
:::tip Question 1 - Coinset | ||
|
||
What data is contained in coins on the Chia Blockchain? (Select all that apply) | ||
|
||
A. Amount (or value) | ||
B. User account number | ||
C. Puzzle Hash | ||
D. Parent Coin ID | ||
|
||
::: | ||
|
||
<details> | ||
|
||
<summary> Answer (expand when ready to see the answer) </summary> | ||
|
||
A. Amount (or value) | ||
C. Puzzle Hash | ||
D. Parent Coin ID | ||
|
||
</details> | ||
|
||
:::tip Question 2 - Puzzle | ||
|
||
True or False: All puzzles on the Chia blockchain are the same. | ||
|
||
::: | ||
|
||
<details> | ||
|
||
<summary> Answer (expand when ready to see the answer) </summary> | ||
|
||
False, while coin puzzles might be similar (such as the standard transaction) the parameters in puzzles vary greatly (who can spend the coin, how it can be spent, other special rules). | ||
|
||
</details> | ||
|
||
:::tip Question 3 - Solutions | ||
|
||
Do all coin solutions require a signature? | ||
|
||
::: | ||
|
||
<details> | ||
|
||
<summary> Answer (expand when ready to see the answer) </summary> | ||
|
||
No, it is possible to create coins that do not require any signature or other spender validation (anyone can spend coins) or to even lock coins using non-signature restrictions (such as password protected coins). | ||
|
||
</details> | ||
|
||
:::tip Question 4 - Coinset vs Account Model | ||
|
||
Does Chia adopt the coinset model or the account model? | ||
|
||
::: | ||
|
||
<details> | ||
|
||
<summary> Answer (expand when ready to see the answer) </summary> | ||
|
||
The coinset model. | ||
|
||
</details> | ||
|
||
--- | ||
|
||
## Additional resources | ||
|
||
### Links | ||
|
||
- Detailed [coinset and account model comparisons](https://docs.chia.net/coin-set-vs-account/): details the differences between the coinset and account models including how these differences effect transactions. | ||
- Overview of [coin puzzles](https://docs.chia.net/coin-set-intro/#puzzles): overviews the role of a coins puzzle and the effect it has on the coins abiltiy to be spent. | ||
- Security recommendations for [signing solutions](https://docs.chia.net/coin-set-security/#signing): reviews the recommendations for securing puzzles by requiring that solutions are signed to limit those who can spend the coin. | ||
- Support [in discord](https://discord.gg/chia): for further support join our discord server and ask in the #chialisp or #support channels. | ||
|
||
--- |
Oops, something went wrong.