SlideShare a Scribd company logo
Verifying offchain
computations using TrueBit
Sami Mäkelä
Onchain computation
● To execute smart contracts, we have to have a way to perform trusted
computations
● Blocks include transactions
● Every full node executes all transactions
● So miners will have to be honest, or their blocks are rejected
Problems with increasing the limit
● Currently 6Mgas available for each block
● For example too little to be able to compute scrypt hash
● If the computations are too long, nobody will have time to check them
● Other problem is that if the computations become costly, perhaps eventually
the miners will try to save by making incorrect computations
● There are over 20000 nodes, so when you make a transaction, you are
buying a lot of computation power
● Longer computations in current Ethereum blockchain could be very expensive
TrueBit
● Computations can be done offchain
● But they can still guaranteed to be correct
● Examples of verifying offchain computations
● Square root
● Ordered list
● Any computation
Square root
● For some reason our smart contract has to know square root of variable N
● Instead computing it, calculate it offchain, and verify it in the smart contract
● √N*√N<= N && N < (1+√N)*(1+√N)
Ordered list
● The complexity of maintaining and ordered data structure is O(log(N)) per
operation
● For example a balanced tree might be complex to implement
● Use linked list, calculate offchain to after which cell the new value should be
inserted
Example
12 at
0xf382
34 at
0xa424
132 at
0x1357
64 at
0x627e
Any computation?
● Any computation can for example represented as bytecode or the merkle root
of the byte code
● Then there is the input
● How can we verify that a given output is the result of the computation?
● The bytecode and input are passed to the TrueBit contract
● TrueBit will return verified output
Solvers and verifiers
● There are two kinds of tasks that are needed for the system to operate
● Solving a task: post a solution for the task
● Verifying a task: check if the posted solution is correct
● If the solution is incorrect, verifier can challenge it
● Not all Ethereum nodes have to compute everything, because it can be
assumed that small fraction of nodes will be enough to produce fraud proofs
Basic idea
● Computations can be divided into simple steps or state transitions
● Each state has a deterministic next state
● Only a small amount of data is needed to calculate the next state (Merkle
trees)
● Each transition can be verified onchain
0xacb..23 0xcab..31 0xa2b..f3 0x5cb..62 0x4cb..25
Binary search and judges
● Everybody agrees on the initial state
● Solvers and verifiers can use interactive protocol to find the first state where
they disagree (binary search)
● This state can then be posted to a smart contract that can determine what is
the next state (judges)
Example (binary search)
1 2 3 4 5 6 7 8 9 10
1 2 3 6 7 8 9 10 11 12
13
2
Different results
Judge will check the transition from 3rd
state to 4th state
Example of judging (memory access)
1. Check correctness of machine state wrt. hash
2. Check if the opcode is actually a memory access opcode
3. Check what is the value of the memory cell in the position given by the
address register
4. Write the value to register
5. Calculate new root hash
Machine state (simplified)
Op code: LOAD R1: 3 R2: 0 Mem: 0x234..123 PC: 2
123 234 543 23 45 56 23 554
h(123,234) h(543,23) h(45,56) h(23,554)
Forced errors
● Verifiers can be rewarded from finding errors
● To incentivise the verifiers, there has to be errors that they can find
● If the probability of errors is too low, the expected return for verifiers is
negative
● Some tasks will be randomly selected to have a “forced error”, where the
solver will have to post a wrong solution
● The verifiers that detect this error will get a special reward
● This ensures that it is profitable to run verifiers
Practical details
Show demo concept
WebAssembly
● Basically a generic compilation target like LLVM bitcode
● Can be efficiently ran using JIT compilers
● Intended for web applications, for example games
● For interpreters, there are some challenges
Emscripten and filesystem
● Emscripten is the system that is used to compile from C (or some other
language) to WebAssembly
● Emscripten has runtime written in JavaScript
● So for TrueBit we need our own runtime
● Some kind of access to files etc.
● The file system represents the input and output for the task
TrueBit VM
● Simple to convert from WebAssembly (most instructions are the same)
● Special instructions for handling file system
● Efficient to interpret
● Can output merkle roots (hashes) of intermediate states
● Can generate the proofs needed for judges
What kind of computations can be verified
● Hardest part is getting the programs to compile
● After that, basically any program can be first ran locally, and then it can be
posted into TrueBit for verification
● Nondeterministic system calls like “gettimeofday” can just be recorded and
replayed to make the computation deterministic
Offchain data
● IPFS, Swarm, etc.
● Because of hashes, in principle the programs can safely refer to IPFS
● Data availability problem
Example applications
● DogEth: scrypt for Ethereum
● Other more complicated cryptographic algorithms
● Machine learning
● Data markets
● Solidity compiler
● General scaling
http://truebit.io/

