SlideShare una empresa de Scribd logo
1 de 39
Descargar para leer sin conexión
Fast, deterministic, and
verifiable computations
with WebAssembly
Mike Voronov
twitter.com/@vms11
• Open-source, decentralized cloud computing network
• Charge developers for computational complexity only: no hash mining

• WebAssembly as the platform for fast & verifiable stateful computations
2
Objectives
Fast
Deterministic
Verifiable
3
Computation machine
What does it mean – verifiable?
4
Problems:
• nodes running the same code got different computation results
• nodes got same results but claim to have spent different amounts of gas
Solutions:
• consensus algorithms, ZK proofs, hardware enclaves
• we use verification game (a part of a special kind of consensus)
5
Verifiable computations
• Verifier finds an incorrect state transition and opens a dispute on Ethereum
• Verification game narrows the dispute to a single WebAssembly instruction
• Ethereum smart contract repeats the instruction and penalizes the bad node
6
Verification game
Execution mode: fast execution
• JIT/AOT compilation is essentially mandatory
• Only final state (VM memory) matters

Dispute mode: granular execution
• JIT/AOT compilation is highly desirable
• Intermediate states (VM memory, stack, instruction pointer) matter too
• Ability to take & load VM snapshots, stop at k-th instruction
• Ability to extract the data needed to execute single instruction on Ethereum
7
Execution duality
WebAssembly to JVM compilation
8
• Each Wasm module is compiled to JVM class by Asmble
• Both JVM and Wasm are stack-based VMs => straightforward conversion
9
WebAssembly to JVM bytecode
10
Another example
С++ Wasm Java
11
Conversion table
WebAssembly JVM Bytecode
{i32, i64, f32, f64} –> {int, long, float, double}
Wasm module –> JVM class
Wasm function –> JVM function
Wasm memory –> ByteBuffer
global variables –> Class fields
calls –> invoke{Exact | virtual | dynamic}
12
Benchmark
https://link.medium.com/PwslNPOSiX
Code instrumentation
13
14
Dispute resolution: k-ary search
• Need to record in Ethereum virtual machine state on every search step
• Need to find the instruction which was executed differently:
😇 VMp–1 = 👿 VMp–1
😇 VMp ≠ 👿 VMp
• Then, need to send this instruction along with required data to Ethereum
15
Virtual machine state
Need to track:
• memory
• stack
• globals
• instruction pointer (ip)
• executed instructions counter (eic)
• used gas
Need to collapse all the required data into a single record
Need to generate proofs for:
• memory chunks and stack frames
• instruction pointer and executed instructions counter
• used gas
HVM = hash(Hmem, Hstack, Hip, Heic, Hgas)
Hmem = merkle(memory)
...
Hgas = hash(gas)
16
VM state hash
Standard Merkle hash:
• needs to rehash the entire memory region
even if only a single byte was changed
• is not optimal for multiple computations
during k-ary search
• is not optimal for large-scale state updated
by simple request processing code
17
Linear memory hash
Idea:
• track memory chunks that were made dirty 

during the state transition VMi => VMi+1
• once the state transition is complete, all
chunks are clean again
• store a cache of intermediate hashes in the
Merkle tree
• when requested, recompute hashes
(including Merkle root) on dirty paths only
18
Incremental memory hash
Algorithmic complexity:
• need to recompute the dirty chunk hash
• need to recompute all hashes on the dirty path
O(chunk_size + hash_size * log(total_chunks))


Additional memory usage:
• dirty chunks bitmap index: 1 MB
• tree hashes cache: 2 * 32 * 10242 = 64 MB
19
Incremental hash: complexity
memory = 4 GB, chunk = 4 KB, hash = 32 B
20
Attack: malicious code updates 1 byte in each memory chunk
How much should we charge? The node had to rehash the 

