Pages

Tuesday, August 21, 2018

A Systems Design Analysis of Ethereum

            On July 30, 2015 Vitalik Buterin, a cryptography researcher, published the Ethereum White Paper. The Ethereum White Paper outlined a blockchain implementation that was Turing complete and stateful, two attributes that the first blockchain implementation Bitcoin did not have.[1] In this paper, I will provide an overview of Ethereum and blockchain technology, as well as a system design analysis of Ethereum.
            The difference between traditional distributed database systems and blockchains is that participants in a blockchain network are assumed to be bad actors, whereas distributed database systems require trust amongst the nodes. Attempts to develop Byzantine Fault Tolerant distributed database systems such as Byzantine Paxos require multi-stage messaging processes that are not scalable for internet size deployment.[2]
At the most basic level, a blockchain is a linked list data structure. In Ethereum, each node within this list has a variety of parameters, including the hash of the previous node in the list and three tree data structures.[3] These trees store the state of the Ethereum blockchain, a list of transactions, and a receipt log. The state of Ethereum is made up of accounts: externally owned accounts and internal accounts known as smart contracts. External accounts hold balances of the native cryptocurrency Ether, while smart contracts hold code. To add code to a smart contract or execute a contract’s function, a transaction that originates from an external account is sent. When a transaction is processed, a state change occurs. The third tree data structure stores event logs. Just decentralized databases have logs, Ethereum smart contracts will emit events that write to a log after performing some action.
            In order to maintain this data structure in a decentralized manner, an incentive scheme for validators is required. The validators of transactions in Ethereum are known as miners. When a transaction is sent to the network, it is stored in a pool of unconfirmed transactions. Miners will choose a set of transactions from this pool to validate. Validating a transaction involves running each transaction and ensuring that the transaction adheres to the rules of the Ethereum protocol. After validation, the miners will hash a group of transactions together into a block. If the resulting hash is lower than a required level, the miner can share this block with the rest of the network.
This process of validation is known as Proof-of-Work. Requiring miners to produce a hash that is lower than a certain value ensures network security because miners must spend computational power and electricity to produce these calculations. Miners will conduct these actions in exchange for the opportunity to earn a monetary reward.
            Other nodes in the network will run these shared transactions, which is a non-computationally expensive process. The transactions will either be accepted, if they adhere to Ethereum’s protocol, or rejected. Other nodes in the network have an incentive to accept the first valid transactions they receive because they will be interested in building off them as the next node in the linked list.
            Another way to think of Ethereum is as an incentive scheme. Simply put, miners who validate transactions are awarded a reward by validating transactions. Some miners may attempt to publish transactions that fraudulent i.e. sending a transaction from an account that does not have a large enough balance. When this transaction is propagated throughout the network, other nodes will see that the transaction does not abide by the Ethereum protocol and will not build off of it in their linked list. These malicious transactions will end up being a waste of work for the malicious miner because they will not receive a reward for these transactions.
           
System Analysis: Forward Compatibility Vs Backward Compatibility

            With any distributed systems, versioning and managing upgrades can be difficult. Since Ethereum is a decentralized network, software upgrades are very difficult. There are two different ways to upgrade blockchain software: soft forks and hard forks.
