Skip to content

Commit

Permalink
First practical session
Browse files Browse the repository at this point in the history
  • Loading branch information
CostinCarabas committed Oct 12, 2023
1 parent 414f952 commit 03ba087
Show file tree
Hide file tree
Showing 17 changed files with 247 additions and 84 deletions.
11 changes: 0 additions & 11 deletions chapters/introduction/lab/content/explorer/README.md

This file was deleted.

44 changes: 44 additions & 0 deletions chapters/introduction/lab/content/explorer/blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Blocks in Blockchain

For simplicity, we will use MultiversX blockchain and MultiversX [Explorer](https://explorer.multiversx.com/).

## Notarization of blocks

Inspect the image below:
![Blocks on MultiversX](../../media/blocks.png)

We can observe 4 blocks from 1 second ago for 4 different shards: Shard0, Shard1, Shard2, Metachain.
These shard a sub-blockchains and enables MultiversX to scale. You can read more about shard [here](https://docs.multiversx.com/technology/adaptive-state-sharding).

We can observe 4 more blocks from 7 seconds ago. That's because each shard outputs a block every 6 seconds.

---
**NOTE**

We previously saw that _every 6 seconds starts new round_, but _not necessarly a new block gets notarized_.
In this case all the blocks successfully passed the consensus round and got notarized.

---


## Block details

[Here](https://explorer.multiversx.com/blocks/cec3654a58245c7b548ffdb56254107b3a3a46903b5d191cf67ff126eaa17111) is the link for one of the blocks in the previous image (Block Height: 16826695).

![Block 16826695](../../media/block_16826695.png)

Observe the block details:
- Round
- Epoch
- Age (timestamp)
- Shard

Based on a simple calculus, the epoch is 1168 which means this blockchain started 3 years and 73 days ago.

We will talk about the other fields in the next section.


## Practice

1. Go to the MultiversX [Explorer](https://explorer.multiversx.com/) and check more blocks from different shard;
2. Go to the Ethereum [Explorer](https://etherscan.io/) and check some blocks details.
15 changes: 15 additions & 0 deletions chapters/introduction/lab/content/explorer/consensus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Consensus Group

We will continue with the same [block](https://explorer.multiversx.com/blocks/cec3654a58245c7b548ffdb56254107b3a3a46903b5d191cf67ff126eaa17111) from the previous section (Block Height: 16826695).

Observe the field **Consensus Group**:
![Leader](../../media/leader.png)

There are 63 validators which execute every transaction in this block.
If you click on the **63 validators (See all)** button you will see 63 public keys, which are links to all the 63 nodes that participated in consensus.

## Practice

- Open 3 different blocks in 3 different tabs. Observe that every time there is another consensus group.
Why do you think the system is designed this way?
- Open 3 different blocks in 3 different tabs on Ethereum [Explorer](https://etherscan.io/). Observe that every time there is another leader.
27 changes: 27 additions & 0 deletions chapters/introduction/lab/content/explorer/leader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Blockchain Leader

We will continue with the same [block](https://explorer.multiversx.com/blocks/cec3654a58245c7b548ffdb56254107b3a3a46903b5d191cf67ff126eaa17111) from the previous section (Block Height: 16826695).

![Leader](../../media/leader.png)

We can observe that the **Leader** (also called the **proposer**) is `Istari Vision`.
The leader, also known as the block producer or validator, is responsible for performing several critical tasks within a consensus round:

1. **Block Proposal:** The leader is tasked with proposing a new block containing a set of transactions. This block proposal is the first step in the process of reaching consensus. The leader selects transactions to include in the proposed block and creates a cryptographic hash of the block's contents.

2. **Signature and Verification:** After proposing a block, the leader signs it with their private key to prove its authenticity. Other network participants can verify the leader's signature using their public key. This verification ensures that the proposed block is indeed from the authorized leader.

3. **Broadcasting the Proposal:** Once the block is signed, the leader broadcasts it to the network. Other nodes in the network receive and validate the proposed block to ensure its compliance with the consensus rules.

4. **Agreement and Confirmation:** If the proposed block meets the consensus criteria, it is accepted by the network. The leader's proposed block becomes part of the blockchain, and consensus is achieved for that round.

Let's see some details about this proposer:

![Istari Vision](../../media/istari.png)

We can see his public key, version of the software for the blockchain node and other information we will further discuss.

## Practice

Open 3 different blocks in 3 different tabs. Observe that every time there is another leader.
Why do you think the system is designed this way?
Empty file.
57 changes: 57 additions & 0 deletions chapters/introduction/lab/content/explorer/time.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Understanding Time in Blockchains

In traditional computer systems, time is relatively straightforward, with a reliance on the system clock.
However, in the world of blockchains, time is a unique and critical concept.
Blockchains need to maintain a shared understanding of time across all participants, and this introduces some complexities.
Here's how time is managed in blockchains:

## Rounds

`Rounds`` refer to the cyclic or sequential stages of consensus protocols, particularly in proof-of-stake (PoS) and delegated proof-of-stake (DPoS) blockchains.
Each blockchain has it's own length of rounds:
- MultiversX - 6 seconds;
- Ethereum - 12 seconds;
- Solana - 0.4 seconds;
- Cardano - 5 seconds;
- NEAR - 1 second;

A round is a time limit to execute a batch of transactions.

## Blocks

Every **round** a new **block** is being proposed.
That proposal can succeed or not. In case of success, a block is added to the blockchain history.
The missed blocks are due to not reaching consensus and are usually under 5%.


---
**NOTE**

For MultiversX case, _every 6 seconds starts new round_, but _not necessarly a new block gets notarized_.

---

## Epochs

This is another time measurement and it's used for larger periods of time (just like minutes, hours, years, decades, etc.).

Each blockchain has it's own length of epochs:
- MultiversX - 14.400 rounds (24 hours);
- Ethereum - 30.000 rounds (100 hours);
- Solana - 432.000 rounds (48 hours);
- Cardano - 432.000 rounds (5 days);
- NEAR - 43.200 rounds (12 hours).

## Block Timestamps

Blockchains organize transactions into blocks, and each block has a timestamp. This timestamp is crucial for several reasons:

1. **Order of Transactions:** The timestamp helps order transactions within a block. Transactions are grouped together and processed in the order in which they are added to a block. This ensures that everyone has a consistent view of the transaction history.

2. **Difficulty Adjustment:** Some blockchains, like Bitcoin, use the block timestamp to adjust the difficulty of the proof-of-work (PoW) algorithm. This keeps the block generation rate relatively constant, regardless of the total network hash rate.

3. **Block Validity:** Block timestamps are used to determine whether a block is valid. If the timestamp of a new block is too far in the future or past, it can be considered invalid.

## Practice

Check MultiversX [Explorer](https://explorer.multiversx.com/) and Ethereum [Explorer](https://etherscan.io/) and see how (almost) at every 6, respectively 12 seconds a new block appears.
37 changes: 37 additions & 0 deletions chapters/introduction/lab/content/explorer/transactions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Transactions

We will continue with the same [block](https://explorer.multiversx.com/blocks/cec3654a58245c7b548ffdb56254107b3a3a46903b5d191cf67ff126eaa17111) from the previous section (Block Height: 16826695).

Observe the field **Transactions**:
![Block 16826695](../../media/block_16826695.png)
We can see that there are 6 transactions in this group.

## Miniblocks

Transactions are grouped in **miniblocks**.
Each miniblock is a category with `Shard_source - Shard_destionation`.

So, for the first miniblock we have 3 transactions from Shard1 to Shard2:
![Block 16826695](../../media/miniblock.png)

## Transaction details

We will use the first [transaction](https://explorer.multiversx.com/transactions/e988394fa40fb97796f2250c3f33087eba46e3a12ef6d3a0ed3b0dbb2084df18#32cfd2a98e1467aaeac65b9a211cf54bc9453cac0ba64da39a8bf789967bf0a2) from the first miniblock as an example:


![Transaction](../../media/transaction1.png)

Observe the fields:
- Status: Success;
- Age: timestamp;
- Miniblock: the one we previously disscussed about;
- From: The user who created the transaction
- To: The destination of the transaction. This is a smart contract. We will discuss about it in a further section;
- Value: The number of EGLD (MultiversX native token) sent in this transaction

There are more fields in this transaction, but we will discuss about it in a further section.

## Practice

- Open 3 different transactions in 3 different tabs. Inspect the fields.
- Open 3 different transactions in 3 different tabs on Ethereum [Explorer](https://etherscan.io/). Inspect the fields.
Empty file.
6 changes: 0 additions & 6 deletions chapters/introduction/lab/content/observer/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions chapters/introduction/lab/content/wallet/README.md

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/introduction/lab/media/blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/introduction/lab/media/istari.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/introduction/lab/media/leader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/introduction/lab/media/miniblock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chapters/introduction/lab/media/transaction1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 67 additions & 59 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ make_assets:
options:
command: make
locations:
- chapters/template-chapter/template-topic/slides
- chapters/introduction/lecture/slides
- chapters/protocol/lecture/slides
- chapters/case-study/lecture/slides
- chapters/wallet/lecture/slides
- chapters/vm/lecture/slides
- chapters/smart-contracts/lecture/slides
- chapters/security/lecture/slides
- chapters/dApps/lecture/slides
- chapters/composability/lecture/slides
args:
- all

Expand All @@ -22,7 +30,15 @@ embed_reveal:
target: docusaurus
extension: mdx
build:
template-chapter-template-topic: template-chapter-template-topic
Introduction: slides/introduction
Protocol: slides/protocol
Case-Study: slides/case-study
Wallet: slides/wallet
VM: slides/vm
Smart-Contracts: slides/smart-contracts
Security: slides/security
Dapps: slides/dApps
Composability: slides/composability

docusaurus:
plugin: docusaurus
Expand All @@ -31,66 +47,58 @@ docusaurus:
sidebar: js
structure:
- Introduction: chapters/README.md
- Lectures:
- Introduction:
path: chapters/template-chapter/template-topic/
extra:
- media/
subsections:
- Reading/: reading/
- Drills/: drills/
- Guides/: guides/
- Slides: /build/embed_reveal/template-chapter-template-topic
- Blockchain Protocols v1:
path: chapters/template-chapter/yet-another-topic/
subsections:
- Drills/: drills/
- Blockchain Protocols v2:
path: chapters/template-chapter/yet-another-topic/
subsections:
- Drills/: drills/
- Case Study - Invited Speaker:
path: chapters/template-chapter/yet-another-topic/
subsections:
- Drills/: drills/
- Wallet:
path: chapters/template-chapter/yet-another-topic/
subsections:
- Drills/: drills/
- Virtual Machine:
path: chapters/template-chapter/yet-another-topic/
subsections:
- Drills/: drills/
- Smart Contracts:
path: chapters/template-chapter/yet-another-topic/
subsections:
- Drills/: drills/
- Security:
path: chapters/template-chapter/yet-another-topic/
subsections:
- Drills/: drills/
- Scaling dApps:
path: chapters/template-chapter/yet-another-topic/
subsections:
- Drills/: drills/
- Composability:
path: chapters/template-chapter/yet-another-topic/
subsections:
- Drills/: drills/
- Lecture:
path: /build/embed_reveal
subsections:
- Introduction: Introduction/Introduction.mdx
- Blockchain Protocols: Blockchain-Protocols/Blockchain-Protocols.mdx
- Case Study: Case-Study/Case-Study.mdx
- Wallet: Wallet/Wallet.mdx
- Virtual Machine: Virtual-Machine/Virtual-Machine.mdx
- Smart Contracts: Smart-Contracts/Smart-Contracts.mdx
- Security: Security/Security.mdx
- Scaling dApps: Scaling-dApps/Scaling-dApps.mdx
- Composability: Composability/Composability.mdx
- Practical Sessions:
- Introduction:
path: chapters/template-chapter/template-topic/
- Explorer:
path: chapters/introduction/lab/content/explorer
extra:
- media/
subsections:
- Reading/: reading/
- Drills/: drills/
- Guides/: guides/
- Slides: /build/embed_reveal/template-chapter-template-topic
- ../media/
- ../quiz/
subsections:
- Time in Blockchain/: time.md
- Blocks/: blocks.md
- Block Leader/: leader.md
- Consensus Grup/: consensus.md
- Transactions/: transactions.md
- Blockchain Validators/: validators.md
- Blockchain Observers/: observers.md
- Observer:
path: chapters/introduction/lab/content/observer
extra:
- ../../media/
- ../../quiz/
subsections:
- Time in Blockchain/: time.md
- Blocks/: blocks.md
- Transactions/: transactions.md
- Leader/: leader.md
- Consensus Grup/: consensus.md
- Validators/: validators.md
- Observers/: observers.md
- Wallet:
path: chapters/template-chapter/yet-another-topic/
subsections:
- Drills/: drills/
path: chapters/introduction/lab/content/wallet
extra:
- ../../media/
- ../../quiz/
subsections:
- Time in Blockchain/: time.md
- Blocks/: blocks.md
- Transactions/: transactions.md
- Leader/: leader.md
- Consensus Grup/: consensus.md
- Validators/: validators.md
- Observers/: observers.md
- Basic Peer-to-Peer Blockchain:
path: chapters/template-chapter/yet-another-topic/
subsections:
Expand Down

0 comments on commit 03ba087

Please sign in to comment.