enabling forkless blockchain upgrades with substrate upgrades...enabling forkless blockchain...

26
Shawn Tabrizi Software developer @ Parity Technologies Ltd. [email protected] | @shawntabrizi Enabling forkless blockchain upgrades with Substrate

Upload: others

Post on 26-Jun-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Shawn Tabrizi Software developer @ Parity Technologies Ltd.

[email protected] | @shawntabrizi

Enabling forkless blockchain upgrades with Substrate

Page 2: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Shawn Tabrizi

GitHub / Twitter: @shawntabrizi

Software developer @ParityTech

Background:● Identity and Authentication● Cloud Infrastructure● Ethereum DApp Development● Substrate Development

Page 3: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

We will talk about:

● Substrate

● Rust

● Wasm

● Blockchain Upgrades

● Building on Substrate

Page 4: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

BODY

Block 42

HEADER

A quick review of blockchains

BODY

Block 43

HEADER

BODY

Block 41

HEADER

Block 41 Blockchain nodes need:

● Database● P2P Network● Consensus Algorithm● Transaction Handling● State Transition Function

(Runtime)

Page 5: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

How does blockchain development happen today?

Page 6: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Parity has a lot of blockchain building experience...

github.com/paritytech/

parity-ethereumgithub.com/paritytech/

parity-bitcoingithub.com/paritytech/

polkadot

Page 7: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

From Polkadot, came Substrate.

Page 8: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

What is Substrate?

Substrate is an open source, modular, and extensible framework for building blockchains.

Page 9: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

What is Substrate?

Substrate provides all the core components of a Blockchain:

● Database Layer● Networking Layer● Consensus Engine● Transaction Queue● Library of Runtime Modules

Each of which can be customized and extended.

Page 10: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

What is a Runtime?

The runtime is the block

execution logic of the

blockchain, a.k.a. the State

Transition Function.

5sudo aura indices

system fees

consensus

balances

It is composed of

Runtime Modules.

RUNTIME

Substrate Runtime Module Library (SRML)

assets aura balances consensus

contract council democracy executive

fees grandpa indices metadata

session staking sudo system

timestamp treasury upgrade-key and more...

timestamp

upgrade-key

Page 11: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Building components of Substrate

libp2p

CONSENSUS

WEBASSEMBLY

Written in Rust

Built into both native & Wasm

Written in Rust

Built into native

5sudo aura indices

system fees

consensus

balances

RUNTIME

timestamp

upgrade-key

Page 12: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Substrate is built using Rust and Wasm.

Page 13: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Why WebAssembly?

● Wasm is Sandboxed

● Wasm is Fast

● Wasm is Compact

● Wasm is Well Supported

Wasm is a platform independent executable format

Page 14: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

● Rust builds directly to Wasm● Native and Wasm binaries use the

same runtime codebase● No garbage collector overhead● Optimization removes dead code● Resulting in small .wasm files

Why Rust?

Parity is a Rust company as much as it is a blockchain company.

Page 15: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Building components of Substrate

libp2p

CONSENSUS

WEBASSEMBLY

Written in Rust

Built into both native & Wasm

Written in Rust

Built into native

Wasm stored on-chain

5sudo aura indices

system fees

consensus

balances

RUNTIME

timestamp

upgrade-key

Page 16: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Hard Fork Upgrades

OLD LOGIC

OLD LOGIC

OLD LOGIC

OLD LOGIC

OLD LOGIC

OLD LOGIC

NEW LOGIC

NEW LOGIC

NEW LOGIC

NEW LOGIC

Not all nodes upgrade their

software

Page 17: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Forkless Runtime Upgrades

Native client environment

WebAssembly Interpreter

Wasm runtime(from chain)

Merklisedstorage

database

Native runtime is

same version as on-chain

runtime? ✔

Native runtime(from client)

ENTRY APIs

Page 18: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

● Fix important security vulnerabilities

● Change core rules in the protocol

● Add new functionality

● Repair chain state

➢ Hard fork upgrades require a lot of coordination

➢ Unclear governance/signaling around upgrades

A Need for Upgrades

Page 19: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Governing Runtime Upgrades

● Runtime code is accessible

through on-chain governance

● Sudo Module

● Democracy Module

● Your own module and logic

● Runtime Upgrades are Optional

Page 20: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

● We created a demonstration runtime based on the

popular CryptoKitties DApp

● Runtime upgrades allow you to extend and

improve your DApp Chains

○ Add new features and functions

○ Add new storage items

○ Repair or upgrade existing storage

● What would it look like to upgrade this runtime?

Extending and Upgrading Your Substrate Runtime

https://www.cryptokitties.co/

Page 21: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Let’s do an upgrade...

Live Demo

Page 22: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

substrate.dev/substrate-collectables-workshop

Substrate Collectables Workshop

➔ Run a local Substrate node➔ Learn about runtime

development and best practices

➔ Build a working chain with UI➔ Minimal Rust Experience

Kitty by David Revoy

Page 23: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer
Page 24: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

We’re hiring!

parity.io/jobs

Page 25: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Parity events and updates

parity.io/newsletter

Page 26: Enabling forkless blockchain upgrades with Substrate Upgrades...Enabling forkless blockchain upgrades with Substrate Shawn Tabrizi GitHub / Twitter: @shawntabrizi Software developer

Questions?

[email protected]@shawntabrizi