Analysis of Data Structures on the Ethereum Blockchain/Current draft

= Detailed scenario and requirements =

A smart, connected toaster is of no value unless it produces better toast.

—  The Scenario Overview in chapter 1 demonstrates the many envisioned use-cases for the blockchain. Ethereum is in rapid development and is planning on releasing four major versions within the next year, with the last version changing the fundamental consensus algorithm. What these upgrades will change the platform in detail, is uncertain. Hence will this thesis assume the Ethereum platform as it stands at the time of writing, and will avoid too much speculating on coming changes. The scenario selected is consequently a scenario which has a short time to market and could use today’s version of Ethereum.

published the idea of using the blockchain for the IoT in the. The corresponding scenario examines the idea of a smart IoT washing machine. The report states that the motivation behind IoT has to be creating better products for the end-user. It is argued that better products can be achieved through new digital economies and creating collaborative value, and that these elements can be achieved with “P2P”, “trustless communication” and “decentralized autonomy” [p.8]. These three underlying technologies will be examined in chapter 3.



Pureswaran et al. explains new digital economies this way: “The IoT creates the ability to digitize, sell and deliver physical assets as easily as with virtual goods today. [...] In a device driven democracy, conference rooms, hotel rooms, cars and warehouse bays can themselves report capacity, utilization and availability in real-time.” [p.13] Pureswaran et al. further claims that “By reducing transaction and marketing costs, and enabling partnerships for innovation, the IoT will create new collaborative value.” [p.15]

Scenario
The report envisions autonomous transactions between a washer, a retailer and other parties. The scenario is broken down into three features. The first feature is to remove need for refilling the detergent compartment of the washer. The washer can, by be given an identity on the blockchain and a corresponding smart contract, start it’s autonomous life. The smart contract has some parameters set by either the vendor or the owner. When the washer is running short on detergent, the washer will autonomously negotiate with the network before purchasing more. The washer takes the set parameters into consideration when negotiating e.g. delivery time, environment and authorized reseller.

This feature can increase competition in the marketplace by removing the influence of the brand and the shelf-placement with a smart contract making the best choice for the washer and the owner. As the marketplace is online, can new players join the competition easier, while it’s today is hard to stand up to huge companies in the marketplace. Some homes have different price tiers depending on their current power consumption. Others are self-sufficient different times of the day e.g. from solar panels. The washer negotiates with other smart appliances in the home to save money. Some devices have power saving modes they can enter for a limit period e.g. a freezer, other devices can communicate with the owner e.g. choosing between switching off the TV or delaying the washing machine. Lastly does the washer do autonomous self-service. The washer detects a potential air filter failure and finds an authorized service center. The service center confirms that it is authorized and proceeds with validating the units warranty. Similar to when purchasing detergent, will the machine make an assessment of the best service center to choose or present the top choices to the owner. A directly updated marketplace of authorized service centers will allow the end-user to quickly making the currently best choice for her. It also opens the market for new players in the service marketplace, one can expect one of the challenges when being new is getting users to compare the quality and price of service with the regular chosen company. The autonomous self-service keeps the machine working, removing frustrating for the owner. It also tries to save money and opens the marketplace for new players.

Thus will this thesis focus on describing the Ethereum blockchain and the problems by implementing this scenario.

Technological challenges

 * Anonymity The blockchain has been called pseudo-anonymous because no one knows your identity on the network, but the network is transparent and all activity is visiable to everyone. Can someone make a connection between your real identity and the one on the blockchain, can the same person see every activity ever performed by the account. Mixers can make it harder to make the connection between the two identities.
 * Privacy The contracts are run by the miners. Transactions are encrypted, but Ethereum does not have any kind of homomorphic encryption enabled, meaning all data that is to be opreated on by the network, will be available to everyone, including the account making the transaction. have outlined how to creating a similar network to Ethereum with homomorphic encryption.
 * Scalability There is a balance between the security through decentralization and the scalability of the blockchain. If the bar for mining i.e. helping decentralize the network, is set to a stage where many computers can mine without extra investment, the network is not able to perform that many transactions per second. There is a lot of research going into the problem where one of the proposed solutions is sharding.
 * Wasted power usage with mining With thousands of machines mining for proof-of-work to secure the blockchain, only about four correct solution are accepted every minute. This means that a massive number of calculations are thrown away. Primecoin is using the mining to search for prime number chains, while Ethereum is planning on moving to proof-of-stake, reducing the power consumption with 41%.
 * Legality With the rapid adpotion of the blockchain, is it uncertain how lawmakers will react to the technology. Government regulation is already in place in New York where a BitLicense is needed to deliver cryptocurrency services.
 * timestamping lorem ipsum
 * Arbitrary Proof of Computation lorem ipsum
 * Code Obfuscation lorem ipsum
 * Privacy reputation systems
 * ny parameter for koden: gas lorem ipsum

I will focus on Solidity, efficiency, gas etc

= Background =

Ethereum Accounts
Ethereum is state transition system, using the blockchain technology to achieve decentralized consensus. The blockchain was invented by S. Nakamoto and is what made Bitcoin possible []. The transactions in Bitcoin include small scripts opening for more advanced transactions then a simple change of ownership. The Bitcoin scripting language is not Turing complete and does not include loops, as this code can be uploaded by anyone and is executed by any computer in the network. Ethereum wants to open for more advanced scripts, with turing completeness, which they call smart contracts. Ethereum achieve this by having the transaction sender pay for the resources consumed with gas. This way a denial of service will cost the attacker proportionally for every command, and accidental loops in transactions will run out of gas.

Messages and Transactions
The state in Ethereum is built up of ’accounts’. An account is what you communicate with, being other peers or contracts in the network. A contract is a chunk of code living in the Ethereum network which can be called by users. Contracts can also be called by other contracts, allowing for a network of decentralized code to communicate together without human intervention.

While most blockchain technologies use the Unused Transaction Output (UTXO) paradigm, Ethereum instead uses Accounts.

Blockchain, Proof-of-work and mining
The way S. Nakamoto opened for consensus in a decentralized network was by not only allowing any node to participate in maintaining the validity of the blockchain (a ’miner’), but also by incentivising it. Transactions are grouped in blocks and miners download all blocks, back to the first block, the genesis block.

Block
a block is an arbitrary number of transactions bundled together. The validity of the transactions is checked and cryptographic signatures (and checksums?) [] are used to prove that the block of validate transactions is a valid block. A miner creates a checksum of


 * all new and valid transactions
 * address of the previous block
 * a proof-of-work

“Easy to verify solutions Hard to find solutions Difficulty of finding solutions can be precisely quantified Provably inseparable from the block it secures”

Contracts &amp; the Ethereum Virtual Machine
Kontrakter skrives i solidity, serpent, Mutan (C) eller LLL (Lisp) EVM (virtuell maskin)

Using Ethereum
With this basis they propose an autonomous decentralized peer-to-peer platform for the IoT where nodes do not need to trust other peers using cryptographic tools. IBM propose achieving the trustlessness with the blockchain technology. The blockchain also solves the problem of reaching consensus with no master and liquefying assets though cryptocurrency. IBM has proposed assembling a handful of technologies from the bottom up, which they have named the ADEPT platform.

IBM proposes an architecture up to the application layer, but what can a full stack look like, from the application presented to the user, down to the operating system running on the things. IBM leaves the top of the abstraction layer open by just saying that this is where the UI and Business Logic is. IBM furthermore contributes with some application layer examples: ’Appliance Self-service, Asset Sharing, Virtual Credit Management, Resource Bartering and Diagnostics’