Distributed Nonblocking Commit Protocols for Many-Party Cross-Blockchain Transactions

01/05/2020 ∙ by Xinying Wang, et al. ∙ 0

The interoperability across multiple blockchains would play a critical role in future blockchain-based data management paradigm. Existing techniques either work only for two blockchains or requires a centralized component to govern the cross-blockchain transaction execution, neither of which would meet the scalability requirement. This paper proposes a new distributed commit protocol, namely cross-blockchain transaction (CBT), for conducting transactions across an arbitrary number of blockchains without any centralized component. The key idea of CBT is to extend the two-phase commit protocol with a heartbeat mechanism to ensure the liveness of CBT without introducing additional nodes or blockchains. We have implemented CBT and compared it to the state-of-the-art protocols, demonstrating CBT's low overhead (3.6% between two blockchains, less than 1% among 32 or more blockchains) and high scalability (linear scalability on up to 64-blockchain transactions). In addition, we developed a graphic user interface for users to virtually monitor the status of the cross-blockchain transactions.



There are no comments yet.


page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1. Introduction

A blockchain offers an immutable, decentralized, and anonymous mechanism for transactions between two users on the same blockchain. Blockchain was not originally designed for online transactional processing (OLTP) workloads; instead, it aimed to offer an autonomous and temper-proof ledger service among mutually-distrusted parties and therefore, early blockchain systems can deliver only mediocre transaction throughput.

One natural question to ask is whether and how can we adopt blockchains to efficiently handle OLTP workloads such that both autonomy and performance can be simultaneously achieved. Indeed, most of recent works focus on this direction. For instance, in [mhindi_vldb19, jwang_nsdi19], authors advocate to leverage blockchains for OLTP workloads with various optimizations (e.g., sharding [hdang_sigmod19], sidechains [sidechain]) to boost up the transaction throughput of blockchains, such that blockchains would deliver similarly high performance as relational databases and become a competitive alternative to the latter as a general-purpose data management system.

There is yet another critical issue that must be addressed before blockchains can be widely adopted as a general data management system: the interoperability across heterogeneous blockchains. While SQL is available between distinct relational database implementations, no such standardization or interface exists for blockchains. Even worse, there is no known mechanism about how to transfer data among multiple blockchains without a central exchange. Recent attempts (e.g., Cosmos [cosmos]) on such cross-blockchain transactions are all ad hoc: making strong assumptions on the blockchains such as their consensus protocols and programming interface. In addition, existing cross-blockchain approaches exhibit various limitations such as limited scalability and significant performance overhead. To make it more specific, what follows lists four outstanding limitations exhibited by state-of-the-art cross-blockchain solutions:

(1) Centralized Broker. The transactions between heterogeneous blockchains are managed by a third-party, usually implemented as another blockchain (it is called a hub in Cosmos). This is against the decentralization principle of blockchains: the broker would become a performance bottleneck, an attack target, and a single-point-of-failure. Similarly, a recent work called AC3 [vzakhary_arxiv19] employs an extra component (known as witness blockchain) as a central authority to govern the cross-chain operations.

(2) Two-Party Transactions. The protocols used by existing cross-blockchain systems are derived from the sidechain protocol [sidechain], which was originally designed for transferring assets between Bitcoin [bitcoin] and another cryptocurrency. The sidechain protocol speaks of nothing about three- or multi-party transactions; in fact, Cosmos only supports transferring assets between Bitcoin [bitcoin] and Ethereum [ethereum]. A more recent line of works [maurice_vldb19, mherlihy_podc18] are based on two-party Atomic Cross-Chain Swaps (ACS); however, ACS cannot guarantee the atomicity of the multi-chain deals as a whole.

(3) Performance. The sidechain protocol [sidechain] took hours, if not days, to commit a cross-blockchain transaction. The main reason for this is due to the possible branches from the participating blockchains. In any participating blockchain, only one (i.e., the longest one) branch will remain valid and any transactions from the shorter branches will rollback. This is not a problem if all of the transaction parties are from the same blockchain; But for cross-blockchain transactions, they must wait for the (longest) branch to stand out.

(4) Interface. The centralized broker requires the users to pack their cross-blockchain transactions with the provided interface. It would create portability issues when the users concurrently work with multiple cross-blockchain platforms. What we need is a common interface with which different blockchains (and their users) can communicate. SQL is an excellent example for relational databases.

