Submit Search
Upload
Inside casper
•
6 likes
•
2,889 views
zigen
Follow
Blockchain.tokyo #8 Casper FFG読んでみた話
Read less
Read more
Engineering
Report
Share
Report
Share
1 of 75
Download now
Download to read offline
Recommended
秋のVim祭り Rubyを添えて
秋のVim祭り Rubyを添えて
Yuta Ogura
Linux kernelsourcearchaeologywithgit public_20120130
Linux kernelsourcearchaeologywithgit public_20120130
Etsuji Nakai
Nmapの真実(ゾクゾク)
Nmapの真実(ゾクゾク)
Keigo Yamazaki
Rxに入門しようとしている
Rxに入門しようとしている
onotchi_
「Dockerはいいぞ」 for Laboratory LT
「Dockerはいいぞ」 for Laboratory LT
ShimpeiIwamaru
C#次世代非同期処理概観 - Task vs Reactive Extensions
C#次世代非同期処理概観 - Task vs Reactive Extensions
Yoshifumi Kawai
コンテナ情報交換会2
コンテナ情報交換会2
Masahide Yamamoto
Swift on Docker
Swift on Docker
sinsoku listy
Recommended
秋のVim祭り Rubyを添えて
秋のVim祭り Rubyを添えて
Yuta Ogura
Linux kernelsourcearchaeologywithgit public_20120130
Linux kernelsourcearchaeologywithgit public_20120130
Etsuji Nakai
Nmapの真実(ゾクゾク)
Nmapの真実(ゾクゾク)
Keigo Yamazaki
Rxに入門しようとしている
Rxに入門しようとしている
onotchi_
「Dockerはいいぞ」 for Laboratory LT
「Dockerはいいぞ」 for Laboratory LT
ShimpeiIwamaru
C#次世代非同期処理概観 - Task vs Reactive Extensions
C#次世代非同期処理概観 - Task vs Reactive Extensions
Yoshifumi Kawai
コンテナ情報交換会2
コンテナ情報交換会2
Masahide Yamamoto
Swift on Docker
Swift on Docker
sinsoku listy
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
More Related Content
Featured
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Featured
(20)
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
Skeleton Culture Code
Skeleton Culture Code
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Inside casper
1.
Inside Casper 2018 5/24
Blockchain.tokyo #8 zigen
2.
Zigen ● 酒飲みながらコード書きます ● Github
@zigen ● Twitter @kei_0811 ● Web Frontend ○ JS, React , ReactNative ● Blockchain初心者 ○ もうすぐ3ヶ月目!!
3.
What’s Casper? 1. Proof
of Stake-based Finality 2. Overlays on Proof of Work block proposal mechanism
4.
New Fork Choice
Rule
5.
用語 ● Source ● Target ●
Supermajority Link ● Justified ● Finalized ● Validators ● Vote ● Dynasty ● Epoch
6.
block1 block3 block2 block4 block5 block6 時間 t 上にいくほど新しい block n
は block n-1 を参照している
7.
1 3 2 4 5 6 時間 t 4b 5b 6b 6c 3b 4c 5 6d どのブロックからでも分岐できる
8.
0 1 48 時間 t Checkpoint49 50 Epoch n Length:
50 Epoch n + 1
9.
1 3 2 4 99 100 時間 t 4b 99b 100b 100d 3b 4c 99c 100c 4つのcheckpointがある
10.
1 100 時間 t 100b 100d100c 普通のblockを省略 このcheckpointだけの表示を subtreeと呼ぶ
11.
r 100 時間 t 100b 100d Source Targe t
12.
Root 100 100b 100d Validators
13.
Root 100 100b 100d Vote
14.
Root 100 100b 100d Vote Supermajority
Link
15.
Root 100 100b 100d Supermajority
Link Justified
16.
Root 100 100b 100dJustified 100
100b 100d Vote
17.
Root 100 100b 100dJustified 100
100b 100d Vote Supermajority Link
18.
Root 100 100b 100d Justified 100
100b 100d Supermajority Link
19.
Root 100 100b 100d Justified 100
100b 100d Supermajority Link Finalized
20.
Root 100 100b 100d Justified 100
100b 100d Cannot Revert!!! Finalized
21.
Implementations 1. Casper Contract
ethereum/casper.git 6a171e1 2. Pythapp karlfloersch/pyethapp#dev_envd1a5d1f 3. Pyethereum ethereum/pythereum.git 3d5ec14 4. Parity paritytech/parity.git#casper 9c51885
22.
Roles ● Casper Contract
simple_casper.v.py ● Miner ● Validator validator_service.py
23.
Implementations 1. Casper Contract
ethereum/casper.git 6a171e1 2. Pythapp karlfloersch/pyethapp#dev_envd1a5d1f 3. Pyethereum ethereum/pythereum.git 3d5ec14 4. Parity paritytech/parity.git#casper 9c51885
24.
Step 1. Initial: Deploy
simple_casper.v.py 2. Miner: Initialize casper metadata of node 3. Validator: Deposit 4. Validator: Vote/Slash 5. Miner: Accept Block
25.
Implementations 1. Casper Contract ●
Written in Vyper ● As Smart Contract
26.
Casper Contract validators Decimal????
27.
Casper Contract parameters
28.
Casper Contractを叩くまでの壁 1. Vyper 2.
Serpent 3. Decimal
29.
Vyper (the former
Viper) ethereum/vyper.git ● New Experimental Language ● Simple, Secure, Readable ● Alternative to Solidity ● *.v.py
30.
Casper Contractを叩くまでの壁 1. Vyper $pip
install vyper すると casperのコンパイルがこける $pip3 install -r requirements.txt しよう 結構な人がハマってた
31.
Casper Contractを叩くまでの壁 2. Serpent MSG_HASHERと PURITY_CHECKERは Serpent製 Casper
Contractをinitするときにこの二つの Contract Addressを渡す
32.
Casper Contractを叩くまでの壁 3. Decimal なお,
ABIのspecにはdecimalは存在しない
33.
Casper Contractを叩くまでの壁 3. Decimal なお,
ABIのspecにはdecimalは存在しない
34.
Casper Contractを叩くまでの壁 3. Decimal でもなぜethereum/casperのテストでは vyperコンパイルが通るのか?
35.
Casper Contractを叩くまでの壁 3. Decimal
36.
Casper Contractを叩くまでの壁 3. Decimal abi.pyをみてみると https://github.com/ethereum/pyethereum/blob/develop/ethereum/abi.py#L315-L318
37.
Casper Contractを叩くまでの壁 3. Decimal 1年前からある... https://github.com/ethereum/pyethereum/commit/b4dcb30fc96ce0b462b6ddfcaa3db4432e2ce200
38.
Casper Contractを叩くまでの壁 3. Decimal pythereumでしか動かないので ethereum/vyperにissueが上がってた https://github.com/ethereum/vyper/issues/566
39.
Casper Contractを叩くまでの壁 3. Decimal https://github.com/ethereum/vyper/issues/566#issuecomment-389851829
40.
Casper Contract validators
41.
Casper Contract checkpoints
42.
Init L126~ ● デプロイ後1回だけ ●
パラメータ与えて 初期化していく ● とくに難しいことはない
43.
initialize_epoch L468~ ● デプロイ後1回だけ ●
パラメータ与えて 初期化していく ● とくに難しいことはない
44.
initialize_epoch L468~
45.
initialize_epoch L425~ ● 各epochが始まるたびに誰かが叩いて更新する ●
Penalty factorなどの調整をするキモの部分
46.
deposit L465~ ● Validatorとして登録される ●
Depositが十分かどうか? ● validator_indexをincrement
47.
deposit validation_addrのチェック ● 'xa1x90x3exab'
はPURITY_CHECKERのmethod ● keccak256(“submit(address)”) => a1903eab65b303e5 https://ethresear.ch/t/verifying-the-purity-of-the-function-stored-at-the-validation-code-address/430
48.
deposit validation_addrのチェック ● こんな感じで他のコントラクトを結構呼び出している ●
頑張れば読める
49.
Vote L550~ ● Validatorがcheckpointに対してvoteする ●
80行くらいある
50.
Vote L550~ ● MSG_HASHERを呼び出してhashを取得 ●
RLPをdecode
51.
Casper Vote Format ●
Validator_index ● Target_hash ● Target_epoch ● Source_epoch ● signature https://github.com/ethereum/casper/blob/master/VALIDATOR_GUIDE.md#casper-vote-format b0 b1 b2 b3 r Epoch: n Epoch: n+1 Validators Address index
52.
Casper Vote Format ●
Validator_index ● Target_hash ● Target_epoch ● Source_epoch ● signature https://github.com/ethereum/casper/blob/master/VALIDATOR_GUIDE.md#casper-vote-format b0 b1 b2 b3 r source Target epoch, blockhash Validators Address index
53.
Vote L550~ ● RLPでdecodeした値をチェックしていく ●
すでにこのepochでvoteしていないかどうか
54.
Vote L550~ ● Target_hashがrecommended_target_hashかどうか? ●
target_epochがcurrent_epochかどうか? ● sourceがjustifyされているかどうか?
55.
Vote L550~ ● Voteしたtarget_hashがrecommended_target_hashでなければ, Voteそのものが失敗してしまう???
56.
Recommended_target_hash L365~ ● Target_epochにおけるcheckpointのblockのhashを返す ●
どうやら本当にrecommended_target_hashにvoteしないといけない ● そもそもrecommendedとは...
57.
そもそも誰がvoteするのか? ● もちろんvalidatorがdepositしてvoteするのである ● karlfloersch/pyethappにvalidator_service.pyという実装がある ○
ethereum/pythappにもあるけど, これは古いcasperのvalidatorの実装なので注意 ● とりあえず読んでみる https://github.com/ethereum/casper/blob/master/VALIDATOR_GUIDE.md https://github.com/karlfloersch/pyethapp/blob/dev_env/pyethapp/validator_service.py
58.
Pythapp validator_service.py L127
vote
59.
Pythapp validator_service.py L127
vote ● 似たようなmethodが呼び出されている
60.
validator_service.py L264~ recommended_vote_contents ●
Target_hash は current_epoch * epoch_length -1 らしい ● 結局のところcasperのrecommended_target_hashと同じ
61.
Validatorの挙動 ● Vote_msgのtarget_hashは, casper contractのrecommended_target_hashと同じ ●
つまり, casper contractが指定するtarget_hashにvoteするしかない
62.
● ValidatorはVote先を選ぶことはできない! ● New
Fork Choice Ruleなのに選べない!
63.
ところで もし, Validatorが自由にTargetを選べたら
64.
ContractはどうやってそのTarget Checkpointが 存在することを確認するのか?
65.
そもそもContractを実行するEVMはどこ?
66.
EVMはどこ? b0 b1 b2 b3 r
67.
ClientClient EVMはどこ? b0 b1 b2 b3 r b0 r b0 r Client ●
各Clientにある ● そのEVMの上でrecommended_target_hashを行うと?
68.
ClientClient EVMはどこ? b0 b1 b2 b3 r b0 r b0 r Client ●
各Clientにある ● そのEVMの上でrecommended_target_hashを行うと?
69.
EVMはどこ? ● blockhashはblockNumberからそのblockのhashを取得する
70.
Casper ContractのVote methodで fork先のtargetを選ぶのではない どのnodeに投げるかで選ぶ
71.
Root 100 100b 100d Vote(100b) Casper
Contract finalize 間違った理解
72.
ClientClient 実際 b0 b1 b2 b3 r b0 r b0 r Client Contract
Contract Contract Vote
73.
Casper Contract再び つまりassertは, 本当にこのNodeに対して行われたvoteかどうかを 確認している
74.
Forkが前提のContractを読み書きするとき ● Nodeが別々であることを意識する ● EVMが何を知っているかを考える
75.
まとめ ● コードを読もう ● 読めばわかる!!!楽しい!!!! ●
Minerがどうやってブロックを選ぶか喋りたかった
Download now