Programmable BFT-Consensus with Smart Contracts for Client-Centric P2P Web Applications

Programmable BFT-Consensus with Smart Contracts for Client-Centric P2P Web Applications

SCEW: Programmable BFT-Consensus with Smart Contracts for Client-Centric P2P Web Applications Martijn Sauwens, Kristof Jannes, Bert Lagaisse, Wouter Joosen imec-Distrinet, KU Leuven Abstract ACM Reference Format: Collaborative web applications are becoming increasingly Martijn Sauwens, Kristof Jannes, Bert Lagaisse, Wouter Joosen. 2021. client-centric, with technologies such as WebRTC, WebWork- SCEW: Programmable BFT-Consensus with Smart Contracts for Client-Centric P2P Web Applications. In 8th Workshop on Principles ers and IndexedDB enabling a shift towards a decentralized and Practice of Consistency for Distributed Data (PaPoC’21), April 26, peer-to-peer (P2P) model. Contemporary systems such as 2021, Online, United Kingdom. ACM, New York, NY, USA, 7 pages. Automerge, Legion, OWebSync and Yjs provide fault tolerance https://doi.org/10.1145/3447865.3457965 and consistency by using Conflict-free Replicated Data Types for synchronization. These systems tolerate crash-faults, but lack resilience against arbitrary faults and malicious users, 1 Introduction also known as Byzantine faults. Providing Byzantine fault Collaborative web applications are becoming increasingly tolerance (BFT) in web apps is non-trivial. Web apps are popular and versatile. Browser technologies such as Web- executed in web browsers on end user devices. The scarce RTC [5], WebWorkers [9] and IndexedDB [1] enable the im- compute resources and the interactive nature of collabora- plementation of responsive and persistent peer-to-peer (P2P) tive web apps do require both a lightweight and low-latency applications in the browser [11]. Existing frameworks for de- solution, while still providing the Byzantine fault tolerance veloping P2P web apps such as Automerge [14], Legion [31], required by P2P systems to protect shared assets. OWebSync [13] and Yjs [24, 25] provide crash-fault toler- Our work aims to fill this gap by indroducing SCEW, a pro- ance [28] by using CRDTs [29] and their P2P architecture. gramming framework for client-centric P2P web apps that However, none of these systems can tolerate arbitrary or require BFT and interactive collaboration. SCEW achieves Byzantine faults. The source of these faults is diverse, ranging this by combining state-based Convergent Replicated Data from software bugs to colluding and malicious users [17, 28]. Types (CvRDTs) and smart contracts. SCEW represents as- Dealing with Byzantine faults is more complex compared to sets shared by peers as CvRDTs with atomic register semanc- fail-stop crashes, requiring elaborate protection mechanisms. tics, that provide BFT through the use of BFT-consensus Byzantine fault tolerance (BFT) is often required by P2P algorithms. SCEW employs smart contracts to define the life- applications that collectively manage shared assets with real cycle of these shared assets, shielding the application and world value. Examples are integrated loyalty programs [12] it’s developers from the complexity of the CvRDT’s consen- and sharing economy [8, 18]. Abuse of shared assets in these sus protocol. Experimental results indicate that applications applications may lead to real-world damage, either in the using SCEW can support P2P networks with 100 peers, even form of financial loss or damage to the reputation of partici- when Byzantine faults are present. pating users. To protect the shared assets against Byzantine CCS Concepts: • Security and privacy ! Distributed faults, P2P applications use BFT-consensus protocols [6]. systems security; • Networks ! Peer-to-peer protocols; Consensus protocols ensure that state changes are only com- • Information systems ! Web applications. mitted when a quorum of peers agree on the newly proposed state. Designing and implementing BFT-consensus protocols Keywords: Smart Contracts, Web applications, Peer-to-peer is sophisticated, requiring thorough testing and formal veri- protocols, Byzantine Fault Tolerance fication to prove safety. To capitalize on development costs, it is useful to make consensus algorithms programmable. An Permission to make digital or hard copies of all or part of this work for abstraction for programming BFT-consensus are smart con- personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear tracts [30]. Smart contracts specify how users interact with this notice and the full citation on the first page. Copyrights for components shared assets and one another. Deploying the same contract of this work owned by others than ACM must be honored. Abstracting with on all peers, in combination with BFT-consensus, ensures credit is permitted. To copy otherwise, or republish, to post on servers or to that the protected shared state can only evolve according to redistribute to lists, requires prior specific permission and/or a fee. Request the specifications of the contract. permissions from [email protected]. Client-centric P2P web apps execute exclusively in web PaPoC’21, April 26, 2021, Online, United Kingdom © 2021 Association for Computing Machinery. browsers of end-users. This environment is characterized by ACM ISBN 978-1-4503-8338-7/21/04...$15.00 a lack of compute resources, unreliable communication and https://doi.org/10.1145/3447865.3457965 high churn rates. The interactive nature of collaborative P2P 1 PaPoC’21, April 26, 2021, Online, United Kingdom Martijn Sauwens, Kristof Jannes, Bert Lagaisse, Wouter Joosen web apps requires a solution to BFT-consensus that is not 3 Background only lightweight, but also provides low latencies, preferably This section provides the background information and ter- in the order of seconds [26]. To fulfil these requirements we minology on CvRDTs, blockchains and BFT-consensus used present the SCEW (Smart Contract Execution for the Web) in the remainder of the text. Other related technologies and programming framework. This framework: systems are discussed in Section 6. 1. enables development of client-centric P2P web apps Convergent Replicated Data Types (CvRDTs) [29] are a that require BFT and interactive collaboration, flavor of Conflict-free Replicated Data Types (CRDTs) [29] 2. uses state-based CRDTs with atomic register semantics providing Strong Eventual Consistency (SEC) between mul- for efficient synchronization and BFT, tiple replicas by defining a join semilattice over a shared 3. and both defines and manages life-cycles of individual state. This lattice has both a partial ordering relation (≤) and assets with state machine based smart contracts. a Least-Upper-Bound (LUB) operation. Replicas periodically exchange their local copy of the state with each other to Experimental results indicate that SCEW can support in- propagate any received updates, merging both the received teractive collaboration in client-centric P2P web apps that and local state using the LUB operation. CvRDTs only re- require BFT to protect their users’ assets. SCEW can support quire a fair-lossy channel for communication, which makes networks with up to 100 users, keeping latencies below 3.2 state-based protocols ideal for use in unreliable networks and 2 seconds for 99% of all transactions in scenarios with such as the Internet. Note that attention should be paid at and without Byzantine faults respectively. design time to minimize the size of the CvRDT, as the entire The remainder of this text is structured as follows: Sec- state is sent over the network during synchronization. tion 2 elaborates on motivation and use cases. Section 3 Consensus algorithms are an important part of Block- provides the reader with additional background. Section 4 chains [35]. Well known blockchains include Bitcoin [27], presents SCEW, the main contribution of this work. Sec- Ethereum [34] and Hyperledger Fabric [3]. Blockchains repli- tion 5 discusses the evaluation. We consider related work in cate a data-structure called the ledger, that is maintained by Section 6 and conclude in Section 7. the blockchain protocol. Users update the ledger by propos- 2 Motivation and Use Cases ing new transactions, aggregating them into blocks. Block- chains such as Ethereum and Fabric use these transactions This section provides two motivating examples of client- to initiate calls to smart contracts [30]. Based on their spec- centric P2P web apps that require BFT to manage shared ification, smart contracts can read and write to the ledger, assets. The first application Loyalty Programs, demonstrates allowing them to update the ledger’s state in a programmable the use of BFT in protecting shared loyalty points, while the manner. A consensus algorithm decides which block of trans- second, Sharing Economy, aims to mitigate distrust between actions is added next to the chain. Blocks are chained to- users participating in a sharing economy application. gether by hashes, making it computationally infeasible to Loyalty Programs. Local shops or merchants at a market- change the contents of blocks or their order at a later time. place can implement a shared loyalty program in which their Examples of consensus algorithms used by blockchains in- customers can exchange earned loyalty points at any partic- clude Nakamoto Consensus [27] and BFT, depending on the ipating shop [12]. To avoid abuse or fees by a central party, context [35]. Nakamoto Consensus requires vast amounts of the shops set up the loyalty program as a client-centric P2P computational resources, as it essentially tries to brute force web app where the loyalty points are managed collectively a solution to

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 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