SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Downloaden Sie, um offline zu lesen
Introduction to
Ewasm
Tai, Hung-Ying (hydai) @ Crosslink 2019
GitHub: @hydai
VP of Engineering, Second State
Slide: http://url.hyd.ai/LRFVT
www.secondstate.io
1
2
3
4
Agenda
EVM bytecode recap
WebAssembly (Wasm)
Ewasm 1.0
Ewasm 2.0
www.secondstate.io
EVM bytecode recap
● Stack-based virtual machine (or interpreter…)
● 256 bit stack items
● Too many high level instructions
○ Storage(SSTORE, SLOAD)
○ SHA3(keccak-256)
○ Call, Create Contract…
● Too far away from actual machine architecture
● Less language support (Vyper, Solidity, ...)
www.secondstate.io
How about Wasm?
● Also, a stack-based machine but…
○ has locals ( ~= register or memory)
○ only access top 3 items from stack v.s EVM’s 16
● Support 32/64 bit operations
● No high level instructions
● RISC Instruction Set, can map to a common CPU ISA
● Large community power
○ Supported in all major browser
○ Lots of language support (C++, Rust, …)
www.secondstate.io
Wasm Section
www.secondstate.io
Wasm tooling
● Tool
○ binaryen (a toolkit contains an interpreter in C++)
○ wabt (a toolkit contains an interpreter in C++)
○ wavm (LLVM-based JIT)
○ wagon (interpreter in Golang)
○ wasmi (interpreter in Rust)
● Browser (hyper interpreter/JIT)
○ Chrome (V8)
○ Edge (chakra)
○ Firefox (spidermonkey)
Ewasm 1.0
www.secondstate.io
What is Ewasm 1.0
● Ewasm ⊂ wasm
● NOT support floating point number
● LIMITED imports and exports (wasm section)
● Will inject bytecode metering and has runtime metering
Where did the high
level instructions
go? (e.g. SHA)
www.secondstate.io
Ethereum Environment Interface (EEI)
● EEI defines a set of ewasm imported functions
● With standard interface, clients can implement easier
● Because EEI is not native instructions in bytecode
● Quick prototyping and doing specific upgrades
www.secondstate.io
Definition
www.secondstate.io
Usage
How about
Invalid instructions
issues?
www.secondstate.io
System Contracts
● Compiled into wasm bytecode
● Deployed on chain (like normal contract)
○ Or be part of client (like precompiles)
● Examples:
○ Byzantium precompiles
■ sha256, ripemd160, ecrecover, modexp, …
■ Use upper-bound metering
○ Sentinel (verification and metering)
www.secondstate.io
Sentinel Contract
● Before contract deployment
● Reject non-Ewasm bytecode (e.g. floating point)
● Insert metering statements
● basic-block-based metering (call useGas in the beginning of
block)
www.secondstate.io
Basic Block Metering (Injection)
www.secondstate.io
Ewasm Stack
www.secondstate.io
EVM-C
● Connect client and VM implementation
● Ethereum Virtual Machine includes EVM1 and eWASM
● With EVM-C, VM can be linked statically or loaded as
plugin (.dll, .so)
● C means C language API
www.secondstate.io
Performance - Sha1
parity-evm 79.3ms
geth-evm 70.7ms
life 14.9ms
evmone 6.3ms
wasmi 5.6ms
wabt 3.1ms
www.secondstate.io
Performance - BN128mul
life 470ms
wasmi 390ms
wabt 106ms
parity-evm 18.0ms
geth-evm 2.3ms
evmone 553.0us
www.secondstate.io
What happens?!!!!!
● General wasm engine supports 32/64 bit operations
● 256 bit operations will be simulated by 32/64 bit
operations
○ ONE 256 bit operations may be replaced by 25 64 bit
operations
● As EVM provides precompiles, Wasm engine can support
`bignum` library to speed up.
Ewasm 2.0
www.secondstate.io
1
2
3
4
Questions about ETH 2.0
State Rent?
Cross-shard call?
Phase 2?
DevEx???
www.secondstate.io
1
2
3
4
Questions about ETH 2.0
State Rent?
Cross-shard call?
Phase 2?
DevEx???
www.secondstate.io
1
2
3
4
Questions about ETH 2.0
State Rent?
Cross-shard call?
Phase 2?
DevEx???
www.secondstate.io
1
2
3
4
Questions about ETH 2.0
State Rent?
Cross-shard call?
Phase 2?
DevEx???
www.secondstate.io
Execution Environments (EEs)
● “Contracts” are now called EEs
● EEs are Wasm bytecode
● EEs are executed on shards
● Shards only store a short (32-byte) state root for an EE
● On-shard execution goal is to verify the current state
root and calculate the new state root based on a
submitted proof and transactions
www.secondstate.io
Two Ewasms
● Ewasm 1.0 - Stateful, EVM-like design, with all the
legacy EVM brings
● Ewasm 2.0 - Stateless and pure execution oriented
design
● Can launch Ewasm 1.0 on Eth 1.0 if optimising EVM in
clients fails
● Can use Ewasm 1.0 contracts within EEs on Eth 2.0
www.secondstate.io
Stateful V.S. Stateless
https://github.com/gballet/presentations/blob/master/devcon/devconv/wasm_precompiles/compare_erc20.dot
www.secondstate.io
Phase One and Done - Very First Step
● Start simple - minimal execution
● Add EEs (Now we have code fields)
● Execute the EEs in shard blocks
● Here comes a testing tool - Scout!!!
www.secondstate.io
Open Questions
● How will cross-shard calls work?
○ Nobody knows
● How will the Eth1 switchover work?
○ Nobody is exactly sure.
● When Serenity?
○ January 3rd, MAYBE
www.secondstate.io
1
2
3
4
A MAYBE Roadmap
Phase one execution
Experiments with different EE
ETH1-esque environment with EVM/Ewasm
ETH1 -> ETH2 switchover
www.secondstate.io
What is Scout?
● An Eth 2.0 execution prototyping framework
● Based on “ETH 2.0 Phase 2 Proposal 2”
● Defines an API for the EEs (the EEI)
● Defines a test format (YAML format)
● Provides a tool which can execute on that format
● Provides example EEs
www.secondstate.io
EE(I)
● eth2::loadPreStateRoot(memoryOffset: u32ptr)
● eth2::blockDataSize() -> u32
● eth2::blockDataCopy(memoryOffset: u32ptr, offset:
u32, length: u32)
● eth2::savePostStateRoot(memoryOffset: u32ptr)
● eth2::pushNewDeposit(memoryOffset: u32ptr,
length: u32)
www.secondstate.io
EE: Hello World (in Rust)
www.secondstate.io
Playground
● SOLL - Compile your Solidity Smart Contract into
Ewasm via LLVM
○ Can deploy Ewasm bytecode on Ethereum Ewasm testnet
○ https://github.com/second-state/soll
○ Demo Video: https://youtu.be/X-A6sP_HTy0
● Scout - Ethereum 2.0 Phase 2 execution prototyping
engine
○ https://github.com/ewasm/scout
www.secondstate.io
Reference
● Ewasm overview and the precompile problem: Alex Beregszaszi and
Casey Detrio @ Ethereum  Part 1 - YouTube
● Ewasm overview and the precompile problem: Alex Beregszaszi and
Casey Detrio @ Ethereum  Part 2 - YouTube
● Wasm for blockchain&Eth2 execution: Paul Dworzanski,Alex
Beregszaszi,Casey Detrio@Ethereum  Part 2 - YouTube
● Ewasm for sharding
● Ewasm updates
● Ewasm design
● wasm-intro
Thanks!

