Skip to content

Commit

Permalink
Mod 4 and 5 updates from Kian (#478)
Browse files Browse the repository at this point in the history
* update a lot of stuff

* fmt
  • Loading branch information
kianenigma authored Jan 17, 2023
1 parent 1442049 commit c6dcd97
Show file tree
Hide file tree
Showing 45 changed files with 1,147 additions and 658 deletions.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-1-comms.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/img/4-Substrate/dev-4-1-contracts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-1-forkless-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-1-forkless-2.svg
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 assets/img/4-Substrate/dev-4-1-ink.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-1-state-opaqueu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-1-state.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-1-substrate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-1-wasm-langs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-2-external.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/img/4-Substrate/dev-4-3-block-opaqueu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-3-child.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-3-full-comm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-3-full.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-3-import.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/img/4-Substrate/dev-4-3-native-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-3-native.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-3-pruning-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-3-pruning-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-3-pruning-3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-3-pruning-4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-4-3-upgrade.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-kv-backend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-overlay-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-overlay-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-overlay-3.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-overlay-4.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-overlay-5.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-overlay-nested-1.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-overlay-nested.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-overlay-root.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-overlay.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-trie-backend-unbalanced.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-trie-backend-walk-0.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-trie-backend-walk-1.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-trie-backend-walk-2.svg

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/img/4-Substrate/dev-trie-backend-walk-full.svg

Large diffs are not rendered by default.

158 changes: 114 additions & 44 deletions syllabus/4-Substrate/4.1-Intro-to-Substrate_Slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Substrate is a **Rust framework** for **building blockchains** in a modular and

- ⛓️ Future is multi-chain.

<img width="800px" src="../../assets/img/4-Substrate/dev-4.1-maximalism.png"></img>
<img rounded width="1000px" src="../../assets/img/4-Substrate/dev-4.1-maximalism.png"></img>

---v

Expand Down Expand Up @@ -61,8 +61,7 @@ Outcomes of this:

- Rust as a language
- Upgradeability through a WASM meta-protocol.
- Generic.
APIs >> Opinions.
- Generic (build _APIs_, not _fixed implementations_).

---v

Expand Down Expand Up @@ -157,13 +156,6 @@ Outcomes of this:

---v

### Negative Consequences of _WASM_ Runtime 🥲

- 😩 Constrained resources
- 🤔 Client diversification != state-transition diversification

---v

### 🤖 Deterministic Execution

- The need for determinism in a blockchain runtime is _absolute_.
Expand Down Expand Up @@ -196,13 +188,20 @@ Outcomes of this:

### 😎 Forkless Upgrade:

<img style="width: 1200px;" src="../../assets/img/4-Substrate/dev-4-1-forkless-2.svg" />
<img style="width: 1400px;" src="../../assets/img/4-Substrate/dev-4-1-forkless-2.svg" />

---v

### Negative Consequences of _WASM_ Runtime 🥲

- 😩 Constrained resources
- 🤔 Client diversification != state-transition diversification

---v

### What is WASM Anyways?

<img style="width: 1200px;" src="../../assets/img/4-Substrate/dev-4-1-wasm-langs.svg">
<img style="width: 1400px;" src="../../assets/img/4-Substrate/dev-4-1-wasm-langs.svg">

---v

Expand All @@ -228,29 +227,6 @@ Outcomes of this:

---v

### SMOLDOT

<pba-cols>

<pba-col center>

A marvel of universe 🤯.

- (light) Substrate\* node compiled to WASM, by the browser.
- Itself executing another WASM blob, the aforementioned runtime.

</pba-col>

<pba-col center>

<img style="width: 800px;" src="../../assets/img/4-Substrate/dev-4-1-smoldot.svg">

</pba-col>

</pba-cols>

---v

### How to Write a WASM Runtime?

- Any language that can compile to WASM and exposes a fixed set of functions, to be used by the client.
Expand All @@ -269,12 +245,14 @@ Everything else you need in a blockchain, except the consensus-critical, determi
- Compiled to native.
- Less need for determinism.
- Has access to anything a normal native binary does (memory, disk, syscalls etc.)
- Does all the other shared things that most blockchains want
- Database, Networking, Mempool, Consensus..

---v

### The Client

<img style="width: 1200px;" src="../../assets/img/4-Substrate/dev-4-3-full.svg">
<img style="width: 1400px;" src="../../assets/img/4-Substrate/dev-4-3-full.svg">

---v

Expand Down Expand Up @@ -331,6 +309,29 @@ Because the runtime can change independently!

</pba-cols>

---v

### SMOLDOT: Compile the Client to WASM

<pba-cols>

<pba-col center>

A marvel of universe 🤯.

- (light) Substrate\* client compiled to WASM, by the browser.
- Itself executing another WASM blob, the aforementioned runtime.

</pba-col>

<pba-col center>

<img style="width: 600px;" src="../../assets/img/4-Substrate/dev-4-1-smoldot.svg">

</pba-col>

</pba-cols>

---

## Communication Paths
Expand Down Expand Up @@ -436,24 +437,93 @@ https://www.cleanpng.com/png-game-boy-advance-deviantart-video-game-consoles-218

## Substrate and Polkadot

<img style="width: 1300px;" src="../../assets/img/4-Substrate/dev-4-1-polkadot.svg">
<img style="width: 1400px;" src="../../assets/img/4-Substrate/dev-4-1-polkadot.svg">

---

## Substrate and Smart Contracts

<img style="width: 100px;" src="../../assets/img/4-Substrate/dev-4-1-ink.jpeg">

NOTE:

I was asked this yesterday as well. My latest answer is: if you don't need any of the customizations
that a blockchain client/runtime gives to you, and the performance of a shared platform is okay for
you, then go with a smart contract. If you need more, you need a "runtime" (some kind of chian,
parachain or solo)

An example of customization is that a runtime has access to `on_initialize` etc.

Also, a contract usually depends on a token for gas, while a runtime can be in principle token-less
fee-less.

---v

### Substrate and Smart Contracts

<img style="width: 1000px;" src="../../assets/img/4-Substrate/dev-4-1-contracts.svg">

---v

### Substrate and Smart Contracts

- So a SMOLDOT instance, syncing a substrate based chain which has pallet-contracts is ...🤔

---v

### Substrate and Smart Contracts

<pba-cols>
<pba-col center>

<img style="width: 600px;" src="https://media.tenor.com/Oc4nf8N08jIAAAAM/mind-blow-galaxy.gif">

</pba-col>
<pba-col center>

- a WASM blob (smoldot)
- that executed a WASM blob (runtime)
- that executed a WASM blob (contract)

</pba-col>
</pba-cols>

---

## Technical Freedom vs Ease

<img style="width: 1200px;" src="../../assets/img/4-Substrate/dev-4-1-freedom.svg"/>
<img style="width: 1000px;" src="../../assets/img/4-Substrate/dev-4-1-freedom.svg"/>

---

## Rest of This Module! 😈

<pba-cols>
<pba-col>

##### Lecture

- Day 0:
- **Introduction**
- Folder structure.
- Day 1:
- **WASM Meta-Protocol**
- SCALE, JSON-RPC
- Day 2:
- **Storage**
- Substrate CLI, TX-Pool

</pba-col>
<pba-col>

##### Activity

- Day 0:
- **Introduction To Substrate**
- Activities..
- Compiling Rust to WASM
- Day 1:
- **WASM Meta Protocol**
- Activities..
- FRAME-less Activity
- Day 2:
- **Substrate Storage**
- More activities..
- FRAME-less Activity

</pba-col>
</pba-cols>
13 changes: 11 additions & 2 deletions syllabus/4-Substrate/4.2-Substrate-Folder-Structure_Slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ Substrate is roughly composed of 3 parts:

Primitives is the glue between the other two.

> Extra Activity: Go search for some crates based on these prefixes in https://paritytech.github.io/substrate/.
---v

### Substrate Internally: `./client`
Expand Down Expand Up @@ -63,11 +61,22 @@ Primitives is the glue between the other two.

---v

### Workshop

- Go search for some crates based on these prefixes in https://paritytech.github.io/substrate/.
- Look into the codebase as well.

---v

### Substrate Internally

- So what's the point in all of this? 🤨

- When looking for the code related to a given topic, this information should help you find it.

<br>
<hr>
<br>

- Networking? only on `sc-*`
- Database/Storage? Probably in `sc-*` and `sp-*`
Expand Down
Loading

0 comments on commit c6dcd97

Please sign in to comment.