Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Solomon Hykes on Twitter https://twitter.com/solomonstre/status/1111004913222324225

Slide 3

Slide 3 text

Agenda - LINE Blockchain Developers’ Today And Future - Why WASM Is Suitable For Smart Contracts - Smart Contracts and WASM Today - About VM (by Takahashi)

Slide 4

Slide 4 text

LINE Blockchain Developers’ Today And Future Smart Contract Enables Executing Your Business Logic on Blockchain

Slide 5

Slide 5 text

LINE Blockchain Developers (LBD) LBD supports your service with LINE Blockchain

Slide 6

Slide 6 text

Tutorial Example: Mage Duel NFT Trading Card Games Service In LINE Blockchain - Each card is a NFT (Non- Fungible Token) - Ruby is FT (Fungible Token) - User can buy cards with ruby - Cards in shops is randomized - Users can re-randomize cards with ruby

Slide 7

Slide 7 text

Re-Randomizing Cards in Shop Randomizing is proceeded off-chain, payment is proceeded on-chain - Payment is proceeded on-chain - Re-randomizing is executed in game server (off-chain) - LBD cannot support the randomizing, now - It cannot be represented with APIs, now - Better if it is on-chain - Service can show its fairness - User can see the process Server Client LINE Blockchain Request randomizing Show the shop Payment of ruby Execute randomizing Is it fair initializing? How to show the fairness? Cannot record & show initializing executions

Slide 8

Slide 8 text

Smart Contract Proceed your business logic on-chain - Developers deploy own program - Users call the program - Code are executed by VM - The chain records executions

Slide 9

Slide 9 text

Requirements: Smart Contract What is needed to available your program on Blockchain Do not threaten the chain and node machines Safe Every node can execute code and gets the same result Executable Deterministic Do not avoid other transactions Effective WebAssembly takes attentions because it meets these requirements

Slide 10

Slide 10 text

Why WebAssembly Is Suitable For Smart Contracts WebAssembly meets smart contract’s technical requirements

Slide 11

Slide 11 text

WebAssembly (WASM) WebAssembly makes WebApps more efficient - Compiled from C++/Rust/etc… - Binary formed executable file - Runs on VM (browser’s sidecar) - High performance as same as machine native operations - 3D games e.g.) d3wasm - Image processing libraries e.g.) photon

Slide 12

Slide 12 text

WebAssembly WebASsembly corporates with JS and calculate complex parts Traditional Web Apps Web Apps Using WebAssembly HTML CSS JavaScript HTML CSS JavaScript WebAssembly Executing programs as efficient as host native

Slide 13

Slide 13 text

Abstract WebAssembly’s strong points meet the requirements of smart contract Excutable Deterministic Effective Safe Developer Friendly Requirements of Smart Contract Strong Points of WebAssembly Portable Fast and Efficient Safe Language Independent Deterministic API Usable Open and Debugable

Slide 14

Slide 14 text

Portable (Executable) WASM contracts run as same regardless of node hosts Develop Runs on e.g.) LINUX-Intel Any platform ARM Intel LINUX ARM Intel Windows M1 Intel MacOS

Slide 15

Slide 15 text

Deterministic (Deterministic) With a few restrictions, WASM contracts are deterministic and do not avoid consensus “nondeterministic execution can only occur in a small number of well-defined cases” Quoted from https://github.com/WebAssembly/design/blob/main/Nondeterminism.md

Slide 16

Slide 16 text

Efficient and Fast (Efficient) WASM smart contracts are expected not to take too much time “Efficient: can be decoded, validated, and compiled in a fast single pass, equally with either just-in-time (JIT) or ahead-of- time (AOT) compilation.” Quoted from https://webassembly.github.io/spec/core/intro/introduction.html

Slide 17

Slide 17 text

Safe (Safe) WASM runs in a sandbox and cannot threaten blockchain node Host PC Sard box virtual memory use process Cannot threaten memory disc WASM

Slide 18

Slide 18 text

Open: API Usable (Safe, Friendly) WASM can import host/blockchain specified functions via API which the VM provides WASM binary Header using API α using API β ... ... ... ... ... ... ... call α call β Body (Logics) APIs via VM ... Read File A Write File A

Slide 19

Slide 19 text

Readable and Debuggable (Safe, Friendly) WASM has readable text form and it helps validation and debugging (module (func (param $lhs i32) (param $rhs i32) (result i32) local.get $lhs local.get $rhs i32.add))

Slide 20

Slide 20 text

Language Independent (Friendly) Developers can make smart contract with common languages ーーーーーー ーーーーーー ーーーーーー C++ WASM binary Rust Other Languages ーーーーーー ーーーーーー ーーーーーー ーーーーーー ーーーーーー ーーーーーー

Slide 21

Slide 21 text

Summary WebAssembly is suitable for smart contracts and LINE Blockchain plans to introduce it Excutable Deterministic Effective Safe Developer Friendly Requirements of Smart Contract Strong Points of WebAssembly Portable Fast and Efficient Safe Language Independent Deterministic API Usable Open and Debugable - WASM is suitable for smart contracts - Suitable for some other non-web, too (e.g. embedded programs) - LINE Blockchain plans to support WASM as smart contracts - Services can use own logics in LINE Blockchain with this - WASM enables developing smart contract with C++/Rust

Slide 22

Slide 22 text

Smart Contracts And WASM Today VMs, WebAssembly, and Ethereum

Slide 23

Slide 23 text

Runtime Executes Smart Contracts Smart Contracts Runs on the sidecar VM Blockchain Smart Contract VM Code Call Deploy Developer Users