More Related Content

PDF
FastBFT
PDF
PDF
Omni ledger
PDF
PDF
Honeybadger of BFT Protocols
PDF
Ekiden
PDF
Design of a secure "Token Passing" protocol
PPTX
Diagnosing HotSpot JVM Memory Leaks with JFR and JMC
FastBFT
Omni ledger
Honeybadger of BFT Protocols
Ekiden
Design of a secure "Token Passing" protocol
Diagnosing HotSpot JVM Memory Leaks with JFR and JMC

What's hot (20)

PPTX
Distributed Transaction Management in Spring & JEE
PPTX
Building a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
PPTX
The paxos commit algorithm
PPT
Os module 2 c
PDF
SemFuzz: Semantics-based Automatic Generation of Proof-of-Concept Exploits
PPT
16. Concurrency Control in DBMS
PPTX
OmniLedger
PPTX
Transaction and concurrency control
PPTX
Mutual Exclusion using Peterson's Algorithm
PPTX
Operating system critical section
PPTX
Process synchronization
PDF
6 Synchronisation
DOCX
Critical section operating system
PDF
Deep dive into LibraBFT consensus
PPT
Peterson Critical Section Problem Solution
PPTX
Process synchronization
PDF
Lecture 5 process synchronization
PPTX
Concurrency control PPT
PPTX
Concurrency control
PPTX
Concurrency control
Distributed Transaction Management in Spring & JEE
Building a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
The paxos commit algorithm
Os module 2 c
SemFuzz: Semantics-based Automatic Generation of Proof-of-Concept Exploits
16. Concurrency Control in DBMS
OmniLedger
Transaction and concurrency control
Mutual Exclusion using Peterson's Algorithm
Operating system critical section
Process synchronization
6 Synchronisation
Critical section operating system
Deep dive into LibraBFT consensus
Peterson Critical Section Problem Solution
Process synchronization
Lecture 5 process synchronization
Concurrency control PPT
Concurrency control
Concurrency control
Ad

Similar to Verifying offchain computations using TrueBit. Sami Makela (20)

PDF
Presentation
PPTX
Best practices to build secure smart contracts
PDF
Stefano Maestri - Why Ethereum and other blockchains are going to Proof of St...
PDF
Computer network (8)
PDF
Blockchain Programming
PPTX
VXCON 2017
ODP
Blockchan For Developers
PPTX
9-Operating Systems -Synchronization, interprocess communication, deadlock.pptx
ODP
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
PDF
Ethereum-Cryptocurrency (All about Ethereum)
PPTX
synchronization in operating system structure
PDF
blockchain-and-trusted-computing
PDF
Blockchain and smart contracts, what they are and why you should really care ...
PDF
Higher Level Malware
PPTX
Building real time Data Pipeline using Spark Streaming
PPTX
BSides LV 2016 - Beyond the tip of the iceberg - fuzzing binary protocols for...
ODP
Proof-of-Stake & Its Improvements (San Francisco Bitcoin Devs Hackathon)
PDF
Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)
PDF
Transactions in Action: the Story of Exactly Once in Apache Kafka
PPTX
Lecture 5- Process Synchronization (1).pptx
Presentation
Best practices to build secure smart contracts
Stefano Maestri - Why Ethereum and other blockchains are going to Proof of St...
Computer network (8)
Blockchain Programming
VXCON 2017
Blockchan For Developers
9-Operating Systems -Synchronization, interprocess communication, deadlock.pptx
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Ethereum-Cryptocurrency (All about Ethereum)
synchronization in operating system structure
blockchain-and-trusted-computing
Blockchain and smart contracts, what they are and why you should really care ...
Higher Level Malware
Building real time Data Pipeline using Spark Streaming
BSides LV 2016 - Beyond the tip of the iceberg - fuzzing binary protocols for...
Proof-of-Stake & Its Improvements (San Francisco Bitcoin Devs Hackathon)
Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)
Transactions in Action: the Story of Exactly Once in Apache Kafka
Lecture 5- Process Synchronization (1).pptx
Ad

More from Cyber Fund (20)

