Skip to content

Commit

Permalink
Kian Substrate lectures (#1037)
Browse files Browse the repository at this point in the history
* Fix a few things

* rename

* more updates from kian
  • Loading branch information
kianenigma authored May 31, 2024
1 parent 3a80e4c commit 16cd7dd
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 262 deletions.
2 changes: 1 addition & 1 deletion assets/img/5-Substrate/dev-4-1-substrate-meta-version.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/styles/PBA-theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
--r-hub-pink: #E6007A;
--r-hub-lime: #D3FF33;
--r-hub-green: #56F39A;

/* Colors used in the Polkadot-SDK Lectures */
--substrate-green: #25cc85ff;
--substrate-runtime: #bb8ba6;
--substrate-host: #8d3aed;
}

/* box sizing;
Expand Down
19 changes: 13 additions & 6 deletions syllabus/6-Polkadot-SDK/Polkadot-SDK-slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ The holy grain of what ETH 2.0 was meant to be.

<img width="800px" rounded src="./img/multi-threaded.svg" />

- Have we compromised security in any way in this model?
Note:

Have we compromised security in any way in this model?

---v

Expand Down Expand Up @@ -161,8 +163,8 @@ All proudly™️ built with Substrate.

Substrate 🤝 FRAME

Substrate: Un-opinionated primitives for building blockchains based on a WASM meta-protocol.
FRAME: An opinionated way to build that WASM protocol/runtime/STF.
- Substrate: Un-opinionated primitives for building blockchains based on a WASM meta-protocol.
- FRAME: An opinionated way to build that WASM protocol/runtime/STF.

Note:

Expand Down Expand Up @@ -205,19 +207,24 @@ but it can 100% ensure that the parachain will do exactly as stated in its WASM

### Interoperability

Polkadot's services to developers:
Polkadot-SDK's services to developers:

- Transport protocols for parachains/cores to send payloads to one
another.
- XCMP, HRMP, VMP, DMP 😶‍🌫️
- As a developer you won't deal with these! 😮‍💨
- Language to compose messages and programs and send them over.
- XCM
- Shared ideas between sovereign consensus systems.
- Asynchronous.

Note:

Consensus System: Moreover, the sender and recipient of these messages can be contracts, accounts, or any other
abstract entities within chains, not just the chain itself.
On "XCMP, HRMP, VMP, DMP": It is similar to building a website. You know HTTP and TCP and such
exist, and you use them via an interface, but you don't need to know them by heart.

Consensus System: Moreover, the sender and recipient of these messages can be contracts, accounts, or any
other abstract entities within chains, not just the chain itself.

Async and Sync: Disjoint consensus systems are in principle[^1] asynchronous by nature. This is an
important concept to keep in mind.
Expand Down
213 changes: 129 additions & 84 deletions syllabus/6-Polkadot-SDK/Substrate/1-Intro-to-Substrate-slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ this when you learn about Substrate's role in the Polkadot ecosystem.

Figure: https://www.youtube.com/watch?v=0IoUZdDi5Is

---v

### Why Substrate?

#### 💭 An update in 2024 💭

🧐 Multi-chain vs. Multi-shard 🧐

Note:

Polkadot led the way since 2016 to convince the world that the future is multi-chain.

Cosmos tried to replicate the same without shared security.

ETH is now doing something similar, with a Rollup-Centric roadmap.

Interestingly, Polkadot is now arguing that the future is not necessarily multi-chain, but rather
multi-shard. In that, there needs to be a sharded system, with a high degree of flexibility to
schedule those shards. "Multi-chain" is merely one manifestation of a multi-shard system, which is
actually not so flexible. We are now striving to make the multi-chain Polkadot more flexible, which
is what JAM is going to be.

---

## Core Philosophies of Substrate 💭
Expand Down Expand Up @@ -335,7 +357,11 @@ whole thing to be updated.

### 🏦 Governance + Upgradeability

_The way to make a protocol truly upgradeable is to design a meta-protocol._
<img src="../../../assets/img/5-Substrate/dev-4-1-substrate-meta-substrate.svg" />

Note:

This is very similar to treating your own runtime as a smart contract.

---v

Expand All @@ -352,11 +378,7 @@ be upgraded with a fork.

### 🏦 Governance + Upgradeability

<img src="../../../assets/img/5-Substrate/dev-4-1-substrate-meta-substrate.svg" />

Note:

This is very similar to treating your own runtime as a smart contract.
_The way to make a protocol truly upgradeable is to design a (fixed) meta-protocol._

---v

Expand All @@ -382,15 +404,27 @@ This is very similar to treating your own runtime as a smart contract.
<pba-col center>
<h3 style="color: var(--substrate-runtime); top: 0"> Runtime (Protocol) </h3>

- Application logic
- Wasm (maybe **FRAME**)
- Stored as a part of your chain state
- Application logic aka. How we execute block
- Stored as a part of your chain state as a WASM Blob
- Upgradeable
- Also known as: STF

</pba-col>

<pba-col center>
<h3 style="color: var(--substrate-host); top: 0"> Node (Meta-protocol) </h3>

<img width="600px" src="../../../assets/img/5-Substrate/dev-4-1-substrate.svg" />

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

---v

#### Substrate (simplified) Architecture

<pba-cols>
<pba-col center>
<h3 style="color: var(--substrate-host); top: 0"> Fixed Node (Meta-protocol) </h3>

- Native Binary
- Executes the Wasm runtime
Expand All @@ -399,6 +433,12 @@ This is very similar to treating your own runtime as a smart contract.

</pba-col>

<pba-col center>

<img width="600px" src="../../../assets/img/5-Substrate/dev-4-1-substrate.svg" />

</pba-col>

</pba-cols>

---
Expand Down Expand Up @@ -514,47 +554,6 @@ https://forum.polkadot.network/t/announcing-polkavm-a-new-risc-v-based-vm-for-sm

---

## State of Light Client/Nodes

- Node that follows headers, therefore knows state roots and can ask for state-proofs to do more.

Note:

Establish that it is merely an alternative node implementation.

---v

### State of Light Clients

<img src="../../../assets/img/5-Substrate/dev-4-1-smoldot.svg" />

Notes:

What was a light client? follows only block headers, therefore knows state roots, and a few other
pieces of information, others send it state proofs if it wishes to do more.

SMOLDOT is not exactly a substrate client. It is mainly designed to work with Polkadot. But with
minimal tweaks, you could make it work for more substrate based chains.

This has to do with the fact that consensus and a few other bits of the client and runtime are not
100% independent. For example, GRANDPA has a pallet on the runtime side, but is mostly in the
client. Now, a client that is configured with GRANDPA can only work with runtimes that are also
configured with GRANDPA.

---v

### State of Light Clients

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

Note:

Similarly it is dead simple to embed smoldot in mobile etc.

Separate lecture on this later.

---

## Communication Paths

<img style="width: 1400px" src="../../../assets/img/5-Substrate/dev-4-1-comms.svg" />
Expand Down Expand Up @@ -674,34 +673,6 @@ fn main() {

### Substrate and Smart Contracts

> SMOLDOT is syncing a chain who's runtime is executing wasm contracts.
Question: How many nested Wasm blobs are executing one another?

---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>

- The browser is executing:
- a Wasm blob (SMOLDOT in extension)
- that executes a Wasm blob (runtime)
- that executes a Wasm blob (contract)

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

---v

### Substrate and Smart Contracts

- So when should you write with a smart contract, and when a Runtime (FRAME)?

Notes:
Expand All @@ -722,7 +693,7 @@ fee-less.

---

## Technical Freedom vs Ease
## Development Options

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

Expand Down Expand Up @@ -975,8 +946,7 @@ state is sometimes called "storage" asd well.
- **Rust**, **Generic Design**, **Upgradeability/Governance**
- Positive and negative consequences of Wasm
- Substrate next to Polkadot and other chains.
- Substrate for Smart Contracts.
- Light Nodes/Clients.
- Substrate and Smart Contracts.
- Node / Runtime architecture
- State Transition Deep Dive -> Forkless Upgrade

Expand Down Expand Up @@ -1018,7 +988,7 @@ hardcoded, but the protocol itself is flexible.

#### Track: Aux Lecture

- Tx Pool (Kian)
- Tx Pool
- Interacting with Substrate
- SCALE Codec

Expand Down Expand Up @@ -1086,7 +1056,13 @@ exception](https://www.gnu.org/software/classpath/license.html).

---

## Appendix: More Diagrams of Substrate and Polkadot
## Appendix

Content that is not covered, but is relevant.

---

### More Diagrams of Substrate and Polkadot

Notes:

Expand Down Expand Up @@ -1156,3 +1132,72 @@ People actually tried sticking things like JVM into the browser (_Java Applets_)

- Any language that can compile to Wasm and exposes a fixed set of functions, to be used by the client.
- ... But, of course, Substrate comes with a framework to make this developer-friendly, **FRAME™️**.

---

## State of Light Client/Nodes

- Node that follows headers, therefore knows state roots and can ask for state-proofs to do more.

Note:

Establish that it is merely an alternative node implementation.

---v

### State of Light Clients

<img src="../../../assets/img/5-Substrate/dev-4-1-smoldot.svg" />

Notes:

What was a light client? follows only block headers, therefore knows state roots, and a few other
pieces of information, others send it state proofs if it wishes to do more.

SMOLDOT is not exactly a substrate client. It is mainly designed to work with Polkadot. But with
minimal tweaks, you could make it work for more substrate based chains.

This has to do with the fact that consensus and a few other bits of the client and runtime are not
100% independent. For example, GRANDPA has a pallet on the runtime side, but is mostly in the
client. Now, a client that is configured with GRANDPA can only work with runtimes that are also
configured with GRANDPA.

---v

### State of Light Clients

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

Note:

Similarly it is dead simple to embed smoldot in mobile etc.

Separate lecture on this later.

---v

### Substrate and Smart Contracts

> SMOLDOT is syncing a chain who's runtime is executing wasm contracts.
Question: How many nested Wasm blobs are executing one another?

---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>

- The browser is executing:
- a Wasm blob (SMOLDOT in extension)
- that executes a Wasm blob (runtime)
- that executes a Wasm blob (contract)

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

0 comments on commit 16cd7dd

Please sign in to comment.