entire 4 GB memory, but the code has written just 1 MB.
Solution: charge fixed price for each chunk that was dirtied
algorithms taking into account page caching should not be hurt too much
Incremental hash: gas usage
Normally, WebAssembly stack is implicitly supported by the JVM stack
However, there is no easy way to access JVM stack data
Stack emulation can be used to retrieve values from the WebAssembly stack
21
Shadow stack
22
Execution mode: implicit stack
23
Dispute mode: shadow stack
Bottomline
Computation machine has execution duality:
Normal mode:
- EIC
- gas
- merkle hash of the final state
Dispute mode:
- EIC
- gas
- merkle hash of the final state
- shadow stack
24
Deterministic computations
25
• External function calls
• VM resource exhaustion
• NaN floating point payloads
https://dl.acm.org/citation.cfm?doid=3062341.3062363
26
Non-determinism sources in Wasm
Our approach:
• at now, on the testnet imports from
the host environment are not allowed
• to obtain persistence, WebAssembly
memory is backed to disk by the host
system
27
External function calls
We are working on supporting of a subset of the WASI syscalls: 

for example – time, filesystem, random number generation operations
Our approach:
• developer configures desired memory and stack size
• allocation of all dynamic Wasm parts (heap, stack, table) is performed
at the virtual machine initialization
• grow_memory always returns –1
28
VM resource exhaustion
NaN (not-a-number) – is a special type of a floating-point value
29
NaN payloads
Popular platforms have different behavior regarding NaNs

New NaN value:
• x86 – NaN with the sign bit set
• ARM and others – produce with it unset


Operations with multiple NaN inputs:
• x86 – first NaN input
• ARMv8 – NaN depending on the signaling and quiet state


some hardware architectures prefer to return a NaN with a fixed bit pattern 30
NaN payloads
31
NaN payloads
Any arithmetical operations with NaNs produce NaNs
32
NaN payloads
Idea: instrument all floating-point operations – convert non-canonical NaNs
into canonical NaNs
Better idea: instrument only those operations that transfer floating-point
values outside of the floating-point domain

Outside transfer operations:
• {f32,f64}.reinterpret_{i32,i64} – converts float value to integer
• {f32,f64}.store – stores float value to the linear memory
• copysign – copies the sign bit into a non-NaN value
Bottomline
To obtain deterministic WebAssembly execution, we:
• block syscalls (in the future: provide a subset of deterministic syscalls)
• preallocate all dynamic resources
• use the canonical NaN pattern when transferring floats outside
33
Few words about Fluence
34
35
Fluence: hybrid security approach
Speed layer
On-demand database (Redis/SQLite) clusters
Security layer
DB transaction history validation for 

the entire network
Data availability layer
DB transaction history storage in Swarm/Filecoin
Dispute resolution layer
Verification game with Ethereum as the final judge
Speed layer
• Ethereum holds the registry of deployed databases
• Consensus-based (BFT) replication between nodes
• Direct frontend <–> database interaction
• TX history is uploaded to Swarm/Filecoin

Tendermint
WebAssembly
36
Security layer
Composition:
• TX history is verified segment by segment
• Segments are sequentially verified by several validators
Validators:
• Are randomly selected from the shared network pool
• Verify that preceding validations were autonomous
• Do not know if there will be a subsequent validation
37
38
Thanks!
dash.fluence.network

Más contenido relacionado

La actualidad más candente

Jacob Marble [InfluxData] | Observability with InfluxDB IOx and OpenTelemetry...
Jacob Marble [InfluxData] | Observability with InfluxDB IOx and OpenTelemetry...Jacob Marble [InfluxData] | Observability with InfluxDB IOx and OpenTelemetry...
Jacob Marble [InfluxData] | Observability with InfluxDB IOx and OpenTelemetry...InfluxData
 
Service Discovery in Prometheus
Service Discovery in PrometheusService Discovery in Prometheus
Service Discovery in PrometheusOliver Moser
 
Helm - the Better Way to Deploy on Kubernetes - Reinhard Nägele - Codemotion...
 Helm - the Better Way to Deploy on Kubernetes - Reinhard Nägele - Codemotion... Helm - the Better Way to Deploy on Kubernetes - Reinhard Nägele - Codemotion...
Helm - the Better Way to Deploy on Kubernetes - Reinhard Nägele - Codemotion...Codemotion
 
Virtualization Technology Overview
Virtualization Technology OverviewVirtualization Technology Overview
Virtualization Technology OverviewOpenCity Community
 