Weitere ähnliche Inhalte

Was ist angesagt?

Make Your Own Developement Board @ 2014.4.21 JuluOSDev
Make Your Own Developement Board @ 2014.4.21 JuluOSDevMake Your Own Developement Board @ 2014.4.21 JuluOSDev
Make Your Own Developement Board @ 2014.4.21 JuluOSDev
Jian-Hong Pan
 

Was ist angesagt? (20)

asyncio
asyncioasyncio
asyncio
 
S2 e (selective symbolic execution) -shivkrishna a
S2 e (selective symbolic execution) -shivkrishna aS2 e (selective symbolic execution) -shivkrishna a
S2 e (selective symbolic execution) -shivkrishna a
 
Workshop@naha_val3
Workshop@naha_val3Workshop@naha_val3
Workshop@naha_val3
 
Bsdtw17: ruslan bukin: free bsd/risc-v and device drivers
Bsdtw17: ruslan bukin: free bsd/risc-v and device driversBsdtw17: ruslan bukin: free bsd/risc-v and device drivers
Bsdtw17: ruslan bukin: free bsd/risc-v and device drivers
 
ZeroMQ with NodeJS
ZeroMQ with NodeJSZeroMQ with NodeJS
ZeroMQ with NodeJS
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
 
Secure LXC Networking
Secure LXC NetworkingSecure LXC Networking
Secure LXC Networking
 
