Emerging Design Patterns for Blockchain Applications

Emerging Design Patterns for Blockchain Applications

Emerging Design Patterns for Blockchain Applications Vijay Rajasekar1, Shiv Sondhi1, Sherif Saad1 and Shady Mohammed2 1School of Computer Science, University of Windsor, Canada 2Faculty of Computer Science & IT, Ahram Canadian University, Egypt Keywords: Software Engineering, Software Patterns, Empirical Analysis, Anti-patterns, Blockchain. Abstract: Blockchain or Distributed Ledger Technology (DLT) introduces a new computing paradigm that is viewed by experts as a disruptive and revolutionary technology. While bitcoin is the most well-known successful appli- cation of blockchain technology, many other applications and sectors could successfully utilize the power of blockchain. The potential applications of blockchain beyond finance and banking encouraged many organiza- tions to integrate and adopt blockchain into existing or new software systems. Integrating and using any new computing paradigm is expected to affect the best practice and design principles of building software systems. This paper summarizes our ongoing research on collecting, categorizing and understanding, existing software design patterns when building blockchain-based software systems. It collects and categorizes the existing software (design and architectural) patterns that are commonly linked to blockchain and distributed ledger technology. We provide an informal analysis of the identified patterns to highlight their maturity. Finally, we discuss the current research gap in software engineering for blockchain-based applications and propose potential research directions. 1 INTRODUCTION of Decentralized Applications or DApps. The devel- opment of DApps in Ethereum is achieved through writing smart contracts using Solidity and implement- A blockchain is a distributed store or ledger of records ing other parts of the DApp using Web3 (Buterin, that is usually used to store transactional data. How- 2014). ever, there is no restriction on the type of data that can be stored health records for health applications, own- Today, there are many blockchain/distributed ership records for property management and even ex- ledger platforms that enable the development ecutable code in the form of smart-contracts. This in- of blockchain-based applications or integrating dicates how flexible blockchains can be. Blockchain blockchain into existing software systems. For technology came into existence when a white paper instance, we have Hyperledger Fabric, Quorum, titled Bitcoin: A peer-to-peer electronic cash system Corda, Ripple, Tezos, Sawtooth, BigChainDB, was announced by Satoshi Nakamoto in 2008. How- OpenChain, etc. All of these platforms provide ever, the word blockchain was never used in the paper technology stacks that enable the developers to build specifically. The paper discusses a peer-to-peer ver- and blockchain-based applications. The recent devel- sion of electronic cash that overcome a well-known opments of blockchain platforms and the widespread limitation in electronic cash (cryptocurrency) known of blockchain-based applications introduced new as double-spending. challenges to the software development commu- One of the major milestones in blockchain tech- nityblockchain developers encountering several nology was the introduction of a blockchain frame- challenges when working with blockchain. To solve work named Ethereum (Buterin, 2014). It pro- these challenges, blockchain developers introduced vides a powerful application stack embedded within new software design patterns or adapted existing each node of the Ethereum network, known as the patterns. Ethereum Virtual Machine. It also provides Solidity, Software design patterns played a significant role a programming language for writing smart contracts, in software engineering practice and education since inspired by many object-oriented programming lan- the term was coined (Gamma et al., 1993). De- guages, to simplify and standardize the development sign patterns are generally considered as the accepted 242 Rajasekar, V., Sondhi, S., Saad, S. and Mohammed, S. Emerging Design Patterns for Blockchain Applications. DOI: 10.5220/0009892702420249 In Proceedings of the 15th International Conference on Software Technologies (ICSOFT 2020), pages 242-249 ISBN: 978-989-758-443-5 Copyright c 2020 by SCITEPRESS – Science and Technology Publications, Lda. All rights reserved Emerging Design Patterns for Blockchain Applications practices applied to software system design, which recorded before any further transactions can be made. help in making the system portable, clean and effi- A disadvantage is that the pattern is counter-intuitive cient. It is not entirely clear how design patterns af- in the sense that it is generally good practice to wait fect the performance of a system; although a few tra- for a function to execute successfully, before making ditional patterns do optimize memory consumption any state changes. (Flyweight Pattern) and speed optimization (Proxy Secure Ether Transfer Description - This is in- Pattern). fact an anti-pattern. The low-level Solidity function, These patterns however, are not a one-size-fits-all address.call() should not be used to invoke a con- utility. Different systems benefit from different pat- tract. Instead, the high-level address.send() or ad- terns; so selecting the correct ones for your appli- dress.transfer() should be preferred because they set cation is important. Similarly, when new technolo- a limit on the amount of gas1 the contract can forward gies crop up, they create the need for new design pat- to any invoked contract. (Wohrer and Zdun, 2018; terns. Examples include technologies like cloud com- Whrer and Zdun, 2018) puting, the internet of things and blockchain. Since Need - Since the low-level function will forward all these technologies differ significantly from traditional remaining gas to the invoked contract, using it allows software systems, they require design patterns that are further invocations to be made, provided the gas sent suited to their unique attributes. Here, we attempt to in the original call is sufficiently larger than the re- find and validate the effect of design patterns on the quired minimum. efficiency, security and reusability of blockchain ap- Consequences - The advantage is that if the amount plications. of gas transferred is capped, the extra invocations will This short paper is organized as follows. In sec- end eventually due to insufficient funds. tion 2, we identity and discuss common blockchain Oracle Description - A contract or blockchain-based design patterns. In section 3 we provide brief empir- application may sometimes need to access informa- ical analysis and discuss how the patterns have ma- tion from the external world. The oracle pattern uses tured with time. Finally, in section 4 we provide the a third-party verifier to verify that information stored conclusion for our findings and our stance on the mat- off-chain is valid, before it can be relayed to the ter. blockchain. (Xu et al., 2018; Whrer and Zdun, 2018; Zhang et al., 2018) Need - There are several scenarios where a blockchain 2 BLOCKCHAIN DESIGN may need to access external data. This depends on the application’s use-case but a few examples are: PATTERNS stock market data, weather-related data and bank ac- count information. Since such information is stored Several studies have been proposed in the literature to off-chain, it’s validity may be compromised and the introduce some new patterns or to extend existing pat- trust generated by the blockchain can be compro- terns to fit blockchain-application requirements. This mised without even attacking it directly. section compiles the patterns found and presents each Consequences - Some considerations when using an one with a description, the need for the pattern and oracle are to be sure you can trust the third-party. the consequences of using it. Wherever applicable, It can also be argued that this introduces an element real-world context is also provided. of centralisation in the blockchain-based application. Checks-Effects-Interactions Description - The con- But that is something that can be controlled while de- tract first checks whether the necessary conditions are veloping the oracle, as shown by (Griffith, 2017) and met, then makes necessary changes to the contract (Costa, 2019). state (effects) and finally passes control to another Off-chain Datastore Description - If the raw data to contract (interactions) (Wohrer and Zdun, 2018). be stored on the blockchain takes too much memory, Need - If the ”interactions” occur before the ”ef- calculate a hash for the entire raw data and store this fects” are recorded and the invoked contract makes on the blockchain instead.(Lu et al., 2018) a callback to the original one, the system state can Need - Since the blockchain is a distributed store of be exploited. And it was, in the hack of The DAO data, many nodes in the network must store the en- (Atzei et al., 2017). The attacker made a recursive tire blockchain, which becomes infeasible if too much call to a function in such a way that the contract’s data is stored in every block. Additionally, on public funds were transferred (interaction) before the pro- blockchains, storing data requires money and can get gram could ever record the transfer of funds (effects). Consequences - The advantage of this software pat- 1Gas is a monetary token or the ”cost” for any transac- tern is that it ensures all debits and credits are tion in Ethereum 243 ICSOFT 2020 - 15th International Conference on Software Technologies expensive quickly. are the

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us