Share
Embed
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
146 slides
-
Ethereum with a little caffeine! *Slides referred from Loi Luu
and Vitalik Buterin Ronak Kogta -
Agenda • Blockchain as World Computer • What is Ethereum
? • Smart contracts and applications • Writing your first contract • Research Problems -
Blockchains and its crudest definition It's a platform that allows
a software package that contains business logic and user data to sit in the cloud. A copy of this cloud is replicated by millions of computers around the world to keep code/ data integrity. The user interface is an open source project that communicates with the software package in the cloud. To incentivize people to replicate this software package to be maintained you pay them with a digital currency. Rick Tuinenburg -
Blockchains and its crudest definition The value of digital currency
is determined by the popularity of the entire platform. Early adopters gain the most if the platform becomes a success. What makes this platform unique is that the business logic / data cannot be taken down or changed unless multiple anonymous developers around the world agree to do so. This makes it so authorities cannot take down software or data they don't like. Some use cases are: legal public records (deeds, court cases records, fictitious business names, etc) Rick Tuinenburg -
Proof of Work Coin Blockchain Dapp ASIC Transaction Contract Miner
Ledger Pools Crypto Sign Hash Commitment Consensus Exchange Technically we should know… -
Blockchain as world computer f(x)=? f(x)=y f(x) = y ?
f(x) = y ? Consensus Computer -
Blockchain as world computer f(x)=? f(x)=y f(x) = y ?
f(x) = y ? f(x)=y Consensus Computer -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton Cannot fail, be stopped or censored -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton Cannot fail, be stopped or censored Ubiquitous -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton Cannot fail, be stopped or censored Ubiquitous Verifiable and Auditable -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton Cannot fail, be stopped or censored Ubiquitous Verifiable and Auditable Guarantees -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton Cannot fail, be stopped or censored Ubiquitous Verifiable and Auditable Atomicity Guarantees -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton Cannot fail, be stopped or censored Ubiquitous Verifiable and Auditable Atomicity Immortality Guarantees -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton Cannot fail, be stopped or censored Ubiquitous Verifiable and Auditable Atomicity Immortality Immutable Code Guarantees -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton Cannot fail, be stopped or censored Ubiquitous Verifiable and Auditable Atomicity Immortality Immutable Code Synchrony Guarantees -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton Cannot fail, be stopped or censored Ubiquitous Verifiable and Auditable Atomicity Immortality Immutable Code Synchrony Provenance Guarantees -
Decentralised Computer Ethereum Truly a 1950s computer Not always decisive
Expansive to use Slow (5-1000x) Truly a global singleton Cannot fail, be stopped or censored Ubiquitous Verifiable and Auditable Atomicity Immortality Immutable Code Synchrony Provenance Permanence Guarantees -
Ethereum (Just another blockchain) • Blockchain is a decentralised ledger
of trust. – Rather than currency, you can use the ledger for kind of applications which require trust -
Ethereum (Just another blockchain) • Blockchain is a decentralised ledger
of trust. – Rather than currency, you can use the ledger for kind of applications which require trust – For e.g. Notary, writing a will, or decentralised -
Ethereum (Just another blockchain) • Blockchain is a decentralised ledger
of trust. – Rather than currency, you can use the ledger for kind of applications which require trust – For e.g. Notary, writing a will, or decentralised I. Craiglist , Uber, Zomato … -
Ethereum (Just another blockchain) • Blockchain is a decentralised ledger
of trust. – Rather than currency, you can use the ledger for kind of applications which require trust – For e.g. Notary, writing a will, or decentralised I. Craiglist , Uber, Zomato … II. Ebay, Amazon, Uber … -
Ethereum (Just another blockchain) • Blockchain is a decentralised ledger
of trust. – Rather than currency, you can use the ledger for kind of applications which require trust – For e.g. Notary, writing a will, or decentralised I. Craiglist , Uber, Zomato … II. Ebay, Amazon, Uber … • The way to do it is to write programs which are called “Smart Contracts” -
Ethereum (Just another blockchain) • Blockchain is a decentralised ledger
of trust. – Rather than currency, you can use the ledger for kind of applications which require trust – For e.g. Notary, writing a will, or decentralised I. Craiglist , Uber, Zomato … II. Ebay, Amazon, Uber … • The way to do it is to write programs which are called “Smart Contracts” • Ethereum can also be used to do normal ether transactions. -
Ethereum (Just another blockchain) • Blockchain is a decentralised ledger
of trust. – Rather than currency, you can use the ledger for kind of applications which require trust – For e.g. Notary, writing a will, or decentralised I. Craiglist , Uber, Zomato … II. Ebay, Amazon, Uber … • The way to do it is to write programs which are called “Smart Contracts” • Ethereum can also be used to do normal ether transactions. Matchmakers -
Ethereum Programming Model Bob does not believe in Spiderman, but
Alice does Alice bets that if she is in danger, Spiderman will protect her. -
Ethereum Programming Model Bob does not believe in Spiderman, but
Alice does Alice bets that if she is in danger, Spiderman will protect her. Spiderman morally wants to help everybody, if he can. Because with great power comes great responsibility. -
Ethereum Programming Model Bob does not believe in Spiderman, but
Alice does Alice bets that if she is in danger, Spiderman will protect her. Spiderman morally wants to help everybody, if he can. Because with great power comes great responsibility. Alice does not trust Bob, and needs to ensure that they both hold their end of bargains after the bet is done. -
Ethereum Programming Model Bob does not believe in Spiderman, but
Alice does Alice bets that if she is in danger, Spiderman will protect her. Spiderman morally wants to help everybody, if he can. Because with great power comes great responsibility. Alice does not trust Bob, and needs to ensure that they both hold their end of bargains after the bet is done. Spiderman is unaware of this bet, and just webbing his way around. -
Ethereum Programming Model Contract Persistent Msg Store $$$ Program Logic
?? $$$ Msg • Contract = Code + State -
Ethereum Programming Model Contract Persistent Msg Store $$$ Program Logic
?? $$$ Msg • Contract = Code + State • Turing Complete -
Ethereum Programming Model Contract Persistent Msg Store $$$ Program Logic
?? $$$ Msg • Contract = Code + State • Turing Complete • Self-Executing and enforcing -
Ethereum Programming Model Contract Persistent Msg Store $$$ Program Logic
?? $$$ Msg • Contract = Code + State • Turing Complete • Self-Executing and enforcing -
Ethereum Programming Model Contract Persistent Msg Store $$$ Program Logic
?? $$$ Msg • Contract = Code + State • Turing Complete • Self-Executing and enforcing are submitted as transactions in blockchain. -
Ethereum Programming Model Contract Persistent Msg Store $$$ Program Logic
?? $$$ Msg • Contract = Code + State • Turing Complete • Self-Executing and enforcing are submitted as transactions in blockchain. - Can send eth to other accounts -
Ethereum Programming Model Contract Persistent Msg Store $$$ Program Logic
?? $$$ Msg • Contract = Code + State • Turing Complete • Self-Executing and enforcing are submitted as transactions in blockchain. - Can send eth to other accounts - Read/write from storage -
Ethereum Programming Model Contract Persistent Msg Store $$$ Program Logic
?? $$$ Msg • Contract = Code + State • Turing Complete • Self-Executing and enforcing are submitted as transactions in blockchain. - Can send eth to other accounts - Read/write from storage - Invoke function calls to other contracts -
Ethereum Programming Model Contract Persistent Msg Store $$$ Program Logic
?? $$$ Msg • Contract = Code + State • Turing Complete • Self-Executing and enforcing are submitted as transactions in blockchain. - Can send eth to other accounts - Read/write from storage - Invoke function calls to other contracts - Create other contracts -
Contract Workflow Your Contract 60606040526040516102503 80380610250833981016040 528........ What others see
in blockchain PUSH 60 PUSH 40 MSTORE PUSH 0 CALLDATALOAD ..... Disassembler output -
Transactions • nonce (anti-replay-attack or transaction counter) • to (destination
address) • value (amount of ETH to send) • data (readable by contract code) • gasprice (amount of ether per unit gas) • startgas (maximum gas consumable) • v, r, s (ECDSA signature values) -
How to Create a Contract? • Submit a transaction to
the blockchain – nonce: previous nonce + 1 – to: empty – value: value sent to the new contract – data: contains the code of the contract – gasprice (amount of ether per unit gas) – startgas (maximum gas consumable) – v, r, s (ECDSA signature values) • If tx is successful – Returns the address of the new contract -
How to Interact With a Contract? • Submit a transaction
to the blockchain – nonce: previous nonce + 1 – to: contract address – value: value sent to the new contract – data: data supposed to be read by the contract – gasprice (amount of ether per unit gas) – startgas (maximum gas consumable) – v, r, s (ECDSA signature values) • If tx is successful – Returns outputs from the contract (if applicable) -
Ethereum Frameworks Serpent Solidity Lower Level Language Ethereum VM Bytecode
Stack Language (Like python) (Like javascript) (Function and macros like scheme) (Defined in Ethereum yellow paper) *Slide from Andrew Miller -
Blockchain State Address Balance (BTC) 0x123456… 10 0x1a2b3f… 1 0xab123d…
1.1 Bitcoin's state consists of key value mapping of addresses to account balance -
Blockchain State Address Balance (BTC) 0x123456… 10 0x1a2b3f… 1 0xab123d…
1.1 Ethereum’s state consists of key value mapping addresses to account objects Address Object 0x123456… X 0x1a2b3f… Y 0xab123d… Z Bitcoin's state consists of key value mapping of addresses to account balance -
Blockchain State Address Balance (BTC) 0x123456… 10 0x1a2b3f… 1 0xab123d…
1.1 Ethereum’s state consists of key value mapping addresses to account objects Address Object 0x123456… X 0x1a2b3f… Y 0xab123d… Z Bitcoin's state consists of key value mapping of addresses to account balance Blockchain != Blockchain State -
EVM Program Counter Computes preamble computation for transaction Rolls back
the transaction, if it fails Ethereum State Transition -
EVM Program Counter Computes preamble computation for transaction Commits the
transaction if success Rolls back the transaction, if it fails Ethereum State Transition -
EVM Program Counter Computes preamble computation for transaction Commits the
transaction if success Rolls back the transaction, if it fails Ethereum State Transition 1 Syntax checking transaction. -
EVM Program Counter Computes preamble computation for transaction Commits the
transaction if success Rolls back the transaction, if it fails Ethereum State Transition 1 Syntax checking transaction. 2 Computing preamble transaction fee. -
EVM Program Counter Computes preamble computation for transaction Commits the
transaction if success Rolls back the transaction, if it fails Ethereum State Transition 1 Syntax checking transaction. 2 Computing preamble transaction fee. 3 Initialise the gas payment. -
EVM Program Counter Computes preamble computation for transaction Commits the
transaction if success Rolls back the transaction, if it fails Ethereum State Transition 1 Syntax checking transaction. 2 Computing preamble transaction fee. 3 Initialise the gas payment. 4 Transfer the amount from sender to receiver. -
EVM Program Counter Computes preamble computation for transaction Commits the
transaction if success Rolls back the transaction, if it fails Ethereum State Transition 1 Syntax checking transaction. 2 Computing preamble transaction fee. 3 Initialise the gas payment. 4 Transfer the amount from sender to receiver. 5 Throw error, when sender account does not have sufficient ether, and roll back transaction. -
EVM Program Counter Computes preamble computation for transaction Commits the
transaction if success Rolls back the transaction, if it fails Ethereum State Transition 1 Syntax checking transaction. 2 Computing preamble transaction fee. 3 Initialise the gas payment. 4 Transfer the amount from sender to receiver. 5 Throw error, when sender account does not have sufficient ether, and roll back transaction. 6 For any other error, send the gas fee to sender -
Account Object • Every account object contains 4 pieces of
data: – Nonce – Balance – Code hash (code = empty string for normal accounts) – Storage trie root -
Account Object • Every account object contains 4 pieces of
data: – Nonce – Balance – Code hash (code = empty string for normal accounts) – Storage trie root -
Tx-n Tx-1 Block Mining Miners Tx-2 Block A set of
TXs Previous block New State Root Receipt Root Nonce -
Tx-n Tx-1 Block Mining Miners Tx-2 Block A set of
TXs Previous block New State Root Receipt Root Nonce -
Tx-n Tx-1 Block Mining Miners Tx-2 Block A set of
TXs Previous block New State Root Receipt Root Nonce Verify transactions & execute all code to update the state -
Tx-n Tx-1 Block Mining Miners Tx-2 Block A set of
TXs Previous block New State Root Receipt Root Nonce SHA3(Block) < D Verify transactions & execute all code to update the state -
Tx-n Tx-1 Block Mining Miners Tx-2 Block A set of
TXs Previous block New State Root Receipt Root Nonce SHA3(Block) < D Broadcast Block Verify transactions & execute all code to update the state -
Code execution • Every (full) node on the blockchain processes
every transaction and stores the entire state P6 P5 P4 P3 P2 P1 -
Code execution • Every (full) node on the blockchain processes
every transaction and stores the entire state P6 P5 P4 P3 P2 P1 This is a new block! I’m a leader -
Code execution • Every (full) node on the blockchain processes
every transaction and stores the entire state P6 P5 P4 P3 P2 P1 This is a new block! I’m a leader This is a new block! This is a new block! This is a new block! This is a new block! This is a new block! -
Dos Attack Vector • Halting problem – Cannot tell whether
or not a program will run infinitely – A malicious miner can DoS attack full nodes by including lots of computation in their txs • Full nodes attacked when verifying the block uint i = 1; while (i++ > 0) { donothing(); } -
Solution: Gas • Charge fee per computational step (“gas”) –
Special gas fees for operations that take up storage -
Solution: Gas • Charge fee per computational step (“gas”) –
Special gas fees for operations that take up storage -
Solution: Gas • Charge fee per computational step (“gas”) –
Special gas fees for operations that take up storage -
Sender has to pay for the gas • gasprice: amount
of ether per unit gas • startgas: maximum gas consumable – If startgas is less than needed • Out of gas exception, revert the state as if the TX has never happened • Sender still pays all the gas • TX fee = gasprice * consumedgas • Gas limit: similar to block size limit in Bitcoin – Total gas spent by all transactions in a block < Gas Limit -
What are Smart Contracts ? A smart contract is a
computer program executed in a secure environment that directly controls digital assets -
Properties of Smart Contracts • Correctness of execution – The
execution is done correctly, is not tampered • Integrity of code and data • Optional properties – Confidentiality of code and data – Verifiability of execution – Availability for the programs running inside Security Property -
Properties of Smart Contracts • Correctness of execution – The
execution is done correctly, is not tampered • Integrity of code and data • Optional properties – Confidentiality of code and data – Verifiability of execution – Availability for the programs running inside Security Property Servers secured by trusted hardware. (Intel SGX) -
Properties of Smart Contracts • A broad category – Domain
name – Website – Money – Anything tokenisable (e.g. gold, silver, stock share etc) – Game items – Network bandwidth, computation cycles Digital Assets -
Properties of Smart Contracts • Requires parties to pay collateral
before participating. • Use oracles (external trusted third parties) • Use network (miners are ready to do your work for a good incentive) • Cryptography 1. Commitments 2. Digital signatures 3. Merkle trees and authenticated data structures Technical aspects of smart contract -
Example: escrow service for exchange A B E X A
B E A B E I won’t give you Y Y -
Example: escrow service for exchange A B E X A
B E A B E I won’t give you Y Y -
Example: escrow service for exchange A B E X A
B E A B E I won’t give you Y Y A B E A B E X X -
Example: multisig • Require M of N “owners” to agree
in order for a particular digital asset to be transferred – Individual use cases • eg. two-factor authentication – Intra-organizational use cases -
Research Problems • How to write secure and correct contracts
? Need tools like Oyente -
Research Problems • How to write secure and correct contracts
? Need tools like Oyente • Can define your secure ethereum client based on yellow paper -
Research Problems • How to write secure and correct contracts
? Need tools like Oyente • Can define your secure ethereum client based on yellow paper • Can define programming languages like rust for smart contracts. -
Research Problems • How to write secure and correct contracts
? Need tools like Oyente • Can define your secure ethereum client based on yellow paper • Can define programming languages like rust for smart contracts. • Scaling Issues ? -
Research Problems • How to write secure and correct contracts
? Need tools like Oyente • Can define your secure ethereum client based on yellow paper • Can define programming languages like rust for smart contracts. • Scaling Issues ? • Sharding -
Research Problems • How to write secure and correct contracts
? Need tools like Oyente • Can define your secure ethereum client based on yellow paper • Can define programming languages like rust for smart contracts. • Scaling Issues ? • Sharding • State channels -
Research Problems • How to write secure and correct contracts
? Need tools like Oyente • Can define your secure ethereum client based on yellow paper • Can define programming languages like rust for smart contracts. • Scaling Issues ? • Sharding • State channels • Privacy Issues (Ring signatures, ZK-SNARKS and Hawk) -
Research Problems • How to write secure and correct contracts
? Need tools like Oyente • Can define your secure ethereum client based on yellow paper • Can define programming languages like rust for smart contracts. • Scaling Issues ? • Sharding • State channels • Privacy Issues (Ring signatures, ZK-SNARKS and Hawk) • Ethereum Virtual machine and improvement in language models -
Research Problems • How to write secure and correct contracts
? Need tools like Oyente • Can define your secure ethereum client based on yellow paper • Can define programming languages like rust for smart contracts. • Scaling Issues ? • Sharding • State channels • Privacy Issues (Ring signatures, ZK-SNARKS and Hawk) • Ethereum Virtual machine and improvement in language models • Proof of work/stake model for x86_64 which is gpu and asic resistant -
Research Problems • How to write secure and correct contracts
? Need tools like Oyente • Can define your secure ethereum client based on yellow paper • Can define programming languages like rust for smart contracts. • Scaling Issues ? • Sharding • State channels • Privacy Issues (Ring signatures, ZK-SNARKS and Hawk) • Ethereum Virtual machine and improvement in language models • Proof of work/stake model for x86_64 which is gpu and asic resistant • Defining decentralised pools and exchanges and relays (eg. Smart pool and BTC relay) -
Research Problems • Role of algorithmic incentives(game theory) in cryptocurrency
• Transaction in blockchain = mining reward + mining fee + private cost function -
Research Problems • Role of algorithmic incentives(game theory) in cryptocurrency
• Transaction in blockchain = mining reward + mining fee + private cost function • Multi-Agents are involved like miners, type of transactions etc. -
Research Problems • Role of algorithmic incentives(game theory) in cryptocurrency
• Transaction in blockchain = mining reward + mining fee + private cost function • Multi-Agents are involved like miners, type of transactions etc. • Can we define a model to calculate the costs for a particular contract or at least provide some guarantee. -
Research Problems • Role of algorithmic incentives(game theory) in cryptocurrency
• Transaction in blockchain = mining reward + mining fee + private cost function • Multi-Agents are involved like miners, type of transactions etc. • Can we define a model to calculate the costs for a particular contract or at least provide some guarantee. • Can do various studies of economics in crypto-regime -
Research Problems • Role of algorithmic incentives(game theory) in cryptocurrency
• Transaction in blockchain = mining reward + mining fee + private cost function • Multi-Agents are involved like miners, type of transactions etc. • Can we define a model to calculate the costs for a particular contract or at least provide some guarantee. • Can do various studies of economics in crypto-regime • Behavioural economic models -
Research Problems • Role of algorithmic incentives(game theory) in cryptocurrency
• Transaction in blockchain = mining reward + mining fee + private cost function • Multi-Agents are involved like miners, type of transactions etc. • Can we define a model to calculate the costs for a particular contract or at least provide some guarantee. • Can do various studies of economics in crypto-regime • Behavioural economic models • Selfish Agents -
Research Problems • Role of algorithmic incentives(game theory) in cryptocurrency
• Transaction in blockchain = mining reward + mining fee + private cost function • Multi-Agents are involved like miners, type of transactions etc. • Can we define a model to calculate the costs for a particular contract or at least provide some guarantee. • Can do various studies of economics in crypto-regime • Behavioural economic models • Selfish Agents • Coordinated choices -
Research Problems • Role of algorithmic incentives(game theory) in cryptocurrency
• Transaction in blockchain = mining reward + mining fee + private cost function • Multi-Agents are involved like miners, type of transactions etc. • Can we define a model to calculate the costs for a particular contract or at least provide some guarantee. • Can do various studies of economics in crypto-regime • Behavioural economic models • Selfish Agents • Coordinated choices • How a blackmail would happen, what would be protocols for heist, Can there be a morality check on contracts -
Research Problems • Role of algorithmic incentives(game theory) in cryptocurrency
• Transaction in blockchain = mining reward + mining fee + private cost function • Multi-Agents are involved like miners, type of transactions etc. • Can we define a model to calculate the costs for a particular contract or at least provide some guarantee. • Can do various studies of economics in crypto-regime • Behavioural economic models • Selfish Agents • Coordinated choices • How a blackmail would happen, what would be protocols for heist, Can there be a morality check on contracts https://github.com/ethereum/research/wiki/Problems