Figure 1 summarizes candidate solutions along with two of the most important features in the realm of cross-blockchain transactions. As we can see, existing works are limited to centralized design (i.e., the requirement of a hub), or the potential blocking of the operation, or both. To this end, we propose a new protocol, namely cross-blockchain transaction (CBT), to overcome the above limitations. The key design objectives of CBT is to eliminate the centralized component and to ensure liveness (i.e., nonblocking).

Figure 1. Feature comparison among cross-blockchain transaction protocols.

The idea of decentralized and nonblocking cross-blockchain transactions was recently presented at [dzhao_cidr20], as an abstract. This demo paper shares recent progress on the following perspectives:

  • We designed a set of protocols, i.e., CBT, that enables a transaction completed (or, aborted altogether) across an arbitrary number of blockchains;

  • We implemented CBT on BlockLite [xwang_cloud19] and validated the effectiveness of CBT over popular blockchain implementations;

  • We evaluated CBT against multiple state-of-the-art protocols for multi-party transactions in blockchains;

  • We developed a graphic interface allowing non-expert users to get hands-on experience on and concrete understanding of cross-blockchain transactions.

In the remainder of this paper, we will formulate the protocol design of CBT in §2, detail CBT’s implementation and report the experimental results in §3, and finally demonstrate the graphic user interface of CBT and other candidate protocols in §4.

2. Cross-Blockchain Transactions

2.1. An Example with Three Blockchains

Figure 2. A simplified running example of CBT across three blockchains: A, B, and C.

Before presenting the formal protocols, we illustrate the execution of CBT on a 3-blockchain scenario. It should be noted that the protocol can be applied to an arbitrary number of blockchains; we chose three because the 2-blockchain case is trivial and 3-blockchain is reasonably understandable for users who are interested in generalizing the protocol into a -blockchain case, where and .

The overall flow is illustrated in Figure 2 where three blockchains , , and cooperatively complete a transaction. We make the following assumptions and define some notations.

  1. We assume one of the blockchains is elected as the coordinator based on some election algorithms. Let’s say is the coordinator, and are the participants. If both and agree on the transaction, the transaction will be committed; Otherwise, the proposed transaction will be rollback.

  2. An uncertain period is the period from the point when the participant votes Yes to the point it gets enough information to make a final decision.

  3. Blocking State: during the uncertain period, if the coordinator’s primary node crashes, and it only sends a final decision (COMMIT or ABORT) to some participants, then the other participants will be blocked until a new primary node is selected and online.

  4. DT log: each blockchain maintains a distributed transaction log (DT log), in which the coordinator and participants keep a write-ahead log of the transaction. The DT log must be stored in a persistent storage.

  5. Heartbeat: a heartbeat protocol is employed by each blockchain. Specifically, if a worker node does not receive a reply from the primary node within the heartbeat time, the primary node will be replaced (by another live worker node) and restarted as a worker.

The normal execution (i.e., no failures) works as follows, pretty much similar to 2PC but among the representative nodes from distinct blockchains:

  1. The Commit Request Phase

    1. The coordinator sends a VOTE-REQUEST to all participants.

    2. When the participant receives the VOTE-REQUEST, it will respond YES or NO to the coordinator. If the participant votes NO, it can unilaterally terminate the protocol.

  2. The Commit Phase

    1. The coordinator collects votes from all participants. If all the responses are YES, then the coordinator sends a COMMIT message to all participants; Otherwise, the coordinator aborts and sends an ABORT message to all participants who have voted YES.

    2. Each participant who votes YES needs to wait for a COMMIT or ABORT message from the coordinator. After receiving the message, the participant performs the corresponding action and terminates.

The above 2PC protocol will only work in normal cases and will block in some scenarios. For instance, there will be cases where the message cannot be delivered due to the network errors or a participant is offline from a specific blockchain. To this end, we propose Improved 2PC (detailed in Algorithms 1 and 2) comprising a heartbeat monitoring mechanism (detailed in Algorithm 7). The exception and its handling is as follows (the step numbers refer to the arrows between blockchains and in Figure 2):

  1. In step 2, the participant waits for a VOTE-REQUEST from the coordinator. Let’s assume that any participant can unilaterally decide to abort before it votes YES. Therefore, if there is a timeout when the participant is waiting for a VOTE-REQUEST, it can unilaterally choose to abort and stop the communication.

  2. In step 3, the coordinator needs to wait for responses (YES or NO) from all participants. The coordinator can unilaterally decide whether to abort, but an ABORT message must be sent to each participant who previously sends a YES message.

  3. In step 4, the participant who has responded YES is in an uncertain period when it is waiting for the final decision (COMMIT or ABORT) from the coordinator. Unlike previous two cases where blockchain can make decisions unilaterally, if a timeout occurs in this case, the participant needs to consult with other participants to decide the next action, which warrants a call to the Interactve Recvery Protocol (detailed in Algorithms 3 and 4).

