Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
イーサリアム実習 I / Practicing Ethereum I
Kenji Saito
PRO
November 01, 2017
Technology
0
180
イーサリアム実習 I / Practicing Ethereum I
2017年11月1日(水)、ブロックチェーンアカデミー「スマートコントラクトプログラミング講座(3)」にて使用のスライドです。
Kenji Saito
PRO
November 01, 2017
Tweet
Share
More Decks by Kenji Saito
See All by Kenji Saito
FinTech Lecture 15 : Presentations and Conclusions
ks91
PRO
0
49
FinTech Lecture 14 : Q & A
ks91
PRO
0
56
FinTech Lecture 13 : FinTech Ideathon
ks91
PRO
0
58
AI との対話 / Interacting with AI
ks91
PRO
0
17
FinTech Lecture 12 : Cyber-Physical Society and Future of Finance
ks91
PRO
0
59
FinTech Lecture 11 : Further Smart Contracts
ks91
PRO
0
56
評判システムと自律分散社会 / Reputation Systems and Decentralized Autonomous Society
ks91
PRO
0
13
FinTech Lecture 10 : Smart Contracts
ks91
PRO
0
35
ブロックチェーンと近未来の金融システム / Blockchain and Financial System of the Near Future
ks91
PRO
0
110
Other Decks in Technology
See All in Technology
本社オフィスを移転し、 オフィスファシリティ・コーポレートIT を刷新した話
rotomx
3
1.2k
Airdrop for Open Source Projects
epicsdao
0
290
API連携に伴う規制と対応 / Regulations and responses to API linkage
moneyforward
0
110
AKIBA.SaaS資料
yasumuusan
0
160
マイクロサービス宣言から8年 振り返りとこれから / Eight Years After the Microservices Declaration A Look Back and A Look Ahead
eisuke
2
130
PCL (Point Cloud Library)の基本となぜ点群処理か_2023年_第2版.pdf
cvmlexpertguide
0
130
Exploring MapStore Release 2022.02: improved 3DTiles support and more
simboss
PRO
0
180
オンプレk8sとEKSの並行運用の実際
ch1aki
0
150
ROS_Japan_UG_#49_LT
maeharakeisuke
0
200
Virtual Thread - 導入の背景と、効果的な使い方 -
skrb
3
250
PCI DSS に準拠したシステム開発
yutadayo
0
270
NGINXENG JP#2 - 3-NGINX Plus・プロダクトのアップデート
hiropo20
0
170
Featured
See All Featured
Atom: Resistance is Futile
akmur
256
24k
Why Our Code Smells
bkeepers
PRO
326
55k
Intergalactic Javascript Robots from Outer Space
tanoku
261
26k
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
175
9.1k
The Cult of Friendly URLs
andyhume
68
5.1k
Pencils Down: Stop Designing & Start Developing
hursman
114
10k
Building Flexible Design Systems
yeseniaperezcruz
314
35k
VelocityConf: Rendering Performance Case Studies
addyosmani
317
22k
Mobile First: as difficult as doing things right
swwweet
213
7.8k
No one is an island. Learnings from fostering a developers community.
thoeni
12
1.5k
The Pragmatic Product Professional
lauravandoore
21
3.4k
Done Done
chrislema
178
14k
Transcript
I (3) CSO / SFC
[email protected]
I – (3) –
2017-11-01 – p.1/37
1. 2. 3. 4. 5. Populus “Bash on Ubuntu on
Windows” geth (Go segmentation fault ) I – (3) – 2017-11-01 – p.2/37
1. : 2. ∼ ∼ I – (3) – 2017-11-01
– p.3/37
1. : I – (3) – 2017-11-01 – p.4/37
BcH-smart-contract-programming.zip init.py Populus 1.11.0 init10.py Populus 1.10.1 contracts tests I
– (3) – 2017-11-01 – p.5/37
Solidity JavaScript ( , ) (constructor) ( ) ( )
Ether I – (3) – 2017-11-01 – p.6/37
pragma solidity ˆ0.4.8; contract MyToken { ( ) : (EVM
) : function MyToken(...) { /* */ : } : } function C (/* */ // ) I – (3) – 2017-11-01 – 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-11-01 – p.8/37
MyToken event Transfer(address indexed from, address indexed to, uint256 value);
indexed (3 ) MyToken function Transfer() Ethereum-Wallet I – (3) – 2017-11-01 – 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-11-01 – p.10/37
MyToken getBalanceOf() function getBalanceOf(address _addr) returns (uint256 balance) { return
(balanceOf[_addr]); } I – (3) – 2017-11-01 – 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-11-01 – p.12/37
(1) import pytest @pytest.fixture() def token_contract(chain): TokenFactory = chain.provider.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-11-01 – 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-11-01 – p.14/37
$ py.test -k test_my_token.py I – (3) – 2017-11-01 –
p.15/37
2. ∼ ∼ I – (3) – 2017-11-01 – p.16/37
A, B A-B m A B A B A B
. . . I – (3) – 2017-11-01 – p.17/37
1. X 2. X C 3. C 1. 2. 3.
reliable multicast I – (3) – 2017-11-01 – p.18/37
: I – (3) – 2017-11-01 – p.19/37
(safety) (liveness) ( ) ( = ) I – (3)
– 2017-11-01 – p.20/37
→ / (benign) → (Byzantine) (malicious) I – (3) –
2017-11-01 – p.21/37
FLP Fischer, Lynch, Paterson I – (3) – 2017-11-01 –
p.22/37
CAP Consistency ( ) Availability ( ) Partition tolerance (
) ⇒ 3 C Eventual consistency ( ) . . . I – (3) – 2017-11-01 – p.23/37
Consistency ( ) Strong consistency ( ) (safety) Eventual consistency
( ) (liveness) ↑ Weak consistency ( ) ↑ ( ) I – (3) – 2017-11-01 – p.24/37
n = f ( ) ⇒ I – (3) –
2017-11-01 – p.25/37
(1) 1 1, 2 n ≤ 3f I – (3)
– 2017-11-01 – p.26/37
(2) I – (3) – 2017-11-01 – p.27/37
CS1 : CS2 : CS3 : CL1 : CL2 :
: : (e.g. ) I – (3) – 2017-11-01 – p.28/37
(B)FT-CUP (Consensus with Unknown Participants) ( / ) : FT
(Fault-Tolerant) : BFT (Byzantine Fault-Tolerant) P2P n FT/BFT I – (3) – 2017-11-01 – p.29/37
State Machine Replication ( ) (by ) (since 1984) (
) ( ) . . . ( ) I – (3) – 2017-11-01 – p.30/37
( ) ( ) ( ) ( ) (by )
⇒ ( ) I – (3) – 2017-11-01 – p.31/37
P2P : P2P 3 3 ( ) strategyproof group strategyproof
I – (3) – 2017-11-01 – p.32/37
(Sybil) 16 I – (3) – 2017-11-01 – p.33/37
again n > 3f R F R > 2F ⇒
I – (3) – 2017-11-01 – p.34/37
( ) f = 1 ⇒ R I – (3)
– 2017-11-01 – p.35/37
(centralized) (decentralized) (distributed) Paul Baran, “On Distributed Communications Networks”, 1964
(C) (A) I – (3) – 2017-11-01 – p.36/37
II Hyperledger I – (3) – 2017-11-01 – p.37/37