intro to truebit

24
Intro to TrueBit yaohsin https://medium.com/@ yaohsin 2017-12-19

Upload: yao-hsin-chen

Post on 17-Mar-2018

113 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Intro to TrueBit

Intro to TrueBit

yaohsin

https://medium.com/@yaohsin

2017-12-19

Page 2: Intro to TrueBit
Page 3: Intro to TrueBit

TrueBit的定位

Web 2.0 Web3 (dApps)

File storage Amazon S3 IPFS/Filecoin

External data 3rd party API Oracles

Payments Credit Card, Paypal Raiden

Network Performance bandwidth, SDN Sharding, Plasma

Computation Amazon EC2 TrueBit

Page 4: Intro to TrueBit

Ethereum is a Turing-Complete World Computer

•充滿無限想像的Smart contracts.• Big data

• AI

• Deep learning

• Solidity source code verification

•唯一的限制是你的想像力.• CryptoKitties

Page 5: Intro to TrueBit

But, 現實是殘酷的

• Ethereum有gasLimit限制

• gasLimit為每個區塊可容納gas數量的最大值

•目前大約8M gas per block

•不過依然不足以執行複雜的運算

•如何改善?

Page 6: Intro to TrueBit

idea#1 取消gasLimit限制

•沒有gasLimit的新世界,使用者可以發出大交易

大交易

$$$$?

有很多的手續費

Page 7: Intro to TrueBit

驗證者的困境

• The Verifier‘s Dilemma

•理性的礦工看到大交易,會有兩種思考層次

1. 驗證大交易太耗時,不利於挖礦競爭不驗證

2. 若其他人都驗證大交易,我就挖錯鏈了驗證

•礦工不知所措!!

Page 8: Intro to TrueBit

idea#2 將運算放到鏈下(off-chain)

• task-giver發出一個運算任務

•多個worker在鏈下算出答案以獲取報酬

•以多數人的結果為最佳解

Task-giverContract

T

S

S

S

SSSS

S

SS

T

S

我們可以做得更好嗎?

T

T

T

TT

Page 9: Intro to TrueBit

TrueBit – the verification game

目標

•任何人都可以提出一個運算任務,並提供報酬

•任何人都可以送出運算結果,來換取報酬

•任何人指的是合約或使用者

• TrueBit保證結果的正確性!!

系統假設

• smart contract永遠不會出錯

•參與者都是理性的(追求最大利益)

Page 10: Intro to TrueBit

TrueBit特色

•運算結果可以被挑戰進入verification game

•誠實的人總是可以贏得挑戰

•網路中只要有一個誠實的人就可確保運算結果是正確的(99% attack)

•達到一致性的共識

Page 11: Intro to TrueBit

TrueBit角色

• Task-giver –發起運算任務,附上獎勵

• Solver –執行運算任務,並提交結果

• Verifier –挑戰Solver運算結果的正確性

• Judges –有限運算能力的仲裁者,確認最終運算結果

computation result You’re wrong

Let’s play the verification gameSolver Verifier

Judges

Page 12: Intro to TrueBit

*找出分歧點

•運算可以拆分成一系列的步驟及狀態轉換

•雙方運算出每一個步驟的merkle tree,並且提交給某些root給Judges

•使用binary search O(logN)

step 1 2 3 4 5 6 7 8 9 10

solver input 0x1234 0xac12 0x57ab 0x4395 0x6646 0x8561 0xc477 0x9837 0x3e45

verifier input 0x1234 0xac12 0x7591 0x9746 0x8332 0xa758 0xd854 0x1288 0x86ae

1

2

3

Judge只需要重複step3 step4的運算

Page 13: Intro to TrueBit

TrueBitContract

T S

T

T

T

T

TS

T

T

S

S

step 1 1,000,000

Judge判決log(1,000,000) ~= 20

輸家會被處罰

• 產生task

• solver執行

• 回報結果

• verifier檢查結果

• 進行game

• Judge判決

S

S S

S

• 隨機挑選solver

S

• 結論

Page 14: Intro to TrueBit

預期結果

•若系統一定存在verifier solver不敢囂張,乖乖給出正確答案

•長久下來,甚至可以完全不需要進行 interactive verification game

Page 15: Intro to TrueBit

問題:Verifier’s Dilemma

•雖然系統只需要一個verifier,但要如何確保他一定會存在

• Verifier找到bug 獲得獎勵

• Solver給出錯誤答案被懲罰

•時間一久 Solver都給正確答案 Verifier無利可圖系統崩潰

Page 16: Intro to TrueBit

解法:Forced Errors

•隨機插入forced errors

•系統付錢給solver隨機產生forced errors

• verifier發現forced errors獲得報酬

•出現forced errors solver不會被懲罰

Page 17: Intro to TrueBit

TrueBitContract

T

T

T

T

T

TS

T

T

E

S

step 1 1,000,000

Judge判決

若沒進入verification game verifier會被懲罰

• 產生task

• solver執行

• 回報結果

• Judge判決

S E

S E S EE

S• forced error?

verifier & solver都有獎勵

• verifier檢查結果

• 進行game

forced error?

• 隨機挑選solver

• 正反兩種答案

S

• 結論

Page 18: Intro to TrueBit

如何決定forced errors

•由random bits決定

•系統需確保下列特性,以達到不可預測• Task giver在產生task時,不知道random bits

• Solver不知道random bits,直到他送出solution

• Verifiers不知道random bits,直到他決定發起挑戰

• random bits由下列兩項來源計算得來• Solver選擇一個private random bits

• Solver送出solution之後的下一個block header

Page 19: Intro to TrueBit

block 0x1234

Solver

h(private randombit)

private random bits

block 0xabcd

error

solution

Task Giver

task

task

block 0x4534

h(error)

h(solution)

block 0x9fe3

block header

random bits = h( , )private-bit block header

依據random bits,選擇要公開哪個答案

timeout 公開 private random bitschallenge 公開private random bits & correct solution

Verifier

Page 20: Intro to TrueBit

TrueBit系統架構TrueBit Virtual Machine (TVM)

Page 21: Intro to TrueBit

Security Defenses

• Pairwise sybil attacks

• The trifecta

• Collusion pools

• On low-hanging fruit

• A cash equivalence problem

Page 22: Intro to TrueBit

各式應用

Page 23: Intro to TrueBit

Livepeer

將TrueBit當成可以外包computation的Oracle且保證結果一定正確

Page 24: Intro to TrueBit

https://truebit.io/