Intro to substrate - sub0 - bruno galvao.pptx

dot55audits 40 views 38 slides Jun 11, 2024
Slide 1
Slide 1 of 38
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38

About This Presentation

Intro to substrate - sub0 - bruno galvao.pptx


Slide Content

© Polkadot
subo © Polkadot AA

Intro To Substrate

PPP. Bruno Galvao
a # Software Engineer, ROGUE

=: Polkadot

Agenda

Developers

Founders

Blockchain Enthusiasts

Topics

Substrate definition

The need for a blockchain framework
Building a blockchain is hard
Substrate Architecture

State Transition Function

Deep Dive into Substrate

Why Substrate

How to get started

Smart contracts with Substrate

sub@

nm

lS hea
ra,
Se
Zum
Be
ETS
Es
u
um
—~
y
as


ere
=

\
H

What is Substrate?

An open-source, battle-tested, Rust framework for building
future-proof blockchains optimized for most use cases.

— built by developers for developers

7.1

a

E

k
\

==

|

Mo

a
el

Cr

E

TEA

ne
=
==

ES

pe
Pp
A

LE

AL:

ae
dan >

iy m Wu
Aad um By

Why blockchain
framework?

5 Polkadot

Building a Blockchain

Common components.

> Database
© Storage layer, serialization
> Networking
@ Peer discovery, block/transaction gossiping, RPC
3 Transaction Queue
> Consensus
Proof of Stake, Proof of Authority, Proof of Work, etc.
> Cryptographic primitives
> Block format, account abstraction
> Light client support

ET]
A

GINA

73 Polkadot subQ

Building a blockchain from scratch is hard and takes a lot of
resources.

It is costly, takes time, and requires specialized knowledge:

> Cryptographers

> Security researchers

> Networking engineers

3 Devops personnel (to coordinate updates)
3 Veteran Engineers

75 Polkadot subQ

Substrate

A generic blockchain framework

Database

Networking

Transaction Queue

Consensus

Cryptographic primitives

Block format, account abstraction
Light client support

State transition function

VU VY

All baked into the Substrate framework

Substrate

Consensus
Custom
Block

Execution
Block Builder Logic

Host
Functions Custom

Runtime
Transaction API
Pool

Business
Logic

Custom
Abstractions
e.g. Account,

Balances,

Substrate

| ucla

Compiled

Block Builder
Runtime a D Neen

Branssction API Runtime

Custom

Abstractions

e.g. Account
Balances,

ete
Import
Queue

Database

suba

5 Polkadot

State Transition
Function (STF)

How does your blockchain transition state?
How your blockchain executes blocks.

This is defined in the Substrate runtime.

Some cool logic

Update Balances
Mint NFTs
Vote on a referendum
Stake an Asset

Substrate

Telemetry
| ret | Your Runtime

Consensus i
Some cool logic
JSON-RPC

Update Balances
Block Builder Mint NFTs

Vote on a referendum
Stake an Asset

Functions

Transaction
Pool

State Transition Function (STF)

Bob => 100 DOT

Sr

Alice => 0 DOT

ate

21 State

STF

AO >

Send 10
DOT to
Eve
from
Bob

Bob => 90 DOT
(minus fees)

Eve => 10 DOT

Alice => 0 DOT

State
N+1

Polkadot

It starts from outside the blockchain with an extrinsic

Outside world “external”

An extrinsic is Substrate
lockchain

Executes
ransfer(Bob, Eve, 10) the extrinsic.

Haw does vaur hlackchain transitian state?

Blockchain’s
state changes.

Eve now has 10
more.

75 Polkadot subQ
Extrinsics

How extrinsics work

Executed Executed

= Block Block
N N+1 s
State State
N-1 N

Node Substrate

Telemetry

Consensus

Block Builder

Host
Functions

Transaction
Pool

‘ibp2p

Runtime
API

Runtime

|

NAT
/
/

I

N 7772

FRAME

The framework within the framework.

E