Slide 24

Slide 24 text

Popular Smart Contract Runtime Almost blockchain with smart contract uses the EVM or a WASM VM WASM VM Cloned/Forked EVM - Developed for Ethereum - Using original format binary - There are some DSL for binary e.g.) solidity Pros - Ethereum tools are usable for development - Ethereum contracts are usable Cons - Chain needs to compatible with Ethereum- specified functions (e.g. get block info) - Non-blockchain-specified VMs are usable - VM for WASM - Common languages (C++/Rust) are usable Pros - Common languages are usable - Non-blockchain-specified tools are usable - There are many VM and technical options Cons - Needs restrictions for deterministic/metering - Needs to provide blockchain-specified API

Slide 25

Slide 25 text

Ethereum Aims WASM Contracts: eWASM eWASM: the subset of WASM with restrictions for smart contracts and compatibility with traditional EVM Required Specification - Restricting non-deterministic operators - Supporting VM’s blockchain specified functions via API - Able to meter execution cost (gas) Language Support - Providing API interface libraries for C++ - Providing API interface libraries for rust Ethereum-Specified Restrictions - Compatible with traditional EVM code - Able to be checked with security contract – “sentinel contract” - Support compiling from solidity, the most popular Ethereum smart contract language

Slide 26

Slide 26 text

Summary WebAssembly is hot in blockchain and smart contract - WebAssembly’s strong points suits smart contracts’ requirements - Chains with smart contract pays attention to WebAssembly LINE Blockchain aims to support WASM as smart contracts - Services can use own business logics in LINE Blockchain - Smart contracts can be developed with C++/Rust and their tools

Slide 27

Slide 27 text

VM into LINE Blockchain The Road to Using WASM as a VM for Smart Contract

Slide 28

Slide 28 text

Things to consider when implementing VM Executable Deterministic Effective Safe Developer Friendly Requirements of Smart Contract Strong Points of WebAssembly Portable Fast and Efficient Safe Language Independent Deterministic API Usable Open and Debugable

Slide 29

Slide 29 text

Things to consider when implementing VM To make it easier to adapt to change Scalability Developer friendly Language Independent To focus on the global market Fast and Efficient

Slide 30

Slide 30 text

Smart Contracts Execution Flow VM Runtime Code(C++) Code(Rust) ... Compiler (Interpreter) Machine code WASM Byte code build frontend backend

Slide 31

Slide 31 text

Runtime Compiler / Interpreter Deterministic Support no_std

Slide 32

Slide 32 text

Compiler ※ IR(Intermediate Representation): A data format used between the conversion of source code into machine language that is finally executed by the CPU. Run (from the 2nd time) WASM Byte code Run (first) Machine Machine Code JIT Compiler IR (※) CPU Compile WASM Byte code Machine Machine Code AOT Compiler IR CPU Compile JIT Compile AOT Compile Run

Slide 33

Slide 33 text

Compiler Backend Singlepass Cranelift LLVM IR Not use Use Use Compile Speed ◎ ○ △ Execute Speed △ ○ ◎

Slide 34

Slide 34 text

Interpreter WASM Byte code Machine Interpreter CPU

Slide 35

Slide 35 text

Is Compiler better? Developer Interpreter is so slow… Compiler is better. LLVM is the fastest ! Okay, let‘s use LLVM!!

Slide 36

Slide 36 text

Avoid JIT Bomb VM Runtime Code Compiler Machine code “Twemoji” ©Twitter, Inc and other contributors (Licensed under CC-BY 4.0) Developer Compile is not finish...

Slide 37

Slide 37 text

Compiler Backend Singlepass Cranelift LLVM IR Not use Use Use Compile Speed ◎ ○ △ Execute Speed △ ○ ◎ Complexity and amount of code △ × × Can Blockchain use ? ○ (Need a strict security audit) × (Difficult to check security audit on compilers)

Slide 38

Slide 38 text

Which Runtime to choose? Wasmer wasmi wasmtime Lucet

Slide 39

Slide 39 text

Performance Privacy Security What's your Priority? Compiler / Interpreter Support no_std Deterministic

Slide 40

Slide 40 text

Performance What's your Priority? It's too slow!! Runtime to Compile is preferred over interpreters (e.g., Wasmer).

Slide 41

Slide 41 text

Privacy What's your Priority? PRIVATE !! If you want to use TEE(※) for confidentiality, use a Runtime that supports no_std. ※ trusted execution environment

Slide 42

Slide 42 text

Security What's your Priority? If security is your primary concern, aim for strict determinisitic.(e.g., wasmi). Is it down?

Slide 43

Slide 43 text

What’s their Priority? Holochain Secret Network Polkadot Priority Performance Privacy Security Runtime Before wasmi (interpreter) Wasmer (not support no_std) wasmi (Strict deterministic) After Wasmer (Singlepass Compiler) wasmi (support no_std) (V8 or SpiderMonkey) Effect Increased execution speed Smart Contracts can be executed with TEE Not yet

Slide 44

Slide 44 text

LINE Blockchain’s VM LINE Blockchain Priority Performance Runtime Wasmer (Singlepass Compiler) Goal Improve the performance even more. Continue to optimize Singlepass.

Slide 45

Slide 45 text

Summary - It is necessary to prepare Runtime to use WASM as the execution module of Smart contract. - There are several points to consider when deciding on a Runtime, and what to adopt depends on your priorities. Mission : To create a Smart contract VM with WASM

Slide 46

Slide 46 text

Thank you