P2P Electricity Transaction Between Ders by Blockchain Technology
Total Page:16
File Type:pdf, Size:1020Kb
DEGREE PROJECT IN COMPUTER SCIENCE AND ENGINEERING, SECOND CYCLE, 30 CREDITS STOCKHOLM, SWEDEN 2018 P2P Electricity transaction between DERs by Blockchain Technology RUOGU LI KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE KTH Royal Institute of Technology School of Electrical Engineering and Computer Science Master’s Thesis in Computer Science and Computer Engineering P2P Electricity transaction between DERs by Blockchain Technology Author: Ruogu Liu Supervisors: Anne Håkansson Xue Wang Examiner: Prof.Mihhail Matskin, KTH, Sweden ii Abstract The popularity of blockchain technologies increases with a significant rise in the price of cryptocurrency in 2017, which drew much attention in the academia and industry to research and implement new application or new blockchain technology. Many new blockchains have emerged over the last year in a broad spectrum of sectors and use cases including IOT, Energy, Finance, Real estate, Entertainment, etc. Despite many exciting research and applications have been done, there are still many areas worth investigating, and implementation of the blockchain based distributed application are still facing much uncertainty and challenging since blockchain is still an emerging technology. Meanwhile, the energy sector is under a transition to be digitalized and more distributed. A global technology revolution has disrupted the conventional centralized power system with distributed resources and technologies, like photovoltaic units (PV), batteries, electric mobilities, etc. The citizens then have control of their generation and consumption profiles. The purpose of this master thesis is to explore existing blockchain technology, and smart contracts such as IOTA, NEO, Ethereum Tobalaba, which can be adapted in the energy sector. Within this thesis, blockchain and the smart contract is proposed as a way of building distributed applications for a p2p transaction use case in the energy asset management platform. A design science research methodology is applied for the artifact development and evaluation for the research result. The design was implemented on Ethereum and tested on Tobalaba public network with ether and GAS. The evaluation shows the artifact for the p2p transaction in energy asset man- agement platform fulfill the completeness, and correctness of the design requirement. The result of the performance test on Tobalaba networks shows a correlation between GAS consumption and transaction time. Keywords— Blockchain, Peer-to-peer, Energy System, Ethereum, Tobalaba, Transaction, Energy asset Referat Den popularitet av blockchain-tekniker ökar med en signifikant ökning av kryp- tokurrencyprisen år 2017, vilket gav stor uppmårksamhet i akademin och indus- trin för att undersöka och implementera ny applikation eller ny blockchain-teknik. Många nya blockblock har uppstått under det senaste året inom ett brett spektrum av sektorer och anvånder fall som IOT, energi, finans, fastigheter, underhållning etc. Pågrund av många spånnande undersökningar och applikationer finns det fortfarande många områden som år vårda att undersöka, och implementeringen av den blockchain- baserade distribuerade applikationen år fortfarande konfronterad med stor osåkerhet och utmanande eftersom blockchain fortfarande år en uppkommande teknik. Under tiden år energisektorn under en övergång att bli digitaliserad och mer distribuerad. En global teknologirevolution har stört det konventionella centraliserade kraftsys- temet med distribuerade resurser och teknologier, såsom fotovoltaiska enheter (PV), batterier, elektrisk rörlighet etc. Medborgarna har dåkontroll över sina generations- och konsumtionsprofiler. Den hår inriktningen år att undersöka befintliga blockchainteknologi och smarta kontrakt som IOTA, NEO, Ethereum Tobalaba, som kan anpassas inom energisek- torn. Inom denna avhandling har blockchain och the slimme kontrakt föreslagits som en metod för byggfördelade applikationer för en p2p-transaktionsanvåndning i energiförvaltningsplattformen. En designvetenskaplig forskningsmetodik anvånds för artefaktutveckling och utvårdering av forskningsresultatet. Designen genom- fördes påEthereum och testades påTobalabas offentliga nåtverk med eter och gas. Utvårderingen visar att artefakt för p2p-transaktionen i plattformen för energiför- valtning hanterar designkravets fullståndighet och korrekthet. Resultatet av re- sultatprøven påTobalaba-nåtverket visar en koppling mellan GAS-konsumtion och transaktionstid. Keywords— Blockchain, peer-to-peer, energisystem, Ethereum, Tobalaba, Transaktion, Energi tillgång Acknowledgment I am deeply thankful to my examiner Prof.Mihhail Matskin and supervisor Anne Håkansson. Without their guidance, this thesis would not have been possible. I would also like to thank my current company Power2U and my co-supervisor Xue Wang and Dr.Arshad Saleem at Power2U that provide me with this research project. Special thanks to the support of E-regio project, under the management of EU Era-net program. Stockholm, 15th. December 2018 Ruogu Liu Contents List of Figures xi List of Tables xiii List of Glossary xiii 1. Introduction 3 1.1. Background . 3 1.2. Problem.................................. 5 1.3. Purpose and Goal . 6 1.4. Ethics and Sustainability . 6 1.5. Contributions . 7 1.6. Choice of Methodology . 8 1.7. Outline .................................. 8 2. Technical Background 11 2.1. Cryptography . 11 2.1.1. Hashing Functions . 11 2.1.2. Digital Signatures . 12 2.1.3. MerkleTrees ........................... 13 2.1.4. Consensus Algorithm . 14 2.2. Blockchain Technology . 15 2.2.1. NEO . 16 2.2.2. IOTA ............................... 18 2.2.3. Ethereum ............................. 20 2.2.4. Powerledger . 22 2.2.5. Tobalaba . 23 2.3. Related Research . 24 2.3.1. ADMM Optimization . 24 2.3.2. IOTA Micro Transaction . 25 3. Implementation 27 3.1. System Description and Requirements Analysis . 27 3.1.1. System Analysis . 28 3.1.2. Design on the Smart Contract . 29 3.2. Implementation of Smart Contract on Energy Web UI . 32 3.2.1. Deployment on EWF web UI . 32 Contents 3.2.2. Execute contract on EWF web UI . 32 4. Result and Evaluation 37 4.1. Evaluation . 37 4.2. Result ................................... 38 4.2.1. Descriptive analysis . 38 4.2.2. Functional testing . 38 4.2.3. Performance analysis . 40 4.2.4. Outcome . 43 5. Conclusion 45 5.1. Discussion................................. 45 5.2. Limitations of this work . 45 5.3. Futurework................................ 46 Bibliography 48 Appendices 51 A. Source code Ethereum 53 B. Source code NEO 57 x List of Figures 1.1. Bitcoin Price based on Coindesk . 4 1.2. The Blockchian Graph . 4 1.3. Energy Trading Rrice with DSO and Retailer in Sweden. Graph and Data provided by Xue Wang, Power2U AB . 7 1.4. Design Science Approach Overview Retrieved and Adapted from Hvner, 2004 . 8 2.1. Digital Signature in Bitcoin. 12 2.2. MerkleTree................................ 14 2.3. NEO Virtual Machine . 16 2.4. Tangles and Bundles in IOTA Network . 18 2.5. Transaction using IOTA Flash Channel . 19 2.6. Comparison of Blockchain Technologies: Ethereum, NEO, IOTA . 20 2.7. The Ethereum Network and its Interaction with Metamask. 21 2.8. Ethereum based Dapp architecture and its Interaction with web3 lib and front-end application. 21 2.9. Technical Layer of Power Ledger (15) . 22 2.10. Two Type of "token" issued by Power Ledger Platform. 23 2.11. Comparison of an efficient market in which the optimal quantity Q* is cleared at price P(Q*), and a market operated by a monopoly who is able to charge separate prices for generation and consumption.(4) 25 2.12. IOTA charger Proof of Concept by ElaadNL (20) . 26 3.1. P2p Transaction for Smart Energy Asset Management System . 28 3.2. Smart Contract Application Interface implemented on NEO smart contract.https://github.com/liuruogu/NeoEnergyTransaction . 29 3.3. Overview of Different Electricity and their Interactions with the Blockchain and System of Smart Contracts which exist on the Blockchain. 30 3.4. Create the Account on EWF web UI . 33 3.5. Initiate a Contract . 33 3.6. Deploy Smart Contract on EWF web UI. 34 3.7. Deployed Contracts available on EWF web UI, . 34 3.8. Execute a Smart Contract on EWF web UI. 35 3.9. Transaction records in Tobalaba Network. 35 4.1. GAS Consumption on PV Smart Contract(GAS) . 41 4.2. GAS Consumption on EV Charger Smart Contract(GAS) . 41 List of Figures 4.3. Transaction Execution time on EV Charger Smart Contract(s) . 42 4.4. Transaction Execution time on PV Smart Contract(s) . 42 xii List of Tables 2.1. Consensus Algorithms for Usage in Blockchains. 15 3.1. List of Action by Participants . 31 4.1. List of Descriptive Actions by Participants and Implementation . 38 4.2. Table of Experiments Environment . 40 4.3. GAS Consumption on TOBALABA Network(GAS) . 40 EV DSO TSO DERS IOTA NEO M2M p2p POW POS POA POC IOT KWh OCPP EVM PV Consensus DAPP Digital Signature Smart contract Solidity Tobalaba Flash channel Abbreviations and Glossary Consensus all participants of the network agree on the validity of the transactions. DAPP Decentralized Application. DERS distributed energy resources. Digital Signature is a digital code generated by public key encryption. DSO Distribution System Operator. EV Electric vehicle. EVM Ethereum Virtual Machine. Flash channel Flash is a bi-directional off-Tangle payment channel. IOT Internet of Things. IOTA is the Blockchain for Machine Economy. KWh Kilowatt hours. M2M Machine-to-machine. NEO is the blockchain for digitized assets. OCPP Open Charge