Upgrade to Pro — share decks privately, control downloads, hide ads and more …

FinTech - Lecture 9 : Smart Contracts (1)

FinTech - Lecture 9 : Smart Contracts (1)

These slides were used in the lecture 9 of FinTech - Financial Innovation and the Internet 2020 Fall at the Graduate School of Business and Finance, Waseda University, on November 27, 2020.

Kenji Saito

November 27, 2020
Tweet

More Decks by Kenji Saito

Other Decks in Technology

Transcript

  1. QIPUPCZ0MJWFS) FinTech — Financial Innovation and the Internet 2020 Fall

    Lecture 9 : Smart Contracts (1) Kenji Saito Professor, Graduate School of Business and Finance, Waseda University Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.1/39
  2. This class is recorded Camera ON is recommended, but not

    required You do need to speak often (we are going to have a lot of dialogue) We will use breakout rooms a lot, but those won’t be recorded unless you do it yourselves (need to be allowed) Keep your Zoom client updated! We might use latest features The recordings could be used for research on online learning Transcribed for use and anonymized Will let you know when the necessity arises Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.2/39
  3. The lecture slides can be found at : https://speakerdeck.com/ks91 Recording

    and chat text will be posted at Moodle and Discord Trial automatic transcription of the lecturer’s part will be posted at Discord Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.3/39
  4. Schedule (provisional) Lecture 1 9/25 Overview of FinTech (1) •

    Lecture 2 10/2 Overview of FinTech (2) • Lecture 3 10/9 Internet Technology and Governance (1) • Lecture 4 10/16 Internet Technology and Governance (2) • Lecture 5 10/23 The World of Apps (1) • Lecture 6 10/30 The World of Apps (2) • Lecture 7 11/13 Blockchain (1) • Lecture 8 11/20 Blockchain (2) • Lecture 9 11/27 Smart Contracts (1) • Lecture 10 12/4 Smart Contracts (2) Lecture 11 12/11 Other Ledger Technology and Applications (1) Lecture 12 12/18 Other Ledger Technology and Applications (2) Lecture 13 1/8 Cyber-Physical Society and Future of Finance Lecture 14 1/15 FinTech Ideathon Lecture 15 1/22 Presentations and Conclusions Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.4/39
  5. Last Week, We Did . . . Understanding Blockchain –

    continued Physical model with beakers and newspaper Functional layers (validity, existence, uniqueness) Possibilities and Impossibilities Applications people talk about, and thoese workable in reality Problems of blockchain Science Fiction Prototyping Assignment Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.5/39
  6. Today’s Topic Possibilities and Impossibilities of Blockchain – Continued Problems

    of blockchain Blockchain’s true worth and the “last will test” Assignment Review Smart Contracts and Ethereum Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.6/39
  7. Impossibility and Challenges of Blockchain (revisited) We saw probably unsustainable

    transitions of hash rates We saw reality vs. blockchain (a vending machine example with a drone) Transitional technology, in the process of trial and error In fact, a lot of new designs are being tested If we do not have governance for (or if we do not know how to accommodate) technological changes, we cannot use it in society Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.7/39
  8. The DAO Incident (uncovered governance challenges) The DAO, an autonomous

    decentralized investment fund built on Ethereum Split (of fund) was recursively called, and 360k ETH (5∼6 billion yen) was stolen (2016/6/17) Choices Do nothing Soft fork (maintains compatibility → freezes the address of the thief) Funds are not returned Hard fork (No compatibility → rewrites history; who controls the present controls the past) Worst occurrence of “Oneness Trap” (described later) in a sense Community chose “hard fork” ! (executed on 2016/7/20) “Most interesting. Gravity’s silhouette remains, but the star and all its planets have disappeared. How can this be?” “Because someone erased it from the archive memory.” — from Star Wars: Episode II – Attack of the Clones So the incident never happened Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.8/39
  9. Scaling Out Question There is one ATM that always has

    10 people in line Sorry if you are in an advanced environment, and you don’t know what we are talking about (or even wonder what an ATM is) What happens to the number of people in the queue if we add one ATM? Other conditions remain the same cf. Daisuke Yamazaki, “Rethinking Scaling Out” (in Japanese) http://www.slideshare.net/yamaz2/ss-58813038 Performance problems can be solved by adding a server ⇒ The system scales out Blockchain does not scale out in its bare form (because everyone makes and maintains a replica) Improvement is possible if you see it as a KVS (Key-Value Store) Because of the distributed KVS technology But you might lose autonomy Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.9/39
  10. Scaling Out and Blockchain 7PMVNFPG%BUBUP1SPDFTT -PBEQFS/PEF #MPDLDIBJO 1SPQFSMZEFTJHOFEEJTUSJCVUFETZTUFN In blockchain,

    the cost of maintaining data structures rises linearly as transactions increase It does not scale out Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.10/39
  11. Blochain’s “Oneness Trap” It does not scale out Adding more

    nodes does not solve or mitigate performance challenges Must be “the world is one” to work System does not work correctly if the network is partitioned by large-scale disasters or political changes Difficulty of governance to advance technology You cannot “try something different partially, and if it works, apply it to the whole” Impossibility of governance : Agreement by the “whole” must be maintained, but the “whole” cannot be defined ⇒ Powered few changes the technology instead ⇒ Those are disadvantages of non-decentralized structure of blockchain Conversely, there are great expectations and potential for truly decentralized “record fixation device in the air” Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.11/39
  12. Incentive Mismatch Ethereum cannot survive as an application platform if

    ETH as a currency crashes and declines Supported by miners’ motivation to get ETH When the value of ETH drops, miners withdraw Can people who want to run apps (smart contracts) buy ETH to maintain the price? If ETH’s market participants are primarily app users, may be . . . (but they aren’t) The design of the raw Bitcoin is goal-consistent, but . . . In other words, “Bitcoin cannot survive if BTC declines” would be fine But as proof applications such as Proof of Existence advance, similar problems arise Either way, the future of the system depends on the interests of the miners ⇒ Need to separate application platforms from currency systems That is where the recent ledger technology is going, hopefully (because many still aren’t) Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.12/39
  13. Overview of Technological Issues Evaluate three layers of blockchain technology

    1. Guarantee of Validity (For Bitcoin : UTXO data structure + digital signature) Self-contained and verifiable by everyone ⇒ Beneficial (yet confidentiality is a problem) 2. Proof of Existence (For Bitcoin : Hash-chain w/ proof of work) Evidence base for nonrepudiation of existence ⇒ Not as strong as expected 3. Consent of Uniqueness (For Bitcoin : Nakamoto consensus) Trial to finalize transactions ⇒ Problem in synchronizing with reality In addition, the non-decentralized structure and incentive mismatch by 2 and 3 Necessary to simultaneously solve the problems and explore applications on the assumption that the problems will be solved Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.13/39
  14. What is the True Worth of Blockchain? Roughly speaking, what’s

    the thing you can never do without blockchain? Ex1 : Digitizing the last will and testament (in a thought-experimental sense) After the death of the person, the private key used for the digital signature may no longer be a secret Can’t believe a notary saying, “it is as signed before the death” (possible collusion with malicious heir) Ex2 : Online banking passbook data as proof (for the liabilities of banks) If you download it as a CSV file, the data anyone can create is not considered as evidence Even with the digital signature of the bank, once the private key is leaked, the data can be created by anyone Prove that “data digitally signed at a cetain past point of time has not been tampered with since then” (instead of believing those who insist on their statement) “The Last Will Test” is to ask them if they can do that with their blockchain A test to see if something that someone has been pitching as “it’s a blockchain” really makes sense An idea (hash-chain with proof of work) that may satisfy this true worth, combined with existing technologies around the idea is the Bitcoin blockchain Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.14/39
  15. How Well Is It Realized Today? Is there a technology

    that can pass the “last will test”? Public blockchain may pass the test while the market value of the native currency is high Defense such that it would cost a lot to tamper with When the price of the native currency drops or crashes it becomes unreliable Private ledger systems in general only insist, so they do not pass the test Mostly, “blockchain made and operated by XXX Inc.” is meaningless ← please be careful We (Saito and friends) are building new technology to make it pass the test BBc-1 (Beyond Blockchain One; https://github.com/beyond-blockchain) (of course this is just one among many trials) There is an inherent challenge of linkage between records and entities though Includes areas that cannot be solved by technology alone (does the public key really belong to the person?) Including the openness of the source code, all is roughly the problem of . . . “How can we trust automated mechanisms?” Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.15/39
  16. Assignment Review Lecture 9 : Smart Contracts (1) — FinTech

    — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.16/39
  17. Assignment 4. “Smart Contracts” Please think freely with the image

    of the word “smart contract” to fantasize a specific application example, and state the application briefly That is, go ahead and write a very short science fiction Deadline and how to submit November 24, 2020 at 17:59 JST From Moodle (mandatory) Optionally, you can also post to #assignments channel at Discord So that your classmates can read your report, refer to it, and comment on it Just plain text, and be concise, please Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.17/39
  18. Trends and Measures Trends . . . of your reports

    Measures . . . how to improve the class 14 out of 16 students submitted (pretty good, and always better later than never) Sci-Fi about : (vehicle) insurance (4) / Avengers (or property market) (1) / WFH surveillance (1) / swap (1) / data storage or ISP (1) / utility bills (1) / politics (1) / adoption (of pets) (1) / copyright (1) / assassination market (1) / electronic medical record (1) / rent-a-car online (1) / P2P loan (1) Great fun to read! People often say that you cannot know a person’s true character until you drink together, or that you cannot really know them until you meet them face to face But I think the best way to understand each other’s values, desires, and reality may be to exchange our fictional stories with each other Perhaps that is why we use improvisational comedy techniques in our “Blockchain and Decentralized Finance” zemi ;) Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.18/39
  19. F’s Story In the far-off year of 2020, a virus

    has ravaged the world such that commuting to work is considered too risky Yet working at home requires a level of accountability which cannot be verified Thus began the rise of SmartContract, and application by which employers can ensure their employees are doing good work fulfilling their work contracts rather than wasting time looking at pictures of cats on the internet Employees download this application on their PCs and activate it during their work hours When activated, the application “observes” employees’ computers by keeping a log of what tabs are open, what media is playing, etc At the end of a work session, SmartContract brings up a report with the employee Unauthorized or excessive activities, based on the specifications decided by the employer, will request a brief explanation, which the employee can type in The report is then sent to the employer in a concise format so that he or she can quickly check anomalies in how the employee is spending his or her work hours This can guide management to make decisions regarding said employee ⇒ This sounds like Japan (so in part of this country or culture, this is not really a fiction) How about your countries or cultures? Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.19/39
  20. C’s Story One day, a smart contract can be conducted

    between pets and the owners Once anyone decides to raise an animal, the contract will be lifetime The problem of abandoned animals will be solved People will consider more thoroughly before they make any decisions because in the world built up by smart contracts, there is no room for turning back ⇒ Sad, but we are living in a world that requires something like this I (Saito) like that part that the contracts are between pets and the owners Protective for the weak Need for an identification mechanism for pets (physically not intrusive way, hopefully) Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.20/39
  21. T’s Story (1) The assassination market is a market where

    any party can guess the date of death of a person and they can collect the payment if they guess the date correctly The guesser includes their guess which is the name and date of the individual and encrypt it with untraceable digital cash to prevent random guessing It is difficult to assign criminal liability for assassination because the reward is for accurately picking the date and the person’s name rather than carrying out the assassination itself Smart contracts ensure anonymity and fairness for the transaction It does not involve a third party as well so the payer can make a contract with the assassin directly and this can reduce manipulation Smart contract is done in this case by including the date and the person’s death and the payout will be released if the conditions suffice This will entice assassins to take up the contract by killing the individual on the specific date Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.21/39
  22. T’s Story (2) However, smart contracts cannot be altered It

    is impossible to manipulate the contract Therefore, once the contract is placed, it is impossible to withdraw the assassination contract The only way to ensure that the person lives on that day is to hide the person in a safe house and possibly kill off any assassins on that specific date The contract will expire after that his assassination date and there will be no more incentives to kill the targeted individual ⇒ Really interesting! I think you should write a full story, including the part that the protagonist mistakenly places a contract with his or her own death date But designing and operating the system in really is difficult for two reasons: It is difficult to assure anonymity (people are working on it) It is difficult for the system to always correctly recognize one’s death (because death is a social event) Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.22/39
  23. Science Fiction Prototyping “WIRED vol.25 The Power of Blockchain —

    Blockchains change the world” (2016) “Oh, Great Decentralization: 5 Perspectives of Near Blockchain Future” Organized by editors based on my interview The story of “Family” from it You want to get married. You realized this feeling, so you and your partner records the words of your oath (contract) in the air “If you don’t want to be with me, you can break this contract. With the key that only you can use” OK, what if she loses the key? Till death do them part ;) Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.23/39
  24. Smart Contracts and Ethereum What is Smart Contract? Ethereum Lecture

    9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.24/39
  25. What is Smart Contract? Speak in a narrow sense Speak

    in a broad sense Smart contracts and vending machines What is a contract? Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.25/39
  26. Speak in a Narrow Sense A smart contract is, A

    system for automatically transferring and transitioning digitally represented assets according to predetermined rules Or more mechanically, To write program code and data to a blockchain, And run the program blockchain-wise to update data Run when miners verify transactions They do not agree with the feeling of the word But there is a meaning to this narrow sense Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.26/39
  27. Speak in a Broad Sense A smart contract is, Mechanisms

    for implementing contracts mechanically Or, contracts implemented as such ↑ Definition in future dictionaries A vending machine is a primitive form of smart contracts Vending machine . . . do you remember “Reality vs. Blockchain”? Reality that goes in real-time and blockchain’s behavior are very different Suggesting that smart contracts in a broad sense cannot be implemented by blockchain today Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.27/39
  28. What is a Contract Anyway? Contracts (by Oxford Dictionary) A

    written or spoken agreement, especially one concerning employment, sales, or tenancy, that is intended to be enforceable by law Essential requirement for its establishment Coherence of manifestation of intention between the parties And the medium for that, Oral, handshake, carving/baking on clay tablets and breaking them, paper (handwriting), paper (print) What can a machine do? cf. “The medium is the message.” by McLuhan cf. “Gutenberg Galaxy” by McLuhan Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.28/39
  29. Gutenberg Galaxy (typography) (revisited) Birth of the concept of “authors”

    (meaningless concept unless texts are copied word for word without difference) Scientific methodology (publish papers and have results tested) Nationalism (one standard language, one country) Prepared “movies” (series of photos from one viewpoint) Clear distinction between finished and unfinished “products” (printed copies are the products, handwritten manuscripts are not) Individualism (can carry knowledge personally) Unification of popular culture (massive copies) . . . ⇒ Prepared the industrial society Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.29/39
  30. Reversed Gutenberg Galaxy (digital media) (revisited) Destruction of the concept

    of “authors” (social media time lines are like mosaic media) Overturned scientific methodology (automated hypothesis-testing loops for discoveries) Global perspective (connected across borders) Everyone becomes a moviemaker (YouTubers, TikTokers) Obscured finished and unfinished products ⇒ open design Promotion of collaboration (sharing by default) Diversification of cultural events (long tail) . . . ⇒ Preparing for the next society Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.30/39
  31. Overview of Ethereum Blockchain and State Transition EVM (Ethereum Virtual

    Machine) Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.31/39
  32. What is Ethereum? Vitalik Buterin, “Ethereum White Paper: A NEXT

    GENERATION SMART CONTRACT & DECENTRALIZED APPLICATION PLATFORM” Applying blockchain technology Targeted average block interval : 15 seconds Put a programming language on it Turing complete = can emulate a universal Turing machine (well that’s almost a definition of a programming language) Foundation for DApps (applications that automate the center) An attempt to make the current financial and monetary system obsolete That’s what smart contracts are all about Automate digital asset transfers and their state transitions Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.32/39
  33. Blockchain and State Transitions TUBUF FYUFSOBMBDUPST BDDPVOU &7.DPEF &UIFSˠHBT JOWPLF

    DPOUSBDUDPEF NFTTBHFPSBOFXBVUPOPNPVTPCKFDU EBUBFYDIBOHFEBNPOHBDDPVOUTPS&UIFS TUPSBHF TUBUF` TFUPG USBOTBDUJPOT EJHJUBMTJHOBUVSF &7. IVNBO GPSFYBNQMF Blockchain = Run of a state machine (state transition system) = Operation of a computer Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.33/39
  34. Glossary Ether (ETH) Native currency of Ethereum (compensation for mining)

    External Actor A real person/entity who can digitally sign, having an account EOA : Externally-Owned Account Autonomous Object (internal actor) Operates autonomously within the system, and has an account That said, if you don’t send a message, it won’t work (and miners run them) Account Has an Ether balance, and can have storage (state) and EVM code EVM Code Smart contract program Smart contract = application program on Ethereum = intelligent contract Authenticity is ensured by being written in blockchain Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.34/39
  35. EVM : Ethereum Virtual Machine TUBUF FYUFSOBMBDUPST BDDPVOU &7.DPEF &UIFSˠHBT

    JOWPLF DPOUSBDUDPEF NFTTBHFPSBOFXBVUPOPNPVTPCKFDU EBUBFYDIBOHFEBNPOHBDDPVOUTPS&UIFS TUPSBHF TUBUF` TFUPG USBOTBDUJPOT EJHJUBMTJHOBUVSF &7. IVNBO GPSFYBNQMF BVUPOPNPVT PCKFDU Triggered when an autonomous object receives a message, performs a contract, and changes state Gas must be supplied for each execution step (to avoid an infinite loop and to compensate EVM executor = miner) Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.35/39
  36. Technical Challenges of Blockchain Non real-time (probabilistic behavior) Difficulty of

    secrecy (guarantee of verifiability to all) Oneness (distribution vs. replication) Not scalable (do not scale if replicated to all participants) Harder governance of evolution (can’t change if everyone needs to be united) Incentive mismatch (discrepancy of motivations for participation in infrastructure and applications) Supported by the value of the native currency (crash would stop all applications) ⇒ Can be solved by redesigning it zero-base Actually in progress (ex. BBc -1) Problem with many ledgers is that they are not redesigned zero-base ex. Hash-chains without proof of work can be tampered with ex. Talking about “newspaper model”, you can’t prove anything by publishing articles in company newsletters Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.36/39
  37. Ethereum’s Approach (solutions blockchain-way) Non real-time (probabilistic behavior) ⇒ Towards

    transaction finalization mechanism (Casper) Difficulty of secrecy (guarantee of verifiability to all) ⇒ ZoE (Zcash on Ethereum) Oneness (distribution vs. replication) Not scalable (do not scale if replicated to all participants) ⇒ Sharding, Plasma (multi-layered) Harder governance of evolution (can’t change if everyone needs to be united) ⇒ Benevolent Dictator For Life (BDFL) (with bitter smile ;) ) Incentive mismatch (discrepancy of motivations for participation in infrastructure and applications) Supported by the value of the native currency (crash would stop all applications) ⇒ Will people who want to run the apps buy Ether and support? Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.37/39
  38. BBc-1’s Approach (solutions non-blockchain-way) Non real-time (probabilistic behavior) ⇒ No

    probabilistic behavior before transaction commits Difficulty of secrecy (guarantee of verifiability to all) ⇒ Transaction content is kept secret outside the domain, and can be encrypted inside Oneness (distribution vs. replication) Not scalable (do not scale if replicated to all participants) ⇒ Scale-out on a domain-by-domain basis, intra-domain DHT in the future Harder governance of evolution (can’t change if everyone needs to be united) ⇒ Autonomy by domain (don’t care about intra-domain protocols) Incentive mismatch (discrepancy of motivations for participation in infrastructure and applications) Supported by the value of the native currency (crash would stop all applications) ⇒ No native currency, proof of context work by mutual aid Lecture 9 : Smart Contracts (1) — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.38/39
  39. See You Next Week! Lecture 9 : Smart Contracts (1)

    — FinTech — Financial Innovation and the Internet 2020 Fall — 2020-11-27 – p.39/39