Soft forks occur when backward compatible upgrades are made to the protocol. This means that the new protocol is more restricted than the legacy protocol.[4] Nodes that have upgraded their software will see that the new blocks conform to the new consensus protocol. Old nodes will also see that these new blocks conform to the legacy protocol since the new protocol is a subset of the old protocol. If the majority of nodes have upgraded to the new software and an old miner submits a block, this block will be viewed as invalid by the network because it does not adhere to the stricter protocol. Miners who have not upgraded their software will have an economic incentive to do so, as their blocks will not be accepted by the network.[5]
Hard forks expand the existing protocol rules. During a hard fork, nodes that upgrade their software and nodes that do not upgrade their software will operate on two different chains. Legacy nodes will view the newly mined blocks as invalid because they correlate to a different consensus protocol and vice versa.
Soft forks are viewed as less dangerous to a network, as a chain split is less probable. In the case that a majority of miners do not upgrade their software and a majority of nodes do, a chain split will occur. In this situation, nodes will most likely be forced to downgrade their software.
Within the cryptocurrency community, soft forks have developed mixed opinions. Individuals such as Mike Hearn, a Bitcoin core developer, view soft forks as trickery. He argues that the forward compatibility of soft forks really just tricks legacy nodes into thinking updated transactions still follow the legacy protocol when they are actually different in nature.[6]
Vitalik Buterin and Jeff Garzik, a Bitcoin core developer, believe that soft forks do not let users opt into the new consensus rules.[7] In a blog post, Vitalik states, “[W]hat matters is not whether or not individual users have to perform the simple bureaucratic step of clicking a “download” button, but rather whether or not the user is coerced into accepting a change in protocol rules that they would rather not accept.”[8] Vitalik argues that within the blockchain space, individuals think that soft forks are less coercive because the individual does not need to actively upgrade their software. Instead, Vitalik argues that by being passive in a soft fork an individual accepts the new protocol changes, which they may be unaware of. Bitcoin core developer Eric Lombrozo offers a differing opinion. He states that the Bitcoin Improvement Process (BIP) that implements soft forks is community driven and individuals always have the choice to run different software if they are not pleased with the current iteration of the software.[9]
Historically, hard forks have been more contentious to implement than soft forks. This is due to the fact that chain splits diminish the network effects of a particular blockchain and hard forks tend to evolve around contested governance and philosophical issues. For example, Ethereum conducted a hard fork in the summer of 2016 after a hacker exploited a bug in an Ethereum application that took $50 million dollars from users.[10] This hard fork resulted in a chain split producing Ethereum and Ethereum Classic, the blockchain that did not return the lost funds to users. This hard fork decision raised questions amongst community members about the immutability of blockchain systems and the governance processes for decentralized networks.
Andrew Poelstra, a Bitcoin developer and employee at Blockstream, wrote an email thread arguing that hard forks increase the cost to maintain a node, which will lead to centralization. The reasoning for this statement is that hard forks will require individuals to actively monitor their software, which they might choose to outsource.[11] Others argue that forking allows a network to iterate faster and solve governance issues that a subsection of the community may have with the current network.[12]
 Apart from the diminishing network effects of splitting a network and determining who gets to use the original network name, legacy blocks remain valid on the new hard forked chain. This opens up the Replay Attack Problem. A replay attack occurs when an individual sends a transaction on the original chain at the time of a hard fork. Since this transaction will be valid with respect to both chains, this transaction can be broadcast to the new chain. The original sender may not know about this transaction that has been maliciously broadcast, which will result in the same state change.[13]

Naming:

            Right now, each type of account is identified by a unique 40-character hexadecimal representation. In an attempt to make these account names human readable and easier to interact with, a group of developers has begun working on the Ethereum Name Service (ENS). The ENS acts as a decentralized DNS system.
The ENS is made up of three Ethereum smart contracts: the registrar, the ENS registry, and the resolver. Nick Johnson, the lead engineer for the ENS system, stated that by breaking up the services of a DNS into three simple pieces, upgradability and forward compatibility are easier to maintain throughout the ENS.[14]
The ENS registry is a contract that maps the hash of a name to the name’s owner’s address and the address of the specified resolution contract. The registry will return the address of the resolution contract, which will then return the address of the object the owner has mapped the given name too. The registrar is responsible for assigning owners to top-level domain names.[15] (Currently, a multisignature account of the lead developers is the owner of the .eth TLD within the ENS registry contract.)
            The current implementation of the ENS is very primitive. For example, names can only be registered under the .eth TLD, and no name shorter than 7 characters can be registered. This is because there is no effective dispute resolution system for names within the registrar contract. J. Maurelian, an ENS contributor, wrote in a Medium article, “Who should control a name like microsoft.eth,  bankofamerica.eth, or vitalik.eth? How should a registrar allocate these names?” 15 The developers have effectively kicked the can down the road by waiting until a full registrar with dispute resolution has been implemented so more desirable names can be owned.