Gardener: Managed Kubernetes on Your Terms
Gardener: Managed Kubernetes on Your TermsGardener: Managed Kubernetes on Your Terms
Gardener: Managed Kubernetes on Your TermsSAP HANA Cloud Platform
 
Load Balance with NSX-T.pptx
Load Balance with NSX-T.pptxLoad Balance with NSX-T.pptx
Load Balance with NSX-T.pptxDhruv Sharma
 
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...Simplilearn
 
Top 10 reasons to migrate to Gradle
Top 10 reasons to migrate to GradleTop 10 reasons to migrate to Gradle
Top 10 reasons to migrate to GradleStrannik_2013
 
SOLID principles with Typescript examples
SOLID principles with Typescript examplesSOLID principles with Typescript examples
SOLID principles with Typescript examplesAndrew Nester
 
Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기
Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기
Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기KyeongmanKang
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansibleGeorge Shuklin
 
How to store large binary files in git repositories
How to store large binary files in git repositoriesHow to store large binary files in git repositories
How to store large binary files in git repositoriesMatt Aunger
 
191221 unreal engine 4 editor 확장하기
191221 unreal engine 4 editor 확장하기191221 unreal engine 4 editor 확장하기
191221 unreal engine 4 editor 확장하기KWANGIL KIM
 
Apache CloudStack Architecture by Alex Huang
Apache CloudStack Architecture by Alex HuangApache CloudStack Architecture by Alex Huang
Apache CloudStack Architecture by Alex Huangbuildacloud
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done rightDan Vaida
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android Arvind Devaraj
 
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육Ji-Woong Choi
 

La actualidad más candente (20)

Jacob Marble [InfluxData] | Observability with InfluxDB IOx and OpenTelemetry...
Jacob Marble [InfluxData] | Observability with InfluxDB IOx and OpenTelemetry...Jacob Marble [InfluxData] | Observability with InfluxDB IOx and OpenTelemetry...
Jacob Marble [InfluxData] | Observability with InfluxDB IOx and OpenTelemetry...
 
OpenGL SC 2.0 Quick Reference
OpenGL SC 2.0 Quick ReferenceOpenGL SC 2.0 Quick Reference
OpenGL SC 2.0 Quick Reference
 
Service Discovery in Prometheus
Service Discovery in PrometheusService Discovery in Prometheus
Service Discovery in Prometheus
 
Helm - the Better Way to Deploy on Kubernetes - Reinhard Nägele - Codemotion...
 Helm - the Better Way to Deploy on Kubernetes - Reinhard Nägele - Codemotion... Helm - the Better Way to Deploy on Kubernetes - Reinhard Nägele - Codemotion...
Helm - the Better Way to Deploy on Kubernetes - Reinhard Nägele - Codemotion...
 
Virtualization Technology Overview
Virtualization Technology OverviewVirtualization Technology Overview
Virtualization Technology Overview
 
Gardener: Managed Kubernetes on Your Terms
Gardener: Managed Kubernetes on Your TermsGardener: Managed Kubernetes on Your Terms
Gardener: Managed Kubernetes on Your Terms
 
Load Balance with NSX-T.pptx
Load Balance with NSX-T.pptxLoad Balance with NSX-T.pptx
Load Balance with NSX-T.pptx
 
Jenkins
JenkinsJenkins
Jenkins
 
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
 
Top 10 reasons to migrate to Gradle
Top 10 reasons to migrate to GradleTop 10 reasons to migrate to Gradle
Top 10 reasons to migrate to Gradle
 
Dart workshop
Dart workshopDart workshop
Dart workshop
 
SOLID principles with Typescript examples
SOLID principles with Typescript examplesSOLID principles with Typescript examples
SOLID principles with Typescript examples
 
Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기
Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기
Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 
How to store large binary files in git repositories
How to store large binary files in git repositoriesHow to store large binary files in git repositories
How to store large binary files in git repositories
 
191221 unreal engine 4 editor 확장하기
191221 unreal engine 4 editor 확장하기191221 unreal engine 4 editor 확장하기
191221 unreal engine 4 editor 확장하기
 