PPTX
Разработка на блокчейн Голос | Ерлан Шиндаулетов
PPTX
Mesh-сети - интернет, который мы заслужили. Матвей Сиворакша
PPTX
Продукты и сервисы на блокчейне биткоина. Спикер: Алексей Карпов
PPTX
Blockchain wallet Multy
PDF
Практические кейсы использования приватных блокчейнов на EXONUM. Спикер: Глеб...
PDF
Onchain масштабирование блокчейна. Спикер: Дмитрий Мешков
PDF
Анонимизация и деанонимизация пользователей в блокчейн-сетях. Спикер: Григори...
PDF
Оракулы для блокчейнов. Обзор платформы Exonum. Спикер: Алексей Сидоров
PDF
CyberSearch: The Blockchain Browser. Valery Litvin
PDF
The Melon security approach. Reto Trinkler
PDF
The censorship resistance. Andrey Sobol
PDF
End-to-end encryption for Dapps with NuCypher KMS. Sergey Zotov, software dev...
PDF
Creating CI/ CD infrastructure for open source projects. Denis Soldatov, dev-...
PDF
Rust & Web Assembly
PDF
Будущее блокчейн. Спикер: Владимир Попов
PDF
Почему децентрализованные биржи ближе чем нам кажется. Андрей Соболь
PDF
Новеллы в законодательстве. Спикер: Алексей Воробей
PDF
Перспективы технологии и философии. Спикер: Владимир Попов
PDF
Использование открытых данных блокчейн . Спикер: Александр Давыдов.pptx
PDF
Lightning — текущий статус разработок. Спикер: Панков Александр.odp
Разработка на блокчейн Голос | Ерлан Шиндаулетов
Mesh-сети - интернет, который мы заслужили. Матвей Сиворакша
Продукты и сервисы на блокчейне биткоина. Спикер: Алексей Карпов
Blockchain wallet Multy
Практические кейсы использования приватных блокчейнов на EXONUM. Спикер: Глеб...
Onchain масштабирование блокчейна. Спикер: Дмитрий Мешков
Анонимизация и деанонимизация пользователей в блокчейн-сетях. Спикер: Григори...
Оракулы для блокчейнов. Обзор платформы Exonum. Спикер: Алексей Сидоров
CyberSearch: The Blockchain Browser. Valery Litvin
The Melon security approach. Reto Trinkler
The censorship resistance. Andrey Sobol
End-to-end encryption for Dapps with NuCypher KMS. Sergey Zotov, software dev...
Creating CI/ CD infrastructure for open source projects. Denis Soldatov, dev-...
Rust & Web Assembly
Будущее блокчейн. Спикер: Владимир Попов
Почему децентрализованные биржи ближе чем нам кажется. Андрей Соболь
Новеллы в законодательстве. Спикер: Алексей Воробей
Перспективы технологии и философии. Спикер: Владимир Попов
Использование открытых данных блокчейн . Спикер: Александр Давыдов.pptx
Lightning — текущий статус разработок. Спикер: Панков Александр.odp

Recently uploaded (20)

PDF
Hybrid model detection and classification of lung cancer
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
The various Industrial Revolutions .pptx
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
Tartificialntelligence_presentation.pptx
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
TLE Review Electricity (Electricity).pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
Hybrid model detection and classification of lung cancer
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
O2C Customer Invoices to Receipt V15A.pptx
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Chapter 5: Probability Theory and Statistics
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Getting Started with Data Integration: FME Form 101
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
The various Industrial Revolutions .pptx
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Module 1.ppt Iot fundamentals and Architecture
Tartificialntelligence_presentation.pptx
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
A novel scalable deep ensemble learning framework for big data classification...
Zenith AI: Advanced Artificial Intelligence
Enhancing emotion recognition model for a student engagement use case through...
Hindi spoken digit analysis for native and non-native speakers
TLE Review Electricity (Electricity).pptx
NewMind AI Weekly Chronicles - August'25-Week II