Within the ENS registry, a hash of the desired name is registered to the corresponding owner. This allows any type of foreign characters and upper and lowercase characters to be used in a .eth name.[16] Similar to the DNS, owners of a given .eth namespace are allowed to operate on any subdomains of that name.[17]

Compiler Versioning:
           
            All Solidity code, the programming language for Ethereum, requires that the source code includes a compiler version. As explained in the Solidity specs, “Source files can (and should) be annotated with a so-called version pragma to reject being compiled with future compiler versions that might introduce incompatible changes.”[18] The most current version of the compiler is 0.4.12. Any code written with a compiler version 0.4.0 or greater will be compilable with 0.4.12. When version 0.5.x is introduced, code with earlier compiler versions will not remain forward compatible.
From a development perspective, compiler versioning is inconvenient because individuals have to have multiple versions of the compiler installed. Legacy source code may not remain supported far into the future, as individuals will remove those compilers from their systems. While researching this paper, I came across a Github comment section where individuals wanted the compiler version to be included in the binary of the Solidity code. The rationale is that any individual would then be able to validate the given smart contract code.[19]
            While Ethereum is a truly decentralized database, many of the same system design problems of centralized systems exist within its implementation. While it is still in the early days for blockchain implementations, blockchains enable systems to be built that do not require permission, centralized points of control or trust.





[1] https://github.com/ethereum/wiki/wiki/White-Paper
[2] https://www.quora.com/Why-would-you-use-blockchain-over-a-distributed-consensus-protocol-like-Paxos-or-Raft
[3] https://github.com/ethereum/wiki/wiki/White-Paper#merkle-trees
[4] https://lightco.in/2017/07/30/bitcoin-fork-split/
[5] https://www.coindesk.com/information/hard-fork-vs-soft-fork/
[6] https://medium.com/@octskyward/on-consensus-and-forks-c6a050c792e7
[7] https://bitcoinmagazine.com/articles/understanding-soft-forks-a-core-developer-s-view-on-network-monopoly-1474990034/
[8] https://vitalik.ca/general/2017/03/14/forks_and_markets.html
[9] https://bitcoinmagazine.com/articles/understanding-soft-forks-a-core-developer-s-view-on-network-monopoly-1474990034/
[10] https://www.coindesk.com/ethereum-executes-blockchain-hard-fork-return-dao-investor-funds/
[11] https://lists.launchpad.net/mimblewimble/msg00249.html
[12] http://unchained.forbes.libsynpro.com/unconfirmeds-first-episode-olaf-carlson-wee-of-polychain-capital-on-governance
[13] https://cointelegraph.com/news/if-hard-fork-happens-chain-backed-by-majority-of-miners-will-likely-win
[14] https://www.youtube.com/watch?v=pLDDbCZXvTE
[15] https://medium.com/the-ethereum-name-service/explaining-the-ethereum-namespace-auction-241bec6ef751
[16] https://docs.ens.domains/en/latest/faq.html
[17] https://docs.ens.domains/en/latest/userguide.html
[18] https://solidity.readthedocs.io/en/develop/layout-of-source-files.html#version-pragma
[19] https://github.com/ethereum/solidity/issues/529

Thursday, March 22, 2018

I have moved to Medium

For my most recent articles, please look at my Medium page or see below


1) How RDV Venture Fellows Think About Early Stage Startups
An article about how to analyze early stage startups
2) Equity Crowdfunding w/o "The Blockchain"
You don't need a blockchain to crowdfund
3) The Future of Problem Solving
An article about how bounties/contractors will change the way we solve problems in companies
4) How Do Payments Work?
A research paper about how payment networks such as the ACH, wires, and credit cards work
5) When Was the Last Time You Sweat Through Your Jeans
An article about my experience working as an irrigator on a cattle ranch

Monday, July 17, 2017

Intro 2.0 to Smart Contracts (Very High Level)

