1 of 17

1

Ethereum: Decentralized Apps, EVM, and the Ethereum blockchain

Blockchain Technologies

Lecture # 05

2 of 17

Introduction

  • Ethereum is a global, open-source platform for decentralized applications.
  • On Ethereum, you can write code that controls digital value, runs exactly as programmed, and is accessible anywhere in the world
  • It is a decentralized open source blockchain featuring smart contract functionality.
  • Ether is the cryptocurrency generated by Ethereum miners as a reward for computations performed to secure the blockchain

2

3 of 17

  • Ethereum provides a decentralized virtual machine, the Ethereum Virtual Machine (EVM), which can execute scripts using an international network of public nodes.
  • The virtual machine's instruction set, in contrast to others like Bitcoin Script, is Turing-complete.
  • "Gas", an internal transaction pricing mechanism, is used to mitigate spam and allocate resources on the network.

3

4 of 17

Scripting

  • Even without any extensions, the Bitcoin protocol actually does facilitate a weak version of a concept of "smart contracts“
  • UTXO in Bitcoin can be owned not just by a public key, but also by a more complicated script expressed in a simple stack-based programming language.
  • In this paradigm, a transaction spending that UTXO must provide data that satisfies the script.

4

5 of 17

Scripting limitations

  • Lack of Turing-completeness: While there is a large subset of computation that the Bitcoin scripting language supports, it does not nearly support everything. The main category that is missing is loops. Any loop can be simulated by simply repeating the underlying code many times with an if statement, but it does lead to scripts that are very space-inefficient.
  • Value-blindness - there is no way for a UTXO script to provide fine-grained control over the amount that can be withdrawn.

5

6 of 17

  • Lack of state - a UTXO can either be spent or unspent there is no opportunity for multi-stage contracts or scripts which keep any other internal state beyond that. This makes it hard to make multi-stage options contracts, decentralized exchange offers or two-stage cryptographic commitment protocols

6

7 of 17

  • Blockchain-blindness - UTXO are blind to blockchain data such as the nonce, the timestamp and previous block hash. This severely limits applications in gambling, and several other categories, by depriving the scripting language of a potentially valuable source of randomness.

7

8 of 17

Ethereum

  • The intent of Ethereum is to create an alternative protocol for building decentralized applications, providing a different set of tradeoffs that we believe will be very useful for a large class of decentralized applications, with particular emphasis on situations where rapid development time, security for small and rarely used applications, and the ability of different applications to very efficiently interact, are important.

8

9 of 17

  • Ethereum does this by building what is essentially the ultimate abstract foundational layer: a blockchain with a built-in Turing-complete programming language, allowing anyone to write smart contracts and decentralized applications where they can create their own arbitrary rules for ownership, transaction formats and state transition functions. 

9

10 of 17

Philosophy of Ethereum

  • Simplicity: the Ethereum protocol should be as simple as possible, even at the cost of some data storage or time inefficiency
  • Universality: Ethereum provides an internal Turing-complete scripting language, which a programmer can use to construct any smart contract or transaction type that can be mathematically defined. Want to invent your own financial derivative? With Ethereum, you can. Want to make your own currency? Set it up as an Ethereum contract.

10

11 of 17

  • Modularity: the parts of the Ethereum protocol should be designed to be as modular and separable as possible. Over the course of development, our goal is to create a program where if one was to make a small protocol modification in one place, the application stack would continue to function without any further modification. 
  • Agility: details of the Ethereum protocol are not set in stone. Computational tests later on in the development process may lead us to discover that certain modifications, e.g. to the protocol architecture or to the Ethereum Virtual Machine (EVM), will substantially improve scalability or security. If any such opportunities are found, we will exploit them.

11

12 of 17

  • Non-discrimination and non-censorship: the protocol should not attempt to actively restrict or prevent specific categories of usage.
    • All regulatory mechanisms in the protocol should be designed to directly regulate the harm and not attempt to oppose specific undesirable applications.
    • A programmer can even run an infinite loop script on top of Ethereum for as long as they are willing to keep paying the per-computational-step transaction fee.

12

13 of 17

Ethereum accounts

  • In Ethereum, the state is made up of objects called "accounts", with each account having a 20-byte address and state transitions being direct transfers of value and information between accounts.
  • An Ethereum account contains four fields:
    • The nonce, a counter used to make sure each transaction can only be processed once
    • The account's current ether balance
    • The account's contract code, if present
    • The account's storage (empty by default)
  • "Ether" is the main internal crypto-fuel of Ethereum, and is used to pay transaction fees.

13

14 of 17

Transaction

  • The term "transaction" is used in Ethereum to refer to the signed data package that stores a message to be sent from an externally owned account. Transactions contain:
    • The recipient of the message
    • A signature identifying the sender
    • The amount of ether to transfer from the sender to the recipient
    • An optional data field
    • A STARTGASvalue, representing the maximum number of computational steps the transaction execution is allowed to take
    • A GASPRICEvalue, representing the fee the sender pays per computational step

14

15 of 17

Messages

  • Contracts have the ability to send "messages" to other contracts. Messages are virtual objects that are never serialized and exist only in the Ethereum execution environment. A message contains:
    • The sender of the message (implicit)
    • The recipient of the message
    • The amount of ether to transfer alongside the message
    • An optional data field
    • A STARTGASvalue

15

16 of 17

Code Execution

  • The code in Ethereum contracts is written in a low-level, stack-based bytecode language, referred to as "Ethereum virtual machine code" or "EVM code".
  • The code consists of a series of bytes, where each byte represents an operation. In general, code execution is an infinite loop that consists of repeatedly carrying out the operation at the current program counter (which begins at zero) and then incrementing the program counter by one, until the end of the code is reached or an error or STOPor RETURNinstruction is detected. 

16

17 of 17

Applications

  • In general, there are three types of applications on top of Ethereum.
  • The first category is financial applications, providing users with more powerful ways of managing and entering into contracts using their money.
  • This includes sub-currencies, financial derivatives, hedging contracts, savings wallets, wills, and ultimately even some classes of full-scale employment contracts.
  • The second category is semi-financial applications, where money is involved but there is also a heavy non-monetary side to what is being done; a perfect example is self-enforcing bounties for solutions to computational problems.
  • Finally, there are applications such as online voting and decentralized governance that are not financial at all.

17