Apache CloudStack Architecture by Alex Huang
Apache CloudStack Architecture by Alex HuangApache CloudStack Architecture by Alex Huang
Apache CloudStack Architecture by Alex Huang
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android
 
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육
 

Similar a Fast, deterministic, and verifiable computations with WebAssembly. WASM on the blockchain meetup, August 19', Berlin.

Fast, deterministic, and verifiable computations with WebAssembly
Fast, deterministic, and verifiable computations with WebAssemblyFast, deterministic, and verifiable computations with WebAssembly
Fast, deterministic, and verifiable computations with WebAssemblyFluence Labs
 
Java Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoValeriia Maliarenko
 
CNIT 127: Ch 8: Windows overflows (Part 2)
CNIT 127: Ch 8: Windows overflows (Part 2)CNIT 127: Ch 8: Windows overflows (Part 2)
CNIT 127: Ch 8: Windows overflows (Part 2)Sam Bowne
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkDror Bereznitsky
 
Efficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode DetectionEfficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode DetectionGeorg Wicherski
 
BlueHat v18 || Hardening hyper-v through offensive security research
BlueHat v18 || Hardening hyper-v through offensive security researchBlueHat v18 || Hardening hyper-v through offensive security research
BlueHat v18 || Hardening hyper-v through offensive security researchBlueHat Security Conference
 
Advancedperformancetroubleshootingusingesxtop 101110131727-phpapp02
Advancedperformancetroubleshootingusingesxtop 101110131727-phpapp02Advancedperformancetroubleshootingusingesxtop 101110131727-phpapp02
Advancedperformancetroubleshootingusingesxtop 101110131727-phpapp02Suresh Kumar
 
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, UkraineVladimir Ivanov
 
JVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixJVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixCodemotion Tel Aviv
 
Clr jvm implementation differences
Clr jvm implementation differencesClr jvm implementation differences
Clr jvm implementation differencesJean-Philippe BEMPEL
 
Eclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java bytecode analysis and JITEclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java bytecode analysis and JITEclipse Day India
 
blockchain-and-trusted-computing
blockchain-and-trusted-computingblockchain-and-trusted-computing
blockchain-and-trusted-computingYongraeJo
 
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...CODE BLUE
 
XenTT: Deterministic Systems Analysis in Xen
XenTT: Deterministic Systems Analysis in XenXenTT: Deterministic Systems Analysis in Xen
XenTT: Deterministic Systems Analysis in XenThe Linux Foundation
 
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld
 
New hope is comming? Project Loom.pdf
New hope is comming? Project Loom.pdfNew hope is comming? Project Loom.pdf
New hope is comming? Project Loom.pdfKrystian Zybała
 

Similar a Fast, deterministic, and verifiable computations with WebAssembly. WASM on the blockchain meetup, August 19', Berlin. (20)

Fast, deterministic, and verifiable computations with WebAssembly
Fast, deterministic, and verifiable computations with WebAssemblyFast, deterministic, and verifiable computations with WebAssembly
Fast, deterministic, and verifiable computations with WebAssembly
 
Deep hooks
Deep hooksDeep hooks
Deep hooks
 
Java Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey Kovalenko
 
CNIT 127: Ch 8: Windows overflows (Part 2)
CNIT 127: Ch 8: Windows overflows (Part 2)CNIT 127: Ch 8: Windows overflows (Part 2)
CNIT 127: Ch 8: Windows overflows (Part 2)
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own Benchmark
 
Efficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode DetectionEfficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode Detection
 
BlueHat v18 || Hardening hyper-v through offensive security research
BlueHat v18 || Hardening hyper-v through offensive security researchBlueHat v18 || Hardening hyper-v through offensive security research
BlueHat v18 || Hardening hyper-v through offensive security research
 
Jvm memory model
Jvm memory modelJvm memory model
Jvm memory model
 
Advancedperformancetroubleshootingusingesxtop 101110131727-phpapp02
Advancedperformancetroubleshootingusingesxtop 101110131727-phpapp02Advancedperformancetroubleshootingusingesxtop 101110131727-phpapp02
Advancedperformancetroubleshootingusingesxtop 101110131727-phpapp02
 
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
 
JVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixJVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, Wix
 
Clr jvm implementation differences
Clr jvm implementation differencesClr jvm implementation differences
Clr jvm implementation differences
 
Eclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java bytecode analysis and JITEclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java bytecode analysis and JIT
 
blockchain-and-trusted-computing
blockchain-and-trusted-computingblockchain-and-trusted-computing
blockchain-and-trusted-computing
 
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
 
XenTT: Deterministic Systems Analysis in Xen
XenTT: Deterministic Systems Analysis in XenXenTT: Deterministic Systems Analysis in Xen
XenTT: Deterministic Systems Analysis in Xen
 
Scale-out ccNUMA - Eurosys'18
Scale-out ccNUMA - Eurosys'18Scale-out ccNUMA - Eurosys'18
Scale-out ccNUMA - Eurosys'18
 
Understanding low latency jvm gcs
Understanding low latency jvm gcsUnderstanding low latency jvm gcs
Understanding low latency jvm gcs
 
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
 
New hope is comming? Project Loom.pdf
New hope is comming? Project Loom.pdfNew hope is comming? Project Loom.pdf
New hope is comming? Project Loom.pdf
 

Último

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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 Processorsdebabhi2
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
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)wesley chun
 
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 Scriptwesley chun
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 

Último (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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)
 
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
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Fast, deterministic, and verifiable computations with WebAssembly. WASM on the blockchain meetup, August 19', Berlin.

  • 1. Fast, deterministic, and verifiable computations with WebAssembly Mike Voronov twitter.com/@vms11
  • 2. • Open-source, decentralized cloud computing network • Charge developers for computational complexity only: no hash mining
 • WebAssembly as the platform for fast & verifiable stateful computations 2 Objectives
  • 4. What does it mean – verifiable? 4
  • 5. Problems: • nodes running the same code got different computation results • nodes got same results but claim to have spent different amounts of gas Solutions: • consensus algorithms, ZK proofs, hardware enclaves • we use verification game (a part of a special kind of consensus) 5 Verifiable computations
  • 6. • Verifier finds an incorrect state transition and opens a dispute on Ethereum • Verification game narrows the dispute to a single WebAssembly instruction • Ethereum smart contract repeats the instruction and penalizes the bad node 6 Verification game
  • 7. Execution mode: fast execution • JIT/AOT compilation is essentially mandatory • Only final state (VM memory) matters
 Dispute mode: granular execution • JIT/AOT compilation is highly desirable • Intermediate states (VM memory, stack, instruction pointer) matter too • Ability to take & load VM snapshots, stop at k-th instruction • Ability to extract the data needed to execute single instruction on Ethereum 7 Execution duality
  • 8. WebAssembly to JVM compilation 8
  • 9. • Each Wasm module is compiled to JVM class by Asmble • Both JVM and Wasm are stack-based VMs => straightforward conversion 9 WebAssembly to JVM bytecode
  • 11. 11 Conversion table WebAssembly JVM Bytecode {i32, i64, f32, f64} –> {int, long, float, double} Wasm module –> JVM class Wasm function –> JVM function Wasm memory –> ByteBuffer global variables –> Class fields calls –> invoke{Exact | virtual | dynamic}
  • 14. 14 Dispute resolution: k-ary search • Need to record in Ethereum virtual machine state on every search step • Need to find the instruction which was executed differently: 😇 VMp–1 = 👿 VMp–1 😇 VMp ≠ 👿 VMp • Then, need to send this instruction along with required data to Ethereum
  • 15. 15 Virtual machine state Need to track: • memory • stack • globals • instruction pointer (ip) • executed instructions counter (eic) • used gas
  • 16. Need to collapse all the required data into a single record Need to generate proofs for: • memory chunks and stack frames • instruction pointer and executed instructions counter • used gas HVM = hash(Hmem, Hstack, Hip, Heic, Hgas) Hmem = merkle(memory) ... Hgas = hash(gas) 16 VM state hash
  • 17. Standard Merkle hash: • needs to rehash the entire memory region even if only a single byte was changed • is not optimal for multiple computations during k-ary search • is not optimal for large-scale state updated by simple request processing code 17 Linear memory hash
  • 18. Idea: • track memory chunks that were made dirty 
 during the state transition VMi => VMi+1 • once the state transition is complete, all chunks are clean again • store a cache of intermediate hashes in the Merkle tree • when requested, recompute hashes (including Merkle root) on dirty paths only 18 Incremental memory hash
  • 19. Algorithmic complexity: • need to recompute the dirty chunk hash • need to recompute all hashes on the dirty path O(chunk_size + hash_size * log(total_chunks)) 
 Additional memory usage: • dirty chunks bitmap index: 1 MB • tree hashes cache: 2 * 32 * 10242 = 64 MB 19 Incremental hash: complexity memory = 4 GB, chunk = 4 KB, hash = 32 B
  • 20. 20 Attack: malicious code updates 1 byte in each memory chunk How much should we charge? The node had to rehash the 
 entire 4 GB memory, but the code has written just 1 MB. Solution: charge fixed price for each chunk that was dirtied algorithms taking into account page caching should not be hurt too much Incremental hash: gas usage
  • 21. Normally, WebAssembly stack is implicitly supported by the JVM stack However, there is no easy way to access JVM stack data Stack emulation can be used to retrieve values from the WebAssembly stack 21 Shadow stack
  • 24. Bottomline Computation machine has execution duality: Normal mode: - EIC - gas - merkle hash of the final state Dispute mode: - EIC - gas - merkle hash of the final state - shadow stack 24
  • 26. • External function calls • VM resource exhaustion • NaN floating point payloads https://dl.acm.org/citation.cfm?doid=3062341.3062363 26 Non-determinism sources in Wasm
  • 27. Our approach: • at now, on the testnet imports from the host environment are not allowed • to obtain persistence, WebAssembly memory is backed to disk by the host system 27 External function calls We are working on supporting of a subset of the WASI syscalls: 
 for example – time, filesystem, random number generation operations
  • 28. Our approach: • developer configures desired memory and stack size • allocation of all dynamic Wasm parts (heap, stack, table) is performed at the virtual machine initialization • grow_memory always returns –1 28 VM resource exhaustion
  • 29. NaN (not-a-number) – is a special type of a floating-point value 29 NaN payloads
  • 30. Popular platforms have different behavior regarding NaNs
 New NaN value: • x86 – NaN with the sign bit set • ARM and others – produce with it unset 
 Operations with multiple NaN inputs: • x86 – first NaN input • ARMv8 – NaN depending on the signaling and quiet state 
 some hardware architectures prefer to return a NaN with a fixed bit pattern 30 NaN payloads
  • 31. 31 NaN payloads Any arithmetical operations with NaNs produce NaNs
  • 32. 32 NaN payloads Idea: instrument all floating-point operations – convert non-canonical NaNs into canonical NaNs Better idea: instrument only those operations that transfer floating-point values outside of the floating-point domain
 Outside transfer operations: • {f32,f64}.reinterpret_{i32,i64} – converts float value to integer • {f32,f64}.store – stores float value to the linear memory • copysign – copies the sign bit into a non-NaN value
  • 33. Bottomline To obtain deterministic WebAssembly execution, we: • block syscalls (in the future: provide a subset of deterministic syscalls) • preallocate all dynamic resources • use the canonical NaN pattern when transferring floats outside 33
  • 34. Few words about Fluence 34
  • 35. 35 Fluence: hybrid security approach Speed layer On-demand database (Redis/SQLite) clusters Security layer DB transaction history validation for 
 the entire network Data availability layer DB transaction history storage in Swarm/Filecoin Dispute resolution layer Verification game with Ethereum as the final judge
  • 36. Speed layer • Ethereum holds the registry of deployed databases • Consensus-based (BFT) replication between nodes • Direct frontend <–> database interaction • TX history is uploaded to Swarm/Filecoin
 Tendermint WebAssembly 36
  • 37. Security layer Composition: • TX history is verified segment by segment • Segments are sequentially verified by several validators Validators: • Are randomly selected from the shared network pool • Verify that preceding validations were autonomous • Do not know if there will be a subsequent validation 37
  • 38. 38