I read an old blog post this morning called Intro to Smart Contracts. After spending the last year learning about blockchain technology, I realized that this article brought no value to anyone that read it. I apologize to the 14 people that did.
The point of this article is to actually explain what smart contracts are at a very high level.
When you buy Ether or Bitcoin, the coins that you buy are sent to a unique address. With Bitcoin, no coins are actually held at this address. The address acts as a unique identifier, like a bank account number, that allows the total of the transactions to and from this address to be calculated. Bitcoin can be thought of as a ledger that records the deposits and withdrawals from accounts. When you send a transaction via the Bitcoin network, your old balance is reduced by some amount and another account’s balance is increased by this amount. But no physical value is ever moved.
Ethereum works a bit differently. Ethereum stores a number of coins you own at an address in something called a smart contract. The ability to store information at these addresses is called the Ethereum State. Whereas Bitcoin only stores transactions that have been sent in the Bitcoin blockchain, any type of data can be stored in the Ethereum state and thereby the Ethereum blockchain. The information that is stored could range from the amount of Ether you have to the type of life insurance you own.
A smart contract is an address that holds computer code. Transactions can be sent to this address that will trigger specific functions. For example, a user could program and deploy a smart contract that holds the name of a person. When a transaction is sent to this function with a name, the state of the smart contract will be changed so that it now stores the name that was sent to it. Another person could send a different transaction to this smart contract that will return the name that is stored in this smart contract. While this is a very boring example of what smart contracts can do, smart contracts enable Ethereum to operate as a universal computer. Due to the decentralized nature of Ethereum, there are smart contracts that anyone can send transactions to. (You can also create smart contracts that only execute functions when certain people send transactions to it).
Slock.it is using the functionality that smart contracts enable in some very cool use cases. They are developing a mini Ethereum computer that allows physical objects such as bike locks, door locks, or electric charging stations to be operated by a smart contract. You can send the bike lock a transaction with a specified amount of Ether that would allow you to use it for a duration of time. This is different than a Hubway station because the only infrastructure that would be required is a blockchain enabled bike lock.
In my previous article, I stated that smart contracts use conditional statements like a contract in a bet. While smart contracts execute certain functions if a transaction containing some data is sent, smart contracts aren’t only used to write conditional contracts. Many of the use cases regarding conditional contracts, such as the Patriots winning, are difficult to implement on Ethereum. The reason for this is that the Patriots winning is an off chain event, and the Ethereum blockchain needs to be notified of this event somehow. There must be a certified off chain authority that can inform the smart contract of this condition when it occurs. Every node in the blockchain needs to receive this same exact information so that consensus can be reached. Gnosis, a prediction market platform, has developed a solution to this hurdle, but it requires a certified off chain person informing the blockchain what the outcome of the result was.

Tuesday, September 6, 2016

Transferring Assets via Blockchain Technology


Another feature that has generated lots of excitement within the Blockchain 2.0 realm is the ability to transfer assets using the blockchain. While bitcoins have provided people with the ability to send money through the Internet, without the fees of middlemen such as banks, the ability to transfer assets through the blockchain would allow people to trade their houses, cars, or shares of stock without using traditional middlemen such as realtors, stock brokers, or auto salesman. This would also mean that assets would transfer immediately after they were purchased, which would prevent incidents like this from occurring. Colored coins and Counterparty are two technologies that I found that seemed to be the most talked about among Bitcoin and blockchain forums.
Colored coins function as regular Bitcoin transactions. To create a colored coin that represents some asset, all one has to do is take a bitcoin and add metadata to this “coin.” This added data would represent some asset such as one share of Ford or a house in Florida.1 (Bitcoins do not actually exist because Bitcoin is really just a ledger of inputs and outputs into somebody’s Bitcoin wallet. When computers check to see if an account has enough bitcoins, they are just searching for previous inputs into that account. Adding data to a bitcoin is really adding data to some bitcoin transaction in which all parts of that transaction are colored with this added data.2) This new coin functions just like a regular bitcoin transaction. Here is a link if you want to learn how to add this metadata to create a colored coin.
There are some companies such as Overstock.com that have received SEC approval to issue their publicly traded stock as colored coins.1 Most colored coins are not backed by a legal contract and are based on trust that the other party has the physical asset to back their colored coin.
             From scrolling through Reddit and Quora forums, it seems that many people are opposed to colored coins because they believe they will cause blockchain bloat. Blockchain bloat is classified as transactions within the Bitcoin blockchain that are not used for currency transactions, like colored coins.3 While the added data to Bitcoin transactions will increase the amount of information being processed on the network, which could slow processing speeds down, miners who process colored coin transactions are still receiving a processing fee from these transactions.4 This view that blockchain bloat is akin to email spam is held among some purists that believe that the Bitcoin blockchain should be kept for only pure Bitcoin transactions.