The Interactive Recovery Protocol works as follows. If participant p times out in the uncertainty period, it will send a DECISION-REQUIRE message to all the other participants, whose set is indicated by , and ask if any member in knows the outcome of the DECISION or if it can make a DECISION unilaterally. Assuming is the initiator and is the responder. There are four cases (2 and 3 can be grouped together) as follows:

  1. decides to commit (either as a coordinator or a participant): sends a COMMIT message to , and then does the same;

  2. decides to abort (either as a coordinator or a participant): sends an ABORT message to , and does the same;

  3. is a participant. unilaterally decides to abort even though has not voted. It then sends an ABORT message to , and does the same;

  4. is a participant. has voted YES and is also in an uncertain period. It cannot help to reach a decision, and does nothing.

In addition, the internal consistency of a blockchain itself needs to be maintained since each blockchain is composed of multiple nodes. The protocols are detailed in Algorithms 5 and 6.

2.2. Protocols

Most protocols are self-explanatory. We skip the proof of correctness and complexity analyses due to limited space.

1:send VOTE-REQUEST to all participants
2:wait for vote messages from all participants
3:on timeout:
4:   the set of processes from which YES was received
5:  write abort record in DT log
6:  send ABORT to all processes in
7:if all votes are YES and Coordinator votes YES then
8:     write commit record in DT log
9:     send COMMIT to all participants
11:     write abort record in DT log
12:     send ABORT to all processes in
13:end if
Algorithm 1 Improved 2PC Algorithm (Coordinator)
1:wait for VOTE-REQUEST from coordinator
2:on timeout
3:  write abort record in DT log
4:if participant votes yes then
5:     write a yes record in DT log
6:     send YES to coordinator
7:     wait for decision message from coordinator
8:     if  VOTE-REQUEST from new coordinator then
9:         if decision message is COMMIT then
10:              write COMMIT record in DT log
11:         else
12:              write ABORT record in DT log
13:         end if
14:     else
15:         on timeout initiate ask others protocol
16:     end if
17:end if
Algorithm 2 Improved 2PC Algorithm (Participant)
1:send DECISION-REQUIRE to all blockchains
2:wait for decision message from any blockchains
3:on timeout
4:write ABORT record in DT log
5:if decision message is COMMIT  then
6:     write COMMIT record in DT log
8:     write ABORT record in DT log
9:end if
Algorithm 3 Interactive Recovery Protocol (Initiator)
1:wait for DECISION-REQUIRE from any blockchains p
2:if responder has not voted, but decides to abort then
3:     send ABORT to p
4:else if responder has decided to commit then
5:     send COMMIT to p
6:else if responder has decided to abort then
7:     send ABORT to p
9:     skip
10:end if
Algorithm 4 Interactive Recovery Algorithm (Responder)
1:write message to a block
2:send message to all followers in cluster
3:if crashes then
4:     restart as a follower
5:end if
Algorithm 5 Consistency Algorithm (Leader)
1:receive message from the leader
2:write message to log
3:if leader crashes then
4:     run for the new leader
5:     if elected then
6:         synchronize the log
7:     else
8:         skip
9:     end if
10:end if
Algorithm 6 Consistency Algorithm (Follower)
1:build heartbeat thread
2:encapsulate heartbeat requests
3:if responses are normal then
4:     increment success counter by 1
6:     increment failure Counter by 1
7:end if
8:if success counter equals 3 then
9:     reset success counter
10:else if failure counter equals 3 then
11:     initiate a vote for a new leader
12:end if
Algorithm 7 Heartbeat Algorithm

3. Implementation and Evaluation

We have implemented the proposed CBT protocol as well as two baseline protocols, i.e., 2PC [2pc] and AC3 [vzakhary_arxiv19], on the BlockLite system [xwang_cloud19]. The source code will be accessible at: https://github.com/hpdic/cbt. The source code is written with Java of JDK 1.7. The code base comprises about 5,190 lines of code. The code base has three major components: (i) the blockchain implementation including protocols and utilities; (ii) the network component including the communications among coordinator and participants; and (iii) the graphic user interface developed with Java Swing.