a, en;
=. 8
E
[a
— —
= =
== +
Pa ==
= Sy
=

73 Polkadot
FRAME

Framework for Runtime Aggregation of Modularized Entities (FRAME)

The framework within Substrate for building runtimes

> Modules with business logic (which we call pallets)
> Includes support libraries to aid development

Make building runtimes faster.

Substrate

Pallets
Consensus
Arecutive
Block Builder
Host
Functions Runtime
API

Transaction Staking
Pool
construct_r
untime!

(on)

Preimage

| _— | Fe
ee ee MESA
Balances Elections Atomic Swap

Multisig Collective Bounties
ee ees

Vesting Membership

Your

Pallets :
Runtime

Las Democracy | sudo | pa
pean aes MERS

Atomic
Electi P:
essen’ ER
Collective PELLE
a Sa ES

Your chain, your way!

Telemetry

Consensus

Block Builder

Transaction
Pool

+

Host
Functions

Executive

Runtime
API Treasury || Balances

Assets Democracy

NFTs

Compiled

v

Wasm

Database

Runtime

> Polkadot subQ

Forkless Upgrades

Since the application logic of the chain is stored on-chain as a
Wasm blob, upgrading the chain's business logic is as simple as
updating a key's value

:code => wasm_ runtime blob

Polkadot

Forkless upgrade by updating value for : code key

: codé 0x229

Ox££961 => 0x028 STF RY oxrros1 => ox045

Oxfd859 => 0x472 Upgrade Oxfd859 => 0x472
the

Substrate
runtime

Key-Value Key-Value

Database Database

@ e
State State

> Polkadot subQ

Legacy Upgrades

legacy way of upgrading

O |

upgrade!

75 Polkadot

Legacy Upgrades

legacy way of upgrading
| o Po. o Po

upgrade!

«

4

4

> Polkadot 558 SS SS suba

Forkless Upgrades
the Substrate-way of upgrading

o . Po : Po - Po. . Po. x » 8

upgrade!

trs +

75 Polkadot suba

Governance

There is governance; beyond sudo

You could have something as simple as using pallet collectives with
pallet membership and have a body do the decision-making for your chain.

You could take that a step further and couple it with pallet democracy to
have a more sophisticated voting / proposal / referenda system for your chain.

N ce

Why BZ
Mag
F

|
Why Substrate?

f AT
Bit LE

[lys

wnt

> Polkadot

Why Substrate?

Founders and developers can be confident that
their blockchain is ready for whatever the future
brings.

Focus on crafting the business logic that makes
your chain unique and innovative.

Polkadot subO

Why you should use Substrate

The community is strong

Polkadot
Pokadev100000 = Accounts +
119,540,042

Governance = Developer ~ ®g Settings

@ Parachains

parachains parathreads current lease finalized

49 19 15 19,540,039

© Polkadot

subo
Why you should use
Substrate Ya.
GB. Le
ann Y
= 0 ES
Community. Sl >, ¢ rt,
i + © Q- CRC 0
Polkadot Blockchain Academy y 7 ,
Zug ‘eo "0
a G Ale

https://polkadot.network/development/blockchain-academy

subo

¿3 Polkadot
Polkadot SDK Docs

Getting Started Documentation

3 Polkadot
> Substrate
> FRAME

paritytech.github.io

© Polkadot subO

Substrate Stack Exchange

> Technical Support
3 Community

Help > substrate.stackexchange.com

Development
Time

Building a blockchain by
modifying the Substrate Client
Building a blockchain without
FRAME

Building a blockchain with FRAME
Smart contracts w/ Substrate

Development Complexity

subo

Polkadot

Smart Contracts ;

ink! Smart Contracts

> ink! is an eDSL to write smart contracts in Rust
for blockchains built on the Substrate framework
> compiled to Wasm

Start Here: github.com/paritytech/ink

ROGUE subo

POP cu

Step 1: Build your solution using Pop CLI

POP Network

Step 2: Deploy on Pop Network

© Polkadot subO

Connect

Bruno Galvao
Engineer @ ROGUE

TG: @brunopgalvao

pop.rOgue.io
Tags