Verifying offchain computations using TrueBit. Sami Makela

  • 2. Onchain computation ● To execute smart contracts, we have to have a way to perform trusted computations ● Blocks include transactions ● Every full node executes all transactions ● So miners will have to be honest, or their blocks are rejected
  • 3. Problems with increasing the limit ● Currently 6Mgas available for each block ● For example too little to be able to compute scrypt hash ● If the computations are too long, nobody will have time to check them ● Other problem is that if the computations become costly, perhaps eventually the miners will try to save by making incorrect computations ● There are over 20000 nodes, so when you make a transaction, you are buying a lot of computation power ● Longer computations in current Ethereum blockchain could be very expensive
  • 4. TrueBit ● Computations can be done offchain ● But they can still guaranteed to be correct ● Examples of verifying offchain computations ● Square root ● Ordered list ● Any computation
  • 5. Square root ● For some reason our smart contract has to know square root of variable N ● Instead computing it, calculate it offchain, and verify it in the smart contract ● √N*√N<= N && N < (1+√N)*(1+√N)
  • 6. Ordered list ● The complexity of maintaining and ordered data structure is O(log(N)) per operation ● For example a balanced tree might be complex to implement ● Use linked list, calculate offchain to after which cell the new value should be inserted
  • 7. Example 12 at 0xf382 34 at 0xa424 132 at 0x1357 64 at 0x627e
  • 8. Any computation? ● Any computation can for example represented as bytecode or the merkle root of the byte code ● Then there is the input ● How can we verify that a given output is the result of the computation? ● The bytecode and input are passed to the TrueBit contract ● TrueBit will return verified output
  • 9. Solvers and verifiers ● There are two kinds of tasks that are needed for the system to operate ● Solving a task: post a solution for the task ● Verifying a task: check if the posted solution is correct ● If the solution is incorrect, verifier can challenge it ● Not all Ethereum nodes have to compute everything, because it can be assumed that small fraction of nodes will be enough to produce fraud proofs
  • 10. Basic idea ● Computations can be divided into simple steps or state transitions ● Each state has a deterministic next state ● Only a small amount of data is needed to calculate the next state (Merkle trees) ● Each transition can be verified onchain 0xacb..23 0xcab..31 0xa2b..f3 0x5cb..62 0x4cb..25
  • 11. Binary search and judges ● Everybody agrees on the initial state ● Solvers and verifiers can use interactive protocol to find the first state where they disagree (binary search) ● This state can then be posted to a smart contract that can determine what is the next state (judges)
  • 12. Example (binary search) 1 2 3 4 5 6 7 8 9 10 1 2 3 6 7 8 9 10 11 12 13 2 Different results Judge will check the transition from 3rd state to 4th state
  • 13. Example of judging (memory access) 1. Check correctness of machine state wrt. hash 2. Check if the opcode is actually a memory access opcode 3. Check what is the value of the memory cell in the position given by the address register 4. Write the value to register 5. Calculate new root hash
  • 14. Machine state (simplified) Op code: LOAD R1: 3 R2: 0 Mem: 0x234..123 PC: 2 123 234 543 23 45 56 23 554 h(123,234) h(543,23) h(45,56) h(23,554)
  • 15. Forced errors ● Verifiers can be rewarded from finding errors ● To incentivise the verifiers, there has to be errors that they can find ● If the probability of errors is too low, the expected return for verifiers is negative ● Some tasks will be randomly selected to have a “forced error”, where the solver will have to post a wrong solution ● The verifiers that detect this error will get a special reward ● This ensures that it is profitable to run verifiers
  • 18. WebAssembly ● Basically a generic compilation target like LLVM bitcode ● Can be efficiently ran using JIT compilers ● Intended for web applications, for example games ● For interpreters, there are some challenges
  • 19. Emscripten and filesystem ● Emscripten is the system that is used to compile from C (or some other language) to WebAssembly ● Emscripten has runtime written in JavaScript ● So for TrueBit we need our own runtime ● Some kind of access to files etc. ● The file system represents the input and output for the task
  • 20. TrueBit VM ● Simple to convert from WebAssembly (most instructions are the same) ● Special instructions for handling file system ● Efficient to interpret ● Can output merkle roots (hashes) of intermediate states ● Can generate the proofs needed for judges
  • 21. What kind of computations can be verified ● Hardest part is getting the programs to compile ● After that, basically any program can be first ran locally, and then it can be posted into TrueBit for verification ● Nondeterministic system calls like “gettimeofday” can just be recorded and replayed to make the computation deterministic
  • 22. Offchain data ● IPFS, Swarm, etc. ● Because of hashes, in principle the programs can safely refer to IPFS ● Data availability problem
  • 23. Example applications ● DogEth: scrypt for Ethereum ● Other more complicated cryptographic algorithms ● Machine learning ● Data markets ● Solidity compiler ● General scaling