The first experiment verifies that CBT is nonblocking in the scenarios where 2PC is blocking due to the failures of the coordinator (between the first and second phase). In our implementation, a successful transaction can be easily determined by checking the number of commit messages compared with the number of participants. Specifically, from a coordinator’s perspective, every batch of commit messages implies a successful transaction where indicates the number of participants. To verify that CBT is nonblocking as opposed to 2PC, we send a request of five transactions to two instances of three blockchains, one with 2PC and the other with CBT. At the end of the first transaction, we manually shut down the coordinator in both instances, and we expect the 2PC-instance will stop working on consequent transactions (i.e., blocking) and the CBT-instance will select a new coordinator from the same blockchain to continue the work. Indeed, as illustrated in Figure 3, the 2PC-instance only reports one successful transaction with two commit messages (because there are two participants) to the coordinator whereas the CBT-instance coordinator reports 10 commit messages, or five successful transactions.

(a) 2PC Coordinator
(b) CBT Coordinator
Figure 3. Blocking 2PC vs. nonblocking CBT.

The second experiment evaluates CBT’s scalability: we fixed the number of blockchains as two and submit different numbers of transactions ranging from 60 to 480. The raw completion time is reported on the left -axis in Figure 4. The scaling factor, defined as , where and indicate the running time and workload at a specific scale, and and indicate both at the baseline scale. In this experiment, for instance, and . We thus observe a closely linear scalability of CBT: at 120, 240, and 480 scales, the scaling factor is less than 3% off the original, as shown on the right -axis of Figure 4.

Figure 4. Different number of transactions completed by two blockchains using CBT.
Figure 5. Running time for completing 640 transactions among different number of blockchains.

The third experiment compares CBT with two state-of-the-art protocols in cross-blockchain transactions: 2PC [2pc] and AC3 [vzakhary_arxiv19]. For 2PC, we set it up as the “ideal case” where no failures take place during the experiment; it is the upper-bound performance one can best expect from 2PC. The point is to show the overhead incurred by our proposed CBT compared to such upper-bound performance. For AC3, we arbitrarily select one blockchain as the “hub”, or “witness blockchain” as in the literature. Because of AC3’s centralized hub, we expect the performance and scalability will be affected at some point, e.g., larger number of blockchains. We fix the workload of 640 transactions and vary the number of blockchains between 2 and 64. The results are reported in Figure 5. Both 2PC and CBT show (almost) linear scalability because no centralized component exists in the system. CBT incurs insignificant overhead (compared with baseline 2PC) at small/medium scales: 3.6% – 4% on 2–32 blockchains; then the overhead is negligible on 64 blockchains. Compared with 2PC and CBT, AC3 starts to fall behind on eight blockchains due to its “hub” design. Interestingly, AC3’s performance seems to follow a downward ladder trend with respect to the increasing numbers of participating blockchains: {2} {4,8,16} {32,64}. More investigation to this phenomena is beyond the scope of this paper and we leave this as an open question to the community.

4. Demo Scenarios

We will demonstrate our open-source implementation of various cross-blockchain transaction protocols using the a graphical user interface. Again, the source code can be downloaded from Github:

https://github.com/hpdic/cbt. This section will select some of the key steps in running the program.

When the user first launches CBT, she will specify the number of blockchains and whether a hub is available, as shown in Figure 6. For instance, here we set three blockchains: one coordinator (also the hub) and two participants.

Figure 6. CBT portal.

Then, the user would specify the properties of each blockchain, such as number of nodes within each blockchain, the ID of the blockchain, and their port numbers. Following our 3-blockchain instance, we will simply set two nodes for each blockchain along with other parameters, as shown in Figure 7.

Figure 7. Parameter setting.

After the user specifies the structure of the cluster of blockchains, she can submit transactions to the system at the control panel of the coordinator, as shown in Figure 8. The screenshot shows that the user submits five transactions to a 3-blockchain cluster (on the top-left panel). The top-right panel will report the number of messages passed during the transaction; Figure 3 is one such example. The bottom panel will output detailed log information: for instance, if one node crashes, it will be reported here.

Figure 8. Coordinator panel.

5. Concluding Remark

In the future “full version” of this paper, we will extend this work from the following perspectives. We will provide a theoretical proof and analysis of the protocols, mainly on the safety (correctness) and liveness (nonblocking) properties. We are currently working on scaling the CBT protocols to tens of hundreds of nodes. Last but not least, we are working on a set of primitives, extended from SQL, to allow RDBMS users to switch to blockchain-based general-purpose data management systems backed by CBT protocols.