Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
スマートコントラクトプログラミング (3) イーサリアム実習 I / Ethereum Pra...
Search
Kenji Saito
PRO
May 24, 2017
Technology
1
440
スマートコントラクトプログラミング (3) イーサリアム実習 I / Ethereum Practice I
ブロックチェーンハブ主催で開催している (第2期) スマートコントラクトプログラミング講義 (3) 「イーサリアム実習 I」のスライドです。2017年5月24日(水) に使用しました。
Kenji Saito
PRO
May 24, 2017
Tweet
Share
More Decks by Kenji Saito
See All by Kenji Saito
P 値と有意差/分散分析 / P-value, Significant Difference and Analysis of Variance
ks91
PRO
0
29
関連2群のt検定/独立2群のt検定 / Related 2-group t-test and independent 2-group t-test
ks91
PRO
0
51
A Guide to Paper Writing Support with Generative AI - A Joint Zemi
ks91
PRO
0
9
正規分布と簡単な統計理論/t分布と信頼区間 / Normal distribution, simple statistical theory, t-distribution and confidence intervals
ks91
PRO
0
43
じわじわ迫ってきている自動化社会 (その先にメタ・ネイチャー) / The Slowly Approaching Automated Society (and its beyond: Meta-Nature)
ks91
PRO
0
6
起こりうる誤った推論/平均・分散・標準偏差・自由度 / Possible false inferences, means, variances, standard deviations and degrees of freedom
ks91
PRO
0
59
LaTeX と Overleaf によるショートペーパー作成 / Short paper writing with LaTeX and Overleaf
ks91
PRO
0
23
R を用いた検定(補講) (1) — Welch 検定 / Tests using R (supplementary) (1) - Welch test
ks91
PRO
0
12
R を用いた検定(補講) (2) — カイ二乗検定 / Tests using R (supplementary) (2) - Chi-squared test
ks91
PRO
0
13
Other Decks in Technology
See All in Technology
ZOZOTOWN の推薦における KPI モニタリング/KPI monitoring for ZOZOTOWN recommendations
rayuron
1
290
The key to VCP-VCF
mirie_sd
0
120
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
23
6.6k
多様なメトリックとシステムの健全性維持
masaaki_k
0
130
watsonx.ai Dojo #5 ファインチューニングとInstructLAB
oniak3ibm
PRO
0
290
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
230
AWS re:Invent 2024 Recap in ZOZO - Serverless で好きなものをしゃべってみた
chongmyungpark
0
710
「完全に理解したTalk」完全に理解した
segavvy
1
230
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
28
24k
20241218_マルチアカウント環境におけるIAM_Access_Analyzerによる権限管理.pdf
nrinetcom
PRO
3
130
AWS re:Invent 2024 recap
hkoketsu
0
720
[トレノケ雲の会 mod.13] 3回目のre:Inventで気づいたこと -CloudOperationsを添えて-
shintaro_fukatsu
0
120
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Invisible Side of Design
smashingmag
299
50k
Building an army of robots
kneath
302
44k
Become a Pro
speakerdeck
PRO
26
5.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
Transcript
I (3) CSO / SFC
[email protected]
I – (3) –
2017-05-24 – p.1/37
1. 2. 3. 4. 5. I – (3) – 2017-05-24
– p.2/37
1. : 2. ∼ ∼ I – (3) – 2017-05-24
– p.3/37
1. : I – (3) – 2017-05-24 – p.4/37
BcH-smart-contract-programming.zip contracts tests I – (3) – 2017-05-24 – p.5/37
Solidity JavaScript ( , ) (constructor) ( ) ( )
Ether I – (3) – 2017-05-24 – p.6/37
pragma solidity ˆ0.4.8; contract MyToken { ( ) : (EVM
) : function MyToken(...) { /* */ : } : } function C (/* */ // ) I – (3) – 2017-05-24 – p.7/37
MyToken string public name; string public symbol; uint8 public decimals;
mapping (address => uint256) public balanceOf; name, symbol decimals : 2 100 1.00 mapping balanceOf I – (3) – 2017-05-24 – p.8/37
MyToken event Transfer(address indexed from, address indexed to, uint256 value);
indexed (3 ) MyToken function Transfer() Ethereum-Wallet I – (3) – 2017-05-24 – p.9/37
MyToken function MyToken(uint256 _supply, string _name, string _symbol, uint8 _decimals)
{ if (_supply == 0) { _supply = 1000000; /* _supply 1,000,000 */ } balanceOf[msg.sender] = _supply; name = _name; symbol = _symbol; decimals = _decimals; } msg.sender _supply C++ _ I – (3) – 2017-05-24 – p.10/37
MyToken getBalanceOf() function getBalanceOf(address _addr) returns (uint256 balance) { return
(balanceOf[_addr]); } I – (3) – 2017-05-24 – p.11/37
MyToken transfer() function transfer(address _to, uint256 _value) { if (balanceOf[msg.sender]
< _value) { /* */ throw; } if (balanceOf[_to] + _value < balanceOf[_to]) { /* */ throw; } balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); } throw (function ) catch I – (3) – 2017-05-24 – p.12/37
(1) import pytest @pytest.fixture() def token_contract(chain): TokenFactory = chain.get_contract_factory(’MyToken’) deploy_txid
= TokenFactory.deploy(args=[ 0, "BcH Coin", "BcH", 0, ]) contract_address = chain.wait.for_contract_address(deploy_txid) return TokenFactory(address=contract_address) populus I – (3) – 2017-05-24 – p.13/37
(2) def test_my_token(token_contract, chain): account0 = chain.web3.eth.accounts[0] account1 = chain.web3.eth.accounts[1]
assert token_contract.call().getBalanceOf(account0) == 1000000 assert token_contract.call().getBalanceOf(account1) == 0 txid = token_contract.transact().transfer(account1, 10) chain.wait.for_receipt(txid) assert token_contract.call().getBalanceOf(account0) == 999990 assert token_contract.call().getBalanceOf(account1) == 10 account0 coinbase account1 account0 account1 10BcH I – (3) – 2017-05-24 – p.14/37
$ py.test tests/test_my_token.py I – (3) – 2017-05-24 – p.15/37
2. ∼ ∼ I – (3) – 2017-05-24 – p.16/37
A, B A-B m A B A B A B
. . . I – (3) – 2017-05-24 – p.17/37
1. X 2. X C 3. C 1. 2. 3.
reliable multicast I – (3) – 2017-05-24 – p.18/37
: I – (3) – 2017-05-24 – p.19/37
(safety) (liveness) ( ) ( = ) I – (3)
– 2017-05-24 – p.20/37
→ / (benign) → (Byzantine) (malicious) I – (3) –
2017-05-24 – p.21/37
FLP Fischer, Lynch, Paterson I – (3) – 2017-05-24 –
p.22/37
CAP Consistency ( ) Availability ( ) Partition tolerance (
) ⇒ 3 C Eventual consistency ( ) . . . I – (3) – 2017-05-24 – p.23/37
Consistency ( ) Strong consistency ( ) (safety) Eventual consistency
( ) (liveness) ↑ Weak consistency ( ) ↑ ( ) I – (3) – 2017-05-24 – p.24/37
n = f ( ) ⇒ I – (3) –
2017-05-24 – p.25/37
(1) 1 1, 2 n ≤ 3f I – (3)
– 2017-05-24 – p.26/37
(2) I – (3) – 2017-05-24 – p.27/37
CS1 : CS2 : CS3 : CL1 : CL2 :
: : (e.g. ) I – (3) – 2017-05-24 – p.28/37
(B)FT-CUP (Consensus with Unknown Participants) ( / ) : FT
(Fault-Tolerant) : BFT (Byzantine Fault-Tolerant) P2P n FT/BFT I – (3) – 2017-05-24 – p.29/37
State Machine Replication ( ) (by ) (since 1984) (
) ( ) . . . ( ) I – (3) – 2017-05-24 – p.30/37
( ) ( ) ( ) ( ) (by )
⇒ ( ) I – (3) – 2017-05-24 – p.31/37
P2P : P2P 3 3 ( ) strategyproof group strategyproof
I – (3) – 2017-05-24 – p.32/37
(Sybil) 16 I – (3) – 2017-05-24 – p.33/37
again n > 3f R F R > 2F ⇒
I – (3) – 2017-05-24 – p.34/37
( ) f = 1 ⇒ R I – (3)
– 2017-05-24 – p.35/37
(centralized) (decentralized) (distributed) Paul Baran, “On Distributed Communications Networks”, 1964
(C) (A) I – (3) – 2017-05-24 – p.36/37
II Hyperledger I – (3) – 2017-05-24 – p.37/37