Switch or broker
Switch or brokerSwitch or broker
Switch or broker
 
ZeroMQ
ZeroMQZeroMQ
ZeroMQ
 
Rapid SPi Device Driver Development over USB
Rapid SPi Device Driver Development over USBRapid SPi Device Driver Development over USB
Rapid SPi Device Driver Development over USB
 
Let's Talk Locks!
Let's Talk Locks!Let's Talk Locks!
Let's Talk Locks!
 
Make Your Own Developement Board @ 2014.4.21 JuluOSDev
Make Your Own Developement Board @ 2014.4.21 JuluOSDevMake Your Own Developement Board @ 2014.4.21 JuluOSDev
Make Your Own Developement Board @ 2014.4.21 JuluOSDev
 
We shall play a game....
We shall play a game....We shall play a game....
We shall play a game....
 
Build reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQBuild reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQ
 
Zeromq anatomy & jeromq
Zeromq anatomy & jeromqZeromq anatomy & jeromq
Zeromq anatomy & jeromq
 
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVMScala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM
 
Snaps on open suse
Snaps on open suseSnaps on open suse
Snaps on open suse
 
MazuV-Debug-System
MazuV-Debug-SystemMazuV-Debug-System
MazuV-Debug-System
 
Simplestack
SimplestackSimplestack
Simplestack
 

Ähnlich wie Introduction to Ewasm - crosslink taipei 2019

Programming with Threads in Java
Programming with Threads in JavaProgramming with Threads in Java
Programming with Threads in Java
koji lin
 
Medical Image Processing Strategies for multi-core CPUs
Medical Image Processing Strategies for multi-core CPUsMedical Image Processing Strategies for multi-core CPUs
Medical Image Processing Strategies for multi-core CPUs
Daniel Blezek
 

Ähnlich wie Introduction to Ewasm - crosslink taipei 2019 (20)

Web (dis)assembly
Web (dis)assemblyWeb (dis)assembly
Web (dis)assembly
 
Introduction to ewasm
Introduction to ewasmIntroduction to ewasm
Introduction to ewasm
 
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
 
The State of the Veil Framework
The State of the Veil FrameworkThe State of the Veil Framework
The State of the Veil Framework
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
0507 057 01 98 * Adana Klima Servisleri
0507 057 01 98 * Adana Klima Servisleri0507 057 01 98 * Adana Klima Servisleri
0507 057 01 98 * Adana Klima Servisleri
 
Shall we play a game
Shall we play a gameShall we play a game
Shall we play a game
 
Enabling Java: Windows on Arm64 - A Success Story!
Enabling Java: Windows on Arm64 - A Success Story!Enabling Java: Windows on Arm64 - A Success Story!
Enabling Java: Windows on Arm64 - A Success Story!
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)
 
Programming with Threads in Java
Programming with Threads in JavaProgramming with Threads in Java
Programming with Threads in Java
 
Java Memory Model
Java Memory ModelJava Memory Model
Java Memory Model
 
Eclipse IoT Talk (Montreal JUG)
Eclipse IoT Talk (Montreal JUG)Eclipse IoT Talk (Montreal JUG)
Eclipse IoT Talk (Montreal JUG)
 
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMUSFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
 
Kirill Rozin - Practical Wars for Automatization
Kirill Rozin - Practical Wars for AutomatizationKirill Rozin - Practical Wars for Automatization
Kirill Rozin - Practical Wars for Automatization
 
Programming Decentralized Application
Programming Decentralized ApplicationProgramming Decentralized Application
Programming Decentralized Application
 
Medical Image Processing Strategies for multi-core CPUs
Medical Image Processing Strategies for multi-core CPUsMedical Image Processing Strategies for multi-core CPUs
Medical Image Processing Strategies for multi-core CPUs
 
Nodejs
NodejsNodejs
Nodejs
 
AEO Training - 2023.pdf
AEO Training - 2023.pdfAEO Training - 2023.pdf
AEO Training - 2023.pdf
 
An introduction to Node.js application development
An introduction to Node.js application developmentAn introduction to Node.js application development
An introduction to Node.js application development
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 

Introduction to Ewasm - crosslink taipei 2019