Abstract
Most of the existing smart-contract-based cryptocurrencies, such as Ethereum, use an account-based ledger. However, while the account-based model is advantageous for the efficient use of smart contracts and the increased exchangeability of cryptocurrencies, it is not well-suited to the parallel execution of smart contracts. However, unspent transaction output (UTXO)-based cryptocurrencies such as Bitcoin are advantageous for parallel cryptocurrency transfers but not well-suited to smart contracts. In this paper, we propose a hierarchical multi-blockchain system that uses multiple pairs of sidechain and dual-sidechains extended by independent block mining in their blockchain networks and a mainchain to control the branching and connection process of sidechains and dual sidechains. In the proposed method, one pair of a sidechain and dual sidechain forms one shard. The proposed method uses multiple shards to execute cryptocurrency transfers and smart contracts in parallel. In addition, the proposed model uses an accoutchain to record the resulting state changes generated by smart contract executions in each shard and securely share them with all other nodes. The proposed method uses a modifiable blockchain structure for the accountchain to obtain the database to record the smart contract execution results in each shard in as small and secure a manner as possible to ensure that all nodes trust the recorded results without executing smart contracts themselves. To examine the validity of the proposed method, we conducted a threat analysis of the proposed method by examining possible attacks in various scenarios as a thought experiment. This threat analysis concludes that the proposed blockchain system can execute smart contracts in parallel while keeping the concurrency in resulting state changes secure.
1. Introduction
Ever since the advent of Bitcoin [] in 2009, cryptocurrency and its underlying technology, blockchain, have increased their applicability in various fields. The blockchain is a distributed ledger created by collecting all transactions that were issued into blocks and chaining them with a cryptographic hash function by ensuring that the hash value of the current block is included in the next block. This chaining structure and the collision-free cryptographic hash function makes the blockchain tamper-proof and irreversible. These properties provide enhanced security and transparent traceability in the data recorded in a blockchain, and hence enable blockchain technology to be utilized in applications that need to secure trust in a trustless environment without central control [,,,,,].
The field of application of blockchain technology is expanding with the advent of smart-contract-based cryptocurrencies such as Ethereum []. The smart contract is a program code designed to run in a virtual machine formed by distributed computers in worldwide networks. Smart contracts move blockchain technology beyond simple cryptocurrency transfers and enable its application to various business logics. The use of smart contracts is currently primarily considered in the blockchain application field, and that field is rapidly expanding [,,,]. The International Data Corporation (IDC) estimates that spending on blockchain technology will reach $6.6 billion in 2021, an increase of more than 50% compared to 2020, and will continue to see strong growth throughout the 2020–2024 forecast period, with a five-year compound annual growth rate of 48.0% [].
1.1. Motivation of Study
As the use of smart contracts increases, concerns regarding their throughput and efficiency are also increasing. In current blockchain models, smart contracts must be executed sequentially without parallel computation, whether they are called by users or other smart contracts. In this study, the parallel computation is restricted to mean that the blockchain network executes multiple smart contracts simultaneously. In other words, it excludes the parallel computation of a smart contract by multiple nodes. This serial execution discourages the use of smart contracts in a business environment, where many smart contracts must be executed quickly. In addition, all users who want to keep their blockchain up-to-date must execute smart contracts. In other words, even if some users’ smart contract execution results are consistent and, hence, sufficient trust in the actual results is formed among all users, it is difficult for other users to accept the execution results without executing the smart contract themselves. This is also a cause of the restraint in the use of smart contracts in some business environments [].
The previously mentioned problems in smart contracts are related to the technology called sharding. In the database, sharding is a method that partitions data into small chunks to be managed by separate database server instances for the load-spreading. In the blockchain field, sharding is the technique of dividing and allocating the work required to maintain the entire blockchain system to groups of nodes (computers that participate in the blockchain network to maintain the entire blockchain system) []. The sub-blockchain network allocated to this group is called a shard. It is difficult to partition the execution of smart contracts through sharding because the results of smart contract executions in one shard can affect smart contract executions in other shards. In addition, the account-based ledger model (a detailed description will be given in Section 2) used by most smart-contract-based cryptocurrencies makes sharding more difficult. However, the ledger model used in Bitcoin is UTXO (a detailed description will be given in Section 2), which makes it easy to expand cryptocurrency transfers through sharding []. However, it is known that the UTXO model is less convenient than the account model when applying smart contracts [].
1.2. Key Contributions
This study proposes a method for efficiently distributing the node tasks in the network while increasing the throughput of smart contracts using sharding. Specifically, this study proposes a hierarchical multi-block system (HMBS), in which multiple sidechain and dual sidechain pairs are branched from and connected to a single blockchain (called mainchain in this work) with a prespecified rule, where each pair works as a shard. The contributions of the proposed method are as follows.
- One sidechain and dual sidechain pair form one shard, in which cryptocurrency transfers and smart contract executions are processed independently from those in other shards.
- The mainchain determines the block at which the results of cryptocurrency transfers or smart contract executions in shards are synchronized to HMBS.
- A modifiable blockchain, which we will call the accountchain, securely records the result of smart contract execution so that they are trusted by all HMBS network participants.
- When recording the state changes made by smart contract executions, the proposed method uses the accountchain to keep the database as small as possible, while existing UTXO-based blockchain models require an ever-growing database.
- The existing account-based blockchain model demands that all nodes record state changes in their local database by executing all smart contracts themselves. The proposed method allows sharded nodes to execute smart contracts and record the resulting state changes in the accountchain, to share them with all other nodes.
- The proposed method uses the mainchain to execute the smart contract that cannot be executed independently in one shard.
- Unlike existing parallelization approaches to smart contract executions, the proposed method does not require a group of privileged nodes to allocate jobs or check results in advance. Instead, it uses a predetermined rule for the parallelization of smart contract executions. Moreover, in the proposed method, all nodes can securely share execution results without resorting to the help of some privileged nodes.
1.3. Organization of the Paper
This study is outlined as follows. In Section 2, we review the backgrounds on blockchain technology and previous related works. In Section 3, we explain the proposed method. In Section 4, we test the validity of the proposed method by analyzing potential threats in various attack scenarios. Section 5 contains the discussion.
2. Backgrounds and Related Works
This section defines the terms and notations used in this paper, along with background knowledge of blockchain. In addition, we review previous research results on the main topic of this study: parallel computation in smart contracts.
2.1. Blockchain Basic
In this section, we briefly review basic blockchain theory. Readers can find a more detailed explanation in, e.g., []. We assume that a sufficient number of nodes try to update their blockchain copies throughout this study. We also assume that the blockchain uses an underlying cryptocurrency as a rewarding medium of incentivizing nodes to maintain the blockchain system.
Blockchain is a kind of state machine that records previous states or interactions with users. Specifically, miners (who try to compute a new block and connect it to the existing blockchain for a reward) of the blockchain network collect transactions to form a block . Miners try to find proofs of rights (its meaning will be explained shortly) to connect to the blockchain that records all states and interactions with users up to the -th state. Here, the block determines a state change that will be made to the n-th state. This process can be described as follows:
where means the concatenation.
Let
be the collection of transactions collected in the block ( is the number of transactions in ). Those ’s are for cryptocurrency transfers, smart contract executions/creations, etc. To prevent the block from being arbitrarily modified after it is connected to the blockchain, or the creation of a block from being monopolized by a specific miner, the blockchain includes the hash value of the last connected block in a new block and allows the miner to connect his or her block to only if the hash value of satisfies a prespecified condition. This statement is decscribed by the following equation:
where H is a cryptographic hash function, is a set represeting the prespecified condition that the hash value of must satisfy, and is the nonce number that satisfies (3). In Bitcoin, H is SHA256 [] and is the set of 256-bitstreams that are smaller than a very small number. From now on, we shall assume that H refers to the SHA256 hash function and call that the miner who finds satisfying (3) has a proof of rights to connect , which is formed by , to .
Bitcoin follows the UTXO ledger model. The transaction included in the Bitcoin block relates to the cryptocurrency transfer, and the main content of it is to re-allocate the cryptocurrencies allocated to the addresses in the input field to the addresses in the output field. Here, the term address is the public information used to receive cryptocurrency and is determined by the hash value of the public key associated with the private key required to use the cryptocurrency transmitted to the address. Through this process, the cryptocurrencies allocated to the addresses in the input field are spent and hence no longer usable, and the cryptocurrencies allocated to the addresses in the output field are newly created. This explains the core idea of the UTXO ledger model, and is similar to using check in everyday life. Considering this, in this study, we express the cryptocurrency assigned to the address in the UTXO-based blockchain as UTXO-Check or UC. Each UC is determined by the remittance address and the location in the blockchain where the transaction is recorded. We use the following notation to represent this dependency:
We note that each UC has a unique cryptocurrency value, which is entirely determined by and .
The complete dependency of UTXO-Check on the remittance address and the location in the blockchain where the transaction is recorded shows that sharding of cryptocurrencies can easily be accomplished in the UTXO model. For example, following two transactions and in the UTXO model,
which represent the transfer of cryptocurrencies with values from UC to , respectively, do not make any conflict as long as , especially, even if . Therefore, the processing of and can be preformed in different shards without any conflict, since the shard itself affects the location in the blockchain and, hence, the outputs of and would make different UCs.
Ethereum uses an account-based ledger model. Ethereum uses an Externally Owned Account (EOA) to store the ether (the name of the cryptocurrency used in Ethereum). This EOA works like a bank account. For instance, the transaction that transfers v ether from EOA to EOA ,
instructs all nodes in the Ethereum network to subtract v ether from EOA ’s ether balance and add v ether to EOA ’s ether balance.
Smart contracts in Ethereum have their own accounts, named contract accounts or CAs, to store ether balances and the values for internal variables that need to be stored (as, being a program code, a smart contract can produce the internal variable values that are needed in the next execution). The smart contract cannot start by itself. It must be triggered by spending ether in an EOA. For instance, the transaction,
which instructs all nodes in the Ethereum network to execute the smart contract associated with the contract account C with the v ether transfer from EOA E to CA C and input data d, must be properly requested by the user with the authority to control EOA E. Once smart contracts are initiated, they can call other smart contracts in their executions by transferring ethers and input data.
The Ethereum blockchain records the transactions that instruct all nodes in the Ethereum network to compute something, not the results of computations such as ether balance changes in EOAs and CAs or values for internal variables of smart contracts. These results are to be maintained by nodes. This makes sharding difficult in Ethereum. For example, two transactions,
which instructs all nodes in Ethereum network to transfer ethers to EOA from EOAs , respectively, cannot be processed in different shards, since the ether balance of EOA in each shard would not match. In general, the smart contracts that produce values for the internal variables to be used in the next execution make sharding very difficult. In addition, inter-smart contract calling makes sharding even more difficult to deployed. It is worth noting that the next Ethereum protocol is scheduled to include sharding technology [].
2.2. Parallel Computation in Smart Contracts
Much of the existing research on parallel computation in smart contracts in blockchain systems relates to the parallel execution of multiple smart contracts on one node to increase the processing speed on individual nodes. For example, Bartoletti et al. [] proposed a way for miners to simultaneously execute multiple smart contracts. Their method suggests that the node utilizes parallel computation after calculating how to order the smart contracts that will be executed in advance. Yu et al. [] proposed a multi-threaded approach to execute smart contracts in parallel using a partitioning algorithm to solve the parallel-execution-related synchronization problem. Dickerson et al. [] suggested that nodes need to classify smart contracts into those that can be processed in parallel and those that can only perform serial computation by using the software transaction memory method []. The advantage of these methods [,,] is that they can be applied without making any changes to the blockchain system itself, but there is one disadvantage: benefits other than the speed of calculation at each node cannot be obtained. However, this disadvantage is minor in some cases.
Many researchers have studied the sharding-technique-based parallel computation in smart contracts. Luu et al. [] explained how the sharding protocol could be applied to the public blockchain and possible problems with sharding. Ewa Syta et al. [] proposed a protocol that randomizes the rules that determine in which shards nodes will participate. The results of their protocol are publicly verifiable, unbiased, and unpredictable in determining the node partition so that the sharding protocol can be run with Byzantine fault tolerance. Amiri et al. [] proposed a protocol that distributes smart contract executions over multiple nodes. Their method is designed to overcome the limitations of the existing blockchain paradigm by allowing for the execution of smart contracts with concurrent contentiony. Muchhala et al. [] proposed a new blockchain network that allows nodes in a public blockchain to deploy and execute smart contracts that provide concurrency-related functions within the framework of a smart contract. The proposed blockchain network was named ConCurrency, and was specialized for calculation using the MapReduce [], which was developed by Google to process extensive data-based operations in a distributed system.
There was also an effort to pursue parallelizing smart contracts by combining the account ledger model with the UTXO ledger model, which is easy to shard. The cryptocurrency Qtum [] builds on the UTXO model of Bitcoin but allows for the creation and execution of smart contracts using the account model in Ethereum. The Central Bank Digital Currency Cryptocurrency (CDBC) project proposed in [] suggests using the account-based ledger model for frequently circulating digital currencies, especially digital assets and smart contracts with large fluctuations in value and weak liquidity, and a UTXO-based ledger model for large micropayment transactions. Chakravarty et al. [] proposed an extension to Bitcoin’s UTXO model that supports a substantially more expressive form of validation scripts, including scripts that act like smart contracts.
Many researchers have also studied multichain-based parallel computation in smart contracts. Plasma [] used a smart contract on the main chain to create a private blockchain (off-chain), manage all sub-chains created under it, and redesign the data in the sub-chain to be reframed for MapReduce-based parallel computation. A similar approach was also used in the aelf project [], which was proposed to build a multi-chain parallel-computing blockchain framework. Lee et al. [] proposed a method that can be used to handle transactions registered in the blockchain differently according to their importance, using multiple sidechains that are branched from and reconnected to the mainchain. For instance, their method can be used to make some transactions in a modifiable form, processed in a specialized protocol for fast processing, such as micropayment, or processed by a traditional method. Lee et al. [] proposed a blockchain-based digital content service ecosystem to protect the copyright of digital content. Their method has a similar blockchain system to that in this study. Those two methods share the same name, hierarchical multi-blockchain system (HMBS). In [] HMBS uses multiple sidechains and dual sidechains to parallel-process transactions related to the purchase and transfer of digital content rights for higher throughput.
Zhang et al. [] proposed a blockchain-based method to verify an outsourced linear regression computation to an untrustworthy cloud server. Their approach can be helpful in the parallel execution of smart contracts that perform linear regression by outsourcing them. However, it is not clear that this kind of outsourcing is available to general smart contracts. However, it is worth noting that their method obscures computational inputs/outputs to protect the privacy of sensitive information against cloud servers.
3. Proposed Method: HMBS
The blockchain system proposed in this study, HMBS, has a structure in which multiple pairs of sidechain (SC) and dual sidechain (dSC) are attached to one mainchain (MC) and manages the state of the entire blockchain by using accountchain (AC). In HMBS, one sidechain and dual sidechain pair forms one shard. In each shard, a specific form of UTXO-model-based cryptocurrency will be used, called UTXO-Check or UC in this study. In addition, we used a specific form of UTXO model-based cryptocurrency that can only be spent in MC. We assume that users can use UC in HMBS to (1) transfer the value of UC, (2) create a new smart contract, or (3) execute a smart contract.
3.1. UTXO-Check
As in the case of Bitcoin, UC is also created as a result of block mining. As mentioned in Section 2.1, UC must have the address needed to receive the cryptocurrency. In HMBS, the address of UC x is defined by
where H is the cryptographic hash function in SHA-256, is the public key associated with the private key that is required to spend UC x, and r is a nonce. Here, the public–private key pair is generated by Elliptic Curve Digital Signature Algorithm (ECDSA) [].
HMBS uses the n tail bits of (the first element of the address of UC x) to determine the shard in which UC x can be spent:
We shall use the UC x whose n tail bits of are all zero to receive change from the smart contract and spend it only in MC. Considering this fact, we shall treat MC as a shard. In HMBS, one pair of sidechain and dual sidechain forms one shard. Therefore, HMBS has shards formed by sidechain and dual sidechain pairs and one shard formed by MC. The reason for using this nonce r when generating the address of UC is that it makes it easier to adjust to the desired shard in which UC x can be spent. From now on, we use the following expression
to indicate that x is a UC that can be spent only in the shard .
As mentioned earlier, users in HMBS can transfer the value of HMBS cryptocurrency to others by spending their UCs. To explain this, let us consider a scenario where Alice spends her UC of value u to transfer HMBS cryptocurrency of value v to the address of Bob’s UC and return the change to the address of her UC:
where represents a fee to a miner to include the transaction t in his or her block. The transaction t in (12) should be digitally signed by the private key of UC x to spend x. The expression represents the described digital signature. One thing worth noting is that in HMBS, the address of the UC that will be spent, determines the shard in which the given transaction will be recorded, not the address of the UC that will receive remittance. Another one is that addresses of the appearing in the output field of the transaction t in (12) form completely new UCs, even if some UCs with the same address have already appeared in another transaction because they are recorded in new locations in HMBS.
3.2. Smart Contracts
In this study, smart contracts are classified into the following three types according to the scope of the execution effect on the blockchain state. When given as the following functions:
- stateless smart contract uses and returns state-independent input and output, respectively,
- state-independent stateful smart contract uses a state-independent input and returns a state-dependent output, and
- state-dependent stateful smart contract uses state-dependent input and output, respectively.
We can execute the stateless smart contract independently from other smart contracts since the execution of the stateless smart contract does not affect them and is not affected by them. Thus, we can execute the stateless smart contract in any shard without updating the blockchain state. On the other hand, we can execute the state-independent stateful smart contract out of order, but we must update the execution result to the blockchain state before we execute state-dependent stateful smart contracts. This restriction also holds for the state-dependent stateful smart contract. Moreover, we must execute the state-dependent stateful smart contract with full knowledge of the blockchain state. Thus indicates that the execution of a series of state-dependent stateful smart contracts must be carried out in series.
A suggestion that derives this study on the parallelization of smart contract execution is that the user must execute the smart contract that is programmed for parallelization if he or she wishes to benefit from the parallel computation. For the execution result of a smart contract in one shard to be recognized in the entire blockchain network without updating the state, that smart contract must be programmed to be stateless. On the other hand, the state-independent stateful smart contract can be executed in one shard, but the state needs to be immediately updated according to the execution result. As mentioned earlier, state-dependent stateful smart contracts cannot benefit from parallelization through sharding. In other words, parallelizing smart contract execution must avoid using state-dependent stateful smart contracts as much as possible.
The creation of a new smart contract is achieved by recording the following transaction on HMBS:
where x is the , is the special address whose bits are all 0, represents which class (stateless, state-indenpendent stateful, or state-dependent stateful) belongs to, represents the HMBS cryptocurrency value as a fee to a miner for including the transaction t in his or her block, v is the value of UC x, and is the address of UC, which receives the change . Here, we note that the transaction t in (13) must be recorded in the shard in which .
When the smart contract is created by the blockchain registration of the transaction t in (13), a Contract Account (CA) of is created. CA of has the address , the cryptocurrency balance , and the internal memory to save data for its state-dependent variables. Here, is the combination of the and (see (4)) of the UC used to create the smart contract . Here, we note that UC used to create the smart contract is destroyed immediately after being spent, so smart contracts with duplicated addresses cannot exist.
The execution of the stateless or state-independent stateful smart contract is requested by registering the following transaction, which spends a UC x to send the fund to the contract account address to HMBS:
where v is the value of UC x, represents a fee to a miner to include the transaction t in his or her block and execute , is the address of the UC receiving the change , and is the address of the UC that will receive the change after executing . Here, we note that is often set as higher than what is needed to execute , since the latter cannot accurately be predicted in most cases. This is the reason we need the address in (14). We also note that the stateless or state-independent stateful smart contract in t in (14) can be executed in any shard, but only in the shard where .
For the parallelization of smart contracts, users should execute smart contracts that are programmed for parallelization. However, some tasks can only be programmed as state-dependent stateful smart contracts. Such contracts are to be executed on the mainchian (MC), which will be explained in Section 3.3. If a smart contract that will be executed is stateless, it is possible to reduce the load on the network by executing the smart contract in just one shard. In this case, the execution result does not need to be recognized in the entire blockchain network, because the execution of a stateless smart contract does not form a state change. If a state-independent stateful smart contract is executed, then, again, it is possible to reduce the load on the network by executing the smart contract in just one shard. However, the execution result needs to be recognized in the entire blockchain network before any state-independent stateful start contracts are executed. In HMBS, it is not expected that HMBS nodes use any method to obtain the parallelization effect by themselves. HMBS expects the acceleration effect of parallelization in smart contract execution, which can only be obtained by the efforts of smart contract creators and executors. To encourage more active efforts in the parallel computation of smart contracts, it is recommended to add a higher execution fee for stateful smart contracts.
3.3. Mainchain
The mainchain (MC) of HMBS has the same blockchain structure as explained in Section 2.1. Here, for future use, we give the following three equations with explanations:
- Miners in MC network updates MC blockchain to by connecting MC block .
- The MC block consists of , where is the hash value of the preceding MC block , are transactions to be recorded in MC through , and r is a nonce that proveswhere is a condition which every MC block must satisfy.
- The hash value of MC block is defined bywith a nonce which satisfies (16).
HMBS uses MC to (1) merge the blockchain state changes made in each shard, (2) impose the current blockchain state to each shard, (3) transfer the value stored in one UC to another UC, and (4) execute state-dependent stateful smart contracts. The third objective of MC follows the same approach as (12) while the fourth objective of MC follows the one in (14). The first two objectives of MC will be explained in Section 3.4.
3.4. Shard by Sidechain and Dual Sidechain
HMBS uses multiple sidechain (SC) and dual sidechain (dSC) pairs to transfer the cryptocurrency as in (12), create a smart contract as in (13), or execute an exiting smart contract as in (14) by spending UCs through multiple shards. In HMBS, we assume that one shard of HMBS consists of a sidechain and dual sidechain pair. Let be the shard formed by the sidechain and its dual sidechain . In HMBS, each SC consists of a series of segments, each segment is formed by SC blocks, and each SC block has transactions. We denote the n-th segment of SC by , the j-th SC block of by , and the k-th transaction of by . Here, we note that is the transaction that performs (12), (13), or (14).
The proposed method uses a predetermined rule based on the block index n of to select one SC, in which the old segment (being mined in the SC network) is terminated and a new segment is initiated. To explain this, let us assume that the block index of the MC block , based on the predetermined rule, initiates the n-th segment of . Let us also assume that is the next MC block, which initiates the next segment of . Let
be the SC blocks mined in the network during the time interval, which to are mined in the MC network.
In HMBS, each SC must have a dual dSC . We will explain how these are related shortly. Just like , each dSC consists of a series of segments, and each segment consist of dSC blocks. We denote the n-th segment of dSC by and the j-th dSC block of by . Let
be the dSC blocks mined in the network during the time interval that to are computed in the MC network.
The block chaining in the SC segment has the same structure as MC; the mining of the SC block in the SC segment needs to find a nonce r, which proves
where is the number transactions to be included in , is the hash value of the SC block , and represents the condition determined by the consensus algorithm of the SC . The hash value of the SC block is defined by
with a nonce , which satisfies (20).
The block chaining of dSC segment is almost identical to that of the SC segment. One difference is that the dSC block records only one special smart contract, which announces the state changes made by transactions in the preceding sidechain segment to HMBS, while the SC block records the multiple transactions. A detailed explanation will be given shortly.
HMBS connects the SC segment and the dSC segment , which start from and end at , to MC by making the first SC and dSC blocks in and by setting
and updating the hash value as
where and are hash values of the last blocks in and , respectively.
3.5. Accounchain
HMBS records the execution results of state-independent stateful smart contracts in its on-chain database. At first glance, recording the execution results of smart contracts seems unnecessary, since HMBS records exactly how every smart contract will be or was executed. This is, however, a necessary task for the parallelization of smart contract execution in HMBS. It records the results of smart contracts that were executed in the shard formed by a SC and dSC pair in the accountchain (AC), which is a blockchain that can be modified to provide the results of smart contract execution that will be trusted by nodes operating outside the corresponding shard, without demanding that they execute the same smart contract themselves. Here, we note that HMBS demands that AC can be modified to record the frequently changing smart contract states in AC blocks.
The creation of the state-independent stateful smart contract in the transaction of block in the segment led to the creation of the contract account in AC when is connceted to the MC block . Table 1 shows a list of the information stored in the contract account of .
Table 1.
A list of information stored in contract account associated with the smart contract .
In Table 1, , the hash value of the smart contract , binds to the contract account , and represents the location of the transaction t where was created in HMBS. See (13). The state data of represent the cryptocurrency balance and the state-dependent variable saves internal memory . When is created for the first time, the target value in Table 1 is computed by
where is the first -bit truncation of the SHA-256 hash function H, where , and is the all zero bitstream of length 512 bits. The input value in Table 1 is a bitstream of length 256 bits, which are designed to make
holds for , where h is the hash value of the latest block at the moment when is computed. In other words, is said to be the input value of for at the moment specified by h if, and only if, satisfies (25). The parameter in (25) determines the difficulty in computing the input value .
The AC block records multiple contract accounts. Let be a collection of bitstreams representing the contract accounts (to be recorded in AC block ) of smart contracts , where
and is the number of contract accounts to be recorded in . The process of block mining in AC is identical to that in MC. The mining of AC block needs to find a nonce , which makes
where is the hash value of the latest block in AC and represents the condition determined by the consensus algorithm of AC. The hash value of the block is defined by
with a nonce , which satisfies (27).
The modifiability of AC comes from (26). Suppose that the state data of the smart contract need to be updated from to as a result of the execution of . If a miner can find that satisfies (25) with in the place of , then he or she can replace with in without destroying the chaining structure (imposed by (28)) in AC.
Before we close this subsection, it is worth mentioning why the state data of the stateless smart contract do not need to be stored in AC. This is because the cryptocurrency balance of the contract account of the stateless smart contract can be set to zero after the execution is completed, and no state-dependent variables are produced as a result of the execution of a stateless smart contract. Therefore, the state data of the stateless smart contract need to be managed only in the shard where is executed, and only for the duration of . HMBS serially executes the state-dependent stateful smart contract in MC. This implies that nodes in the MC network would prefer to execute the state-dependent stateful smart contract by themselves instead of waiting for the execution result from other nodes. Considering this fact, HMBS does not record the state data of the state-dependent stateful smart contract on AC.
3.6. Special Smart Contracts in Dual Sidechains
In this section, we shall explain how HMBS uses dual sidechains. For this purpose, let us assume that there is a transaction, t, which is broadcast to be recorded in a SC segment in a shard, say, . We first consider the case that t is the transaction that creates UCs and by spending a UC (See (12)). In this case, must be in , but and can be in any other shards. If and , then is immediately spendable after an SC block containing t is mined, but can be spent only after the segment is connected to MC block . However, any UCs created in the segment are spendable in their own shards after ends.
We now consider that the transaction t is used to create a smart contract, . If is stateless, then, like a newly created UC, it is executable in immediately after the SC block containing t is mined, but only in the whole HMBS network after the segment is connected to MC block . Any stateless smart contracts created in the segment are only executable after the MC block is mined. In the case when is state-dependent stateful, is only executable in MC and only after the MC block is mined. In the case when is state-independent stateful, however, is not executable in an HMBS network, even after the MC block is mined. This is because, as a state-independent stateful smart contract, needs its contract account in AC. In other words, users in the HMBS network, including users in the shard , need to wait for to be created in AC to execute .
In HMBS, the transaction that creates a state-independent stateful smart contract is the request signal to AC miners to create the corresponding contract account. To be specific, an AC miner create , with defined by
where is the collection of indices (SC), n (segment), j (block) and k (transaction) that identifies the location of the transaction t that creates in HMBS and is the hash value of the MC block . Therefore, the creation of the contract account of the smart contract can only start after the MC block is mined. In other words, is not immediately executable after the MC block is mined. HMBS requires that the state-independent stateful smart contract is only executable in the SC segment if the contract account was in AC when started.
We now consider the case that transaction t is used to execute a state-independent stateful smart contract whose contract account was in AC when the SC segment started. See (14). In this case, the UC created by the address used to receive the predetrmined change is spendable after the SC block containing t is mined if or after the SC segment ends if . The UC created by the address is used to receive the change from the contract account , and is only spendable in MC.
We are now ready to explain the objective of dual sidechains. Let us begin with the scenario where is executed in k times in the SC segment . When miners in first encouter the transaction that executes in the SC segment , they update their local database for the state data of by using the data recorded in AC. After executing , miners in update the state data of , not in AC, but in their local database. Miners in the dSC network update the state data of contract accounts in AC. Let Alice be the miner in network who tries to update the state data of in AC based on executions in . She follows each execution to compute correct changes and the final-state data change to be made for during the time when is being extended. At the moment when the SC segment ends, the dSC segment starts. During the dSC segment, is extended; she tries to connect the dSC block that contains only one special transaction T to :
where are the addresses of the UCs that are receiving changes from -executions, are the state data of at the moment when the SC segment ends, and is the input value of for (see Table 1). Notice that, unlike othe transactions in HMBS, the special transaction T in (30) does not require UC spending to be recorded in dSC. It is now clear that the objective of dual sidechains is to update AC based on the smart contract execution. Note that if the execution of a smart contract in the SC segment is not recognized in , then the state data change by the execution of will be ignored in the network.
Figure 1 illustrates how the state data of a state-dependent stateful smart contract are updated. In Step 1, miners in SC and dSC networks compute state changes by executing and recording them in their local database. In Step 2, state changes formed by executions of in the segment are collected to form the special transaction (see (30)) in . Finally, in Step 3, the final state data change of is updated in AC immediately after the dSC segment to MC.
Figure 1.
The process of updating the state data of a state-dependent stateful smart contract in HMBS.
4. Results
This section shows the thought experiments that were conducted to examine the stability and feasibility of the proposed model, HMBS. We also compare HMBS with Bitcoin and Ethereum to show the benefits it can obtain.
4.1. Threat Analysis
Double UC spending in SC: Suppose that a malicious user attempts to spend or has already spent a UC x by requesting that a x-spending transaction is included in the SC block of the SC segment . Let be the transaction that was used to spend the UC x. For each UC, the proposed method specifies the SC in which it can be spent. In other words, x-spending transactions and must be recorded in some SC blocks in . Thus, the serial block-chaining structure in the SC makes nodes in the network ignore ’s request to be included in the SC block by knowing that was already included in .
Double UC spending in MC: In HMBS, the block chaining structure in MC is identical to that in SC. Thus, no user can spend UC twice in MC.
Haste UC spending in SC: Suppose that a user attempts to spend a UC x, which was designed to be spendable in but was created in . Let t, , and be the planned transaction: to spend x in SC , the SC block to which t belongs, and the SC segment in which is to be recorded, respectively. Let and be the transaction that created the UC x in SC and the SC segment in which was recorded, respectively. In this case, the user can sepnd the UC x through the transaction t if, and only if, the SC segment was already connected to MC before the SC segment was branched out from MC. In other words, the UC x isnot spendable until its creation is reported to the MC network.
We now consider the case when the SC segment is not yet connected to MC, while blocks in the SC segment are being mined. We assume that the transaction was recorded in , that is, the UC x was already created. In this case, it is possible that some miners in the network might know the creation of the UC x in SC . HMBS, however, demands that miners in all SC networks determine the validity of the transaction t based on blocks preceding (the SC block to which t belongs) and the MC blocks preceding the MC block , from which the SC segment is branched out. Since the transaction is neither in blocks preceding nor in the MC blocks preceding the MC block , miners in the network would regard the UC x as not yet created, and hence not spendable. It explains why the haste UC spending (the spending of a UC not known to whole nodes in the SC network where the UC can be spent) is not possible.
Haste UC spending in MC: In HMBS, any UCs designed to be spendable in MC are only spendable after they are reported to MC and only through transactions in MC. This explains why the haste UC spending is not possible.
Replay of smart contract execution: In HMBS, any smart contract execution in SC must be triggered by spending UCs. See (14). Thus, it is impossible to replay smart contract execution in SC. The same argument and results also hold for the replay of smart contract execution in MC.
Head start block mining: Just like in Bitcoin or Ethereum, the block mining in HMBS, whether it is in MC, SC, dSC, or AC, needs the hash value of the immediately preceding block. See (16), (20), and (27). Therefore, the mining of the next block is worthless if the hash value of the current block is not computed.
Head start input value computation: Miners in dSC network compute input values for the state data of smart contracts executed in SC network. More specifically, the dSC-block in the dSC segment, say, , is designed to record just one special transaction (see (30)), which requests that the state data are updated accroding to the change generated by the execution of a smart contract . For this purpose, when the dSC block of is extended, miners in dSC network check the validity of changing state data to for . They also check whether the updated input value satisfies (25) with the latest dSC block hash value . This indicates that the head start input value computation is only useful if the latest dSC hash value is known.
4.2. Comparison with Bitcoin and Ethereum
This study’s proposed method, HMBS, uses the UTXO model in the cryptocurrency transfer, as Bitcoin does. However, it differs from Bitcoin in that it can execute smart contracts and parallelize cryptocurrency transfers and smart contract executions through sharding. In Ethereum, an externally owned account is used to receive the remaining funds back after sending enough funds to execute a smart contract. On the other hand, HMBS uses a UTXO-based cryptocurrency to execute a smart contract, and the remaining funds are returned to a UC that is only spendable in MC.
HMBS is a mixture of Bitcoin’s UTXO and Ethereum’s account models, and pursues parallelism in cryptocurrency transfers and smart contract executions using sharding techniques. In this process, to make the result of changes in the state of the blockchain system made in one shard trustable by all nodes, HMBS uses the accountchain, which has a modifiable blockchain structure.
In Ethereum, to prevent duplications in cryptocurrency transfer or smart contract execution, a number that can identify each transfer and execution (called the nonce in Ethereum) is used. However, the use of these numbers is a constraint on parallelization as it forces cryptocurrency transfers or smart contract executions to be serialized, even when the serialization is unnecessary. HMBS solved this problem by using UTXO-Check, which, once used, cannot be used again, for both cryptocurrency transfer and smart contract execution.
5. Discussion
In this study, we proposed a hierarchical multi-blockchain system (HMBS), which consists of one mainchain (MC), multiple pairs of sidechain (SC) and dual sidechain (dSC), and one accountchain (AC), to efficiently distribute the computation of cryptocurrency transfers and smart contract executions to whole nodes. In HMBS, a pair of SC and dSC forms a shard and, within a shard, some cryptocurrency transfers and smart contract executions can be processed independently, while SC or dSC segments are branched out from and reconnected to MC, according to a predetermined rule. The changes in state data generated by transactions in SC or dSC segments are synchronized in whole nodes of HMBS at the MC block to which those SC or dSC segments are terminated. This makes it possible to determine when the state changes made in SC or dSC segments are synchronized in a orderly manner. AC has a modifiable blockchain structure to ensure the state changes are not easily modifiable by a colluded mining of few nodes, and, at the same time, state changes can be modified by consensus of SC or dSC networks.
The state changes made by smart contract executions in MC are synchronized in MC block units, but those in SCs are synchronized in pair units. Therefore, for HMBS to obtain a meaningful parallelization effect through sharding, the number of shards must be increased according to the time required for block mining in SCs or dSCs. However, this might increase the possibility of a shard being monopolized by a few nodes.
In this study, we proposed an HMBS that combines the advantages of Bitcoin’s UTXO-based model and Ethereum’s account-based model. The proposed method does not use a group of privileged nodes to control parallelism in smart contract executions and can be applied to any blockchain, including public blockchains.
Funding
This study was supported by the 2019 Inje University research grant.
Conflicts of Interest
The author declares no conflict of interest.
References
- Nakamoto, S. Bitcoin: A Peer-to-Peer Electronic Cash System. Available online: https://bitcoin.org/bitcoin.pdf (accessed on 26 September 2021).
- McGhin, T.; Choo, K.; Liu, C.; He, D. Blockchain in healthcare applications: Research challenges and opportunities. J. Netw. Comput. Appl. 2019, 135, 62–75. [Google Scholar] [CrossRef]
- Xia, Q.I.; Sifah, E.B.; Asamoah, K.O.; Gao, J.; Du, X.; Guizani, M. MeDShare: Trust-less medical data sharing among cloud service providers via blockchain. IEEE Access 2017, 5, 14757–14767. [Google Scholar] [CrossRef]
- Yang, J.; Onik, M.M.H.; Lee, N.-Y.; Ahmed, M.; Kim, C.-S. Proof-of-Familiarity: A privacy-preserved blockchain scheme for collaborative medical decision-making. Appl. Sci. 2019, 9, 1370. [Google Scholar] [CrossRef] [Green Version]
- Onik, M.M.H.; Kim, C.-S.; Lee, N.-Y.; Yang, J. Privacy-aware blockchain for personal data sharing and tracking. Open Comput. Sci. 2019, 9, 80–91. [Google Scholar] [CrossRef]
- Meng, W.; Tischhauser, E.W.; Wang, Q.; Wang, Y.; Han, J. When intrusion detection meets blockchain technology: A review. IEEE Access 2018, 6, 10179. [Google Scholar] [CrossRef]
- Crosby, M.; Pattanayak, P.; Verma, S.; Kalyanaraman, V. Blockchain technology: Beyond bitcoin. Appl. Innov. 2006, 2, 71. [Google Scholar]
- Ethereum. Available online: https://ethereum.org (accessed on 26 September 2021).
- Feng, T.; Yu, X.; Chai, Y.; Liu, Y. Smart contract model for complex reality transaction. Int. J. Crowd Sci. 2019, 3, 184. [Google Scholar] [CrossRef] [Green Version]
- Eenmaa-Dimitrieva, H.; Schmidt-Kessen, M.J. Creating markets in no-trust environments: The law and economics of smart contracts. Comput. Law Secur. Rev. 2019, 35, 69–88. [Google Scholar] [CrossRef]
- Wang, H.; Guo, C.; Cheng, S. LoC—A new financial loan management system based on smart contracts. Future Gener. Comput. Syst. 2019, 100, 648–655. [Google Scholar] [CrossRef]
- Khatoon, A. A blockchain-based smart contract system for healthcare management. Electronics 2020, 9, 94. [Google Scholar] [CrossRef] [Green Version]
- Worldwide Blockchain Spending Guide. 19 April 2021. Available online: https://www.idc.com/getdoc.jsp?containerId=IDC_P37345 (accessed on 26 September 2021).
- Muchhala, Y.; Singhania, H.; Sheth, S.; Devadkar, K. Enabling MapReduce based parallel computation in smart contracts. In Proceedings of the 6th International Conference on Inventive Computation Technologies (ICICT), Coimbatore, India, 20–22 January 2021. [Google Scholar]
- Tao, Y.; Li, B.; Jiang, J.; Ng, H.C.; Wang, C.; Li, B. On sharding open blockchains with smart contracts. In Proceedings of the IEEE 36th International Conference on Data Engineering (ICDE), Dallas, TX, USA, 20–24 April 2020. [Google Scholar]
- Yu, G.; Wang, X.; Yu, K.; Ni, W.; Zhang, J.A.; Liu, R.P. Survey: Sharding in blockchains. IEEE Access 2020, 8, 14155–14181. [Google Scholar] [CrossRef]
- Brunjes, L.; Gabbay, M.J. UTxO- vs. account-based smart contract blockchain programming paradigms. In Lecture Notes in Computer Science, Proceedings of the Leveraging Applications of Formal Methods, Verification and Validation: Applications, ISoLA 2020, Rhodes, Greece, 20–30 October 2020; Margaria, T., Steffen, B., Eds.; Springer: Cham, Switzerland, 2020. [Google Scholar]
- Narayanan, A.; Bonneau, J.; Felten, E.; Miller, A.; Goldfeder, S. Bitcoin and Cryptocurrency Technologies: A Comprehensive Introduction; Princeton University Press: Princeton, NJ, USA, 2016. [Google Scholar]
- NIST. Descriptions of SHA-256, SHA-384, and SHA-512. Available online: https://web.archive.org/web/20130526224224/http://csrc.nist.gov/groups/STM/cavp/documents/shs/sha256-384-512.pdf (accessed on 26 September 2021).
- Upgrading Ethereum to Radical New Heights. Available online: https://ethereum.org/en/eth2/ (accessed on 26 September 2021).
- Bartoletti, M.; Galletta, L.; Murgia, M. A true concurrent model of smart contracts executions. In Lecture Notes in Computer Science, Proceedings of the Coordination Models and Languages, COORDINATION 2020, Valletta, Malta, 15–19 June 2020; Bliudze, S., Bocchi, L., Eds.; Springer: Cham, Switzerland, 2018. [Google Scholar]
- Yu, W.; Luo, K.; Ding, Y.; You, G.; Hu, K. A parallel smart contract model. In Proceedings of the 2018 International Conference on Machine Learning and Machine Intelligence, Ha Noi, Vietnam, 28–30 September 2018. [Google Scholar]
- Dickerson, T.; Gazzillo, P.; Herlihy, M.; Koskinen, E. Adding concurrency to smart contracts. In Proceedings of the ACM Symposium on Principles of Distributed Computing (PODC’ 17), Washington, DC, USA, 25–27 July 2017. [Google Scholar]
- Shavit, N.; Touitou, D. Software transactional memory. In Proceedings of the fourteenth annual ACM symposium on Principles of distributed computing (PODC’ 95), Ottowa, ON, Canada, 20–23 August 1995. [Google Scholar]
- Luu, L.; Narayanan, V.; Zheng, C.; Baweja, K.; Gilbert, S.; Saxena, P. A secure sharding protocol for open blockchains. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security (CCS’ 16), Vienna, Austria, 24–28 October 2016. [Google Scholar]
- Syta, E.; Jovanovic, P.; Kogias, E.K.; Gailly, N.; Gasser, L.; Khoffi, I.; Fischer, M.J.; Ford, B. Scalable bias-resistant distributed randomness. In Proceedings of the 2017 IEEE Symposium on Security and Privacy (SP), San Jose, CA, USA, 22–26 May 2017. [Google Scholar]
- Amiri, M.J.; Agrawal, D.; Abbadi, A.E. ParBlockchain: Leveraging transaction parallelism in permissioned blockchain systems. In Proceedings of the 2019 IEEE 39th International Conference on Distributed Computing Systems (ICDCS), Dallas, TX, USA, 7–10 July 2019. [Google Scholar]
- MapReduce-Wikipedia. Available online: https://en.wikipedia.org/wiki/MapReduce (accessed on 26 September 2021).
- Qtum Blockchain New Whitepaper. Available online: https://qtum.org/user/pages/01.home/Qtum%20New%20Whitepaper_en.pdf (accessed on 26 September 2021).
- Zhang, J.; Tian, R.; Cao, Y.; Yuan, X.; Yu, Z.; Yan, X.; Zhang, X. A hybrid model for central bank digital currency based on blockchain. IEEE Access 2021, 9, 53589. [Google Scholar]
- Chakravarty, M.; Chapman, J.; Mackenzie, K.; Melkonian, O.; Jones, M.P.; Wadler, P. The extended UTXO model. In Proceedings of the 4th Workshop on Trusted Smart Contracts, Kota Kinabalu, Sabah, Malaysia, 14 February 2020. [Google Scholar]
- Poon, J.; Buterin, V. Plasma: Scalable Autonomous Smart Contracts. Available online: https://plasma.io/plasma.pdf (accessed on 26 September 2021).
- Aelf—A Multi-Chain Parallel Computing Blockchain Framework. Available online: https://aelf.com (accessed on 26 September 2021).
- Lee, N.-Y.; Yang, J.; Onik, M.M.H.; Kim, C.-S. Modifiable public blockchains using truncated hashing and sidechains. IEEE Access 2019, 7, 173571. [Google Scholar] [CrossRef]
- Lee, N.-Y.; Yang, J.; Kim, C.-S. Blockchain-based smart propertization of digital content for intellectual rights protection. Electronics 2021, 10, 1387. [Google Scholar]
- Zhang, H.; Gao, P.; Yu, J.; Lin, J.; Xiong, N. Machine Learning on Cloud with Blockchain: A Secure, Verifiable and Fair Approach to Outsource the Linear Regression. Available online: https://arxiv.org/abs/2101.02334 (accessed on 26 October 2021).
- NIST. Descriptions of Digital Signature Standard. Available online: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf (accessed on 26 September 2021).
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |
© 2021 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).