Another downside of using colored coins is that if one sends a colored coin to an address that does not have colored coin capabilities, the colored coin will be lost forever. There are specific computers within the blockchain that can understand which bitcoin transactions are colored coins. This is how colored coin wallets operate as well.4
            In an article by Richard Gendal, he discusses how the exchange process of colored coins works. When someone agrees to buy a colored coin from another party, there needs to be a system in which the buyer is guaranteed that they will receive this asset coin when they send their money. Colored coin technology ensures this by having the seller put their asset coin into a escrow account of sorts, which functions outside the blockchain.5 This goes against Bitcoin ideology because there is now a third party that the individual must put their faith in. The problem with trusting a third party is that if this company failed while holding someone’s assets, those assets could be lost.
Counterparty, a competing technology to colored coins, uses a bid/ask system to complete the exchange process. A seller will make an ask price, and a buyer will make a bid price. When these two offers are matched, the seller is required to honor the price they said they would sell the shares at, and the buyer must honor the price they stated they would pay for the shares. Like stock exchanges, Counterparty locks these assets into place until the offer has expired. Coded into the protocol is an automatic exchange system that forgoes a party outside of the blockchain. But Richard Gendal states that the problem with this system is that all these bid/ask prices are stored in the blockchain, meaning that temporary transactions are stored permanently.5
            Unlike Colored Coins, Counterparty uses its own currency to digitize assets onto the blockchain. This native currency is called XCP. XCP came into existence when individuals sent bitcoins to a Bitcoin wallet in return for XCP. The bitcoins that were sent to this wallet were destroyed, so that Counterparty and the creation of XCP would not be viewed as a get rich quick scheme.12 The Counterparty website likens this to the process of mining bitcoin as “Bitcoin miners also destroy one resource [Energy] to get another [Bitcoins].”
            While Counterparty has its own currency, the transactions within Counterparty are merged onto the traditional blockchain network. There is special computer code that recognizes Counterparty transactions and establishes an independent Counterpary ledger. Since the same nodes that mine bitcoin process Counterparty transactions, there is a bitcoin fee for every transaction within Counterparty. Besides the bitcoin transaction fee, it costs 0.5 XCP to create an asset token. This 0.5 XCP that is used to create an asset token is burned (See issuance strategy above), causing XCP to be deflationary.7




Bibliography:

1) Digiconomist. "Adding Metadata to the Blockchain, Part 1 - Digiconomist." Digiconomist. 2015. Accessed August 09, 2016. http://digiconomist.net/adding-metadata-blockchain-part-1.

2) "How Do Bitcoin Transactions Work? - CoinDesk." CoinDesk. http://www.coindesk.com/information/how-do-bitcoin-transactions-work/.
3) Wagner, Andrew. "Ensuring Network Scalibility: How to Fight Blockchain Bloat." Bitcoin Magazine. 2014. https://bitcoinmagazine.com/articles/how-to-ensure-network-scalibility-fighting-blockchain-bloat-1415304056.
4) "Beginners." Coloredcoins. 2015. Accessed August 03, 2016. http://coloredcoins.org/inner-page-3-1/.
5) Brown, Richard Gendal. "A Decentralized Securities Trading and Settlement System Is Being Built Hidden in Plain Sight." Richard Gendal Brown. 2014. Accessed August 02, 2016. https://gendal.me/2014/06/10/a-decentralized-securities-trading-and-settlement-system-is-being-built-hidden-in-plain-sight/.

6) "Why Proof-of-Burn." Counterparty. March 23, 2014. Accessed August 06, 2016. http://counterparty.io/news/why-proof-of-burn/.


7) "Assets." Counterparty. Accessed August 05, 2016. http://counterparty.io/docs/assets/.