Saturday, November 5, 2016

Ethereum, or the Blockchain of Code


Software is incredibly powerful. Like most things in mathematics, the more powerful the thing being studied is, the harder it is to state useful things about it. In fact, the definition of programming as we know it came from Turing's seminal paper on the Halting Problem which told us what we couldn't do with a computer. It is from this that we draw the name "Turing-complete" to describe any system which is computationally powerful enough to run into the same limitations.

The Halting problem prevents us from knowing for sure how a computation will turn out without running. A slightly different problem that haunts many domains is that software is inherently disappearing. In calling a function, we trade the arguments for the end result. In the name of space efficiency, we later discard our arguments most of the time. At some point a variable is "useless" and the data it contained is erased.

Anybody who has gotten a bug report with an application state that seems borderline nonsense can understand the pain of this. Trying to reverse-engineer what one's own code did is what makes debugging so time consuming.

A slightly different problem caused by this is that it becomes important where code is run. When two systems cooperatively interact to compute something, something can go wrong at every single step of the way. Frequently, something does. It becomes the duty of an ultimately trusted entity to pick up the pieces and decide what the correct view of the world should be. In many situations, this is unacceptable.

The Solution

Ethereum tries to solve this problem by having everybody run the code, and by keeping around the arguments used to generate the result indefinitely. If this sounds expensive, it is. Someone using Ethereum to do numerical computation over a large amount of data is going to have to pay the network a lot for it.

Most applications aren't like this though. Most applications are thin, pretty wrappers around a data store that allow for simplistic manipulation. Messaging applications, commerce, social networks, and asset management applications are all examples of this.

The interesting thing is that when everybody is running the code, it is almost as if nobody is running the code. There's no need to keep servers online constantly to receive messages that might come with unknown frequency. The network as a whole provides uptime on behalf of the application writer. In this way, Ethereum applications are frequently called "serverless."

Ethereum promises a lot, and they do a pretty good job of delivering on it.

Architecture 

Ethereum is a blockchain technology, like many of the architectures that we've covered thus far. Human input into the network is done by sending transactions to the mining pool, which validates the transaction and adds it to a block to mine. After a miner manages to find the integer necessary to make the block's hash smaller than a determined difficulty, the block is considered part of the chain and the mining pool starts on the next block.

In financial blockchains, a transaction is always an exchange of value. Validating a transaction is thus validating that the person sending the money actually has the money. Bitcoin also has a scripting language which allows for very rudimentary computation. In Ethereum, use of the scripting language is the primary reason to use the network. Ethereum also contains a currency, which is used primarily to pay the transaction fee to the miners but can be sent between people as well. Validating an Ethereum transaction involves executing scripts held by the recipient of a transaction, which is paid for with the sender's transaction currency.

Contracts

A contract is born by making a transaction which contains the compiled code of a contract in the data field. After mining, this contract becomes an entity that can receive transactions.

A contract is really thought of as a self-contained piece of code that responds to payment messages by executing the script. This script execution can essentially do anything that a person interacting with Ethereum can do. Scripts can create new contracts, send transactions to other contracts, and save the results of computation to a permanent storage. Anything that requires computation or storage has a computational fee that is measured in "gas" and is what determines the mining fee.

What's interesting is that these Turing complete virtual machines live on the blockchain to serve their defined goals without any further need for the code author to interact with the network. As long as the people who need to run the code can afford the execution, the network will take care of everything.


Managing Turing Completeness with Gas Money

Now anybody familiar with the Halting problem will flinch at the thought of putting an open server out there which will run any code submitted to it. An infinite loop can be crafted to lock up a system. A malicious agent would be able to derail every node that tries to validate that transaction.

Ethereum handles this through fine-grained accounting. A transaction contains two figures that determine the cost to the sender. The STARTGAS counts the computational load of operations that the sender expects the contract to run. Operations which store data or are more computationally expensive have a higher price in gas. The GASPRICE is the rate that the sender is willing to pay per "gas" unit in terms of Ethereum's underlying currency.

A transaction verifier will run a contract until the gas runs out, or until the script finishes. If the script finishes then the remaining gas is refunded to the recipient and the miner keeps the product of the consumed gas and GASPRICE. If the gas runs out, all state changes are reverted and the miner just keeps the money. 


Scalability

Ethereum, like Bitcoin, faces the issue of storage. If Bitcoin were to handle the load of a modern credit card processing company, it would grow by about 1GB per hour. If Ethereum were to become mainstream, a naive implementation of it might face the same issues. As the blockchain grows, fewer and fewer nodes can afford to hold onto the entire chain. These "full nodes" have all of the power; if they were to form a malicious alliance then the history of the blockchain would be at risk.

Ethereum will likely scale a bit easier by the fact that the blockchain is not quite necessary to get a full view of the state of the network. Each Ethereum full node needs only to hold onto the global storage and the holdings of accounts, and can fold each incoming block into this.

Ethereum uses a modification of a Merkle tree optimized for addition and removal called a Patricia tree. This tree refers to subtrees of previous blocks by hash and tries to reduce hash invalidation. This is used to create a hash of the global application state that can be inserted into each block.

Ethereum has a formal method for finding the bad link in a poisoned chain. If a chain has a defect, it must occur between two blocks such that state N is correct and state N+1 is not. By walking through the blockchain from an expected good state, maybe even the initial block, a node can find the exact wrong state transition and can offer it to the network as proof that another miner had mined a bad block.

There is another kind of scalability worth considering, and that's the ability to do things cheaply. Ethereum's costs are relatively high currently, making it inappropriate for certain classes of high-throughput systems. Ethereum is moving to proof-of-stake in order to make it less computationally costly to mine, and therefore less expensive for the end user to run contracts.

The DAO

One cannot talk about Ethereum without talking about the problem that was the DAO. The DAO, or distributed autonomous organization, was an entity that would hold the users' funds in a joint account that would be utilized as the holders saw fit. The DAO was widely successful, raising $150 Million. 

Unfortunately, the contract behind the DAO had a few bugs. Furthermore, the creators of the project didn't expect such a success, and put all of the money into a single account. This enabled an attacker to leave the DAO in a state that threatened to have the funds made useless or able to be stolen outright. 

The solution that the Ethereum project saw was to provide miners with an option to choose to continue mining the version of the blockchain that contained the result of the DAO and the attacker's actions, or to mine a new version that relocated the funds so that caretakers of the DAO could refund those who bought in to the best of their ability.

The miners favored the refund, and the attacker had their funds taken from them by the network. This "hard fork" was met with both relief and unease. This showed that unpopular actors in a blockchain network can have the network decide to do whatever it wants with their funds. While this is no surprise, given the nature of the 51% attack vulnerability in blockchains, it burst the bubble of some of the most crypto-anarchist-libertarian supporters of cryptocurrency. 

Cryptocurrency assets are able to be seized. The global consensus of ownership is a democracy due to the nature of the underlying blockchain.
 
Ethereum Ecosystem

A language or virtual machine succeeds or fails based on the flexibility of implementations and the availability of existing libraries. Ethereum is no different. There are many programmatic implementations of the clients currently, but the exciting stuff is still on the horizon.

At this point in time, much effort is being put into Ethereum's Mist browser. Mist offers a user-friendly interface for the intricacies of distributed serverless applications. It functions as a client for the Ethereum network and prioritizes privacy and the user experience.

I look forward to seeing the distributed applications that people will build for this exciting new platform.



References

https://github.com/ethereum/wiki/wiki/White-Paper
https://github.com/ethereum/wiki/wiki/Mining
http://ethdocs.org/en/latest
https://blog.ethereum.org/2016/07/12/build-server-less-applications-mist/
https://github.com/ethereum/mist 
http://www.coindesk.com/understanding-dao-hack-journalists/

15 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. cryptocurrency

    ReplyDelete
  3. A great many people attempting to disclose blockchains jump at the chance to contrast it with a record. Whenever somebody makes an exchange, for example, a cash changing hands or another gadget being added to a system, it is recorded in the chain and anybody can track what has happened. Click here

    ReplyDelete
  4. So before we get into what a crytpocurrency is and how blockchain innovation may change the world, how about we talk about what blockchain really is. Ricona ICO

    ReplyDelete
  5. Some digital monetary forms, similar to Ripple and Radar, are still observed and checked by particular people or potentially organizations.coin launch

    ReplyDelete
  6. However any 'new' cryptographic money may offer law based investment when the virtual currency has diverse standards of administration and issuance in view of all the more socially based equitable standards. https://cybermentors.org.uk/

    ReplyDelete
  7. As of late, square chain innovation re-imagined the Internet and prompted the rise of another sort of web where computerized data is circulated without replicating. Double Ethereum

    ReplyDelete
  8. i read all kind of things for more know about crypto code you could look here

    ReplyDelete
  9. Blockchain gives the additional security of information not getting lost or tainted. ICO Video

    ReplyDelete
  10. The most vital point about "blockchain" is that it was intended to make applications that don't require a focal information handling administration. This implies in case you're utilizing a framework expand over it (to be specific Bitcoin) - your information will be put away on 1,000's of "autonomous" servers around the globe (not possessed by any focal administration).
    Blockchain ICO Marketing

    ReplyDelete
  11. In the event that you are one of the individuals who wishes to have an extensive learning of the innovation, simply bear on perusing the data gave underneath. www.binance.com

    ReplyDelete
  12. To this end, when taking a gander at "crypto", you have to first see how it really functions, and where its "esteem" truly lies...
    http://icowatchers.co

    ReplyDelete
  13. Blockchain can lessen the dangers of cheats and operational blunders in Stock Market exchanging. Not to overlook here that the exchanges would turn out to be relatively immediate. NASDAQ and Australian Securities Exchange are as of now investigating blockchain to lessen costs and enhance proficiency. ICO Marketing Agency

    ReplyDelete
  14. Please someone tel lme about the IcoPulse model about internet ICO and I will thank him. There are great talks about it and I'e heard that its one of the best so far. There is nothing that can stop it and people are enjoying it because of it. It will be the best thing for all of us.

    ReplyDelete
  15. Another open source, decentralized software platform. The currency was launched in 2015 and enables Smart Contracts and Distributed Applications to be built and run without any downtime. The applications on Ethereum platform require a specific cryptographic token - Ether. According to the core developers of Ethereum, the token can be used to trade, secure, and decentralize just about anything. ICO PR Distribution

    ReplyDelete