Quant 백서

Quant

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 7쪽 중 5쪽

th 4 blocks. Fig.12: Hasse diagram of the order B(<, S), where S is the set of blocks{1A, 2A, 3A, 4A}. Page of 3048 If two blocks have two conflicting transactions, the transaction in the greatest (latest) block isn’t valid because that coin’s considered already spent. This is how ordering partially solves double-spending. One challenge is what happens if the two conflicting transactions are present in the same block. Since transactions within the same block have the same timestamp, we can model the set of transactions as a total poset T(≤ , W), where W is the set of all transactions contained in the blocks, and ≤ is the binary relation that compares transaction order. As an example, Fig.13 represents the Hasse diagram of a poset problem with 3 blocks and 5 transactions. Luckily, this problem is automatically solved in many blockchain protocols, because blocks with conflicting or invalid transactions are not eligible to be added, and when they’re proposed as the next block in the ledger, they’re dropped. In this way, it’s not possible to have conflicting transactions either in different blocks or in the same block [29]. Fig 13: Hasse diagram of the poset T(<,W), where W is the set of transaction{T1, T2, T3, T4, T5}. Overledger block order. While the order set of blocks and transactions within a particular blockchain can be modelled as total order, the comparison of the order of blocks or transactions across different blockchains is impossible, as those elements exist inside different domains. Fig. 14: Blockchains and overledger representation. This problem is represented in Fig. 14 showing the Hasse diagram of the set of some blocks of two different blockchains: blockchain A and B. The order is the poset O(≤ , S), where S is the set{1A, 2A, 3A, 2B, 3B, 4B}and ≤ is the binary relation deciding which block comes first. There’s no way to compare block 1A with 2B, or any other couple of blocks belonging to different chains. The easiest solution to this problem is to use timestamps to decide which block comes first. However, by dealing with different consensus mechanisms, the timing scheme regulating the way new blocks are added to the chains, can make this choice non-compliant with cross-ledger business logic. Moreover, it’s possible some chains don’t use a timestamp comparable with others. In fact, timestamps define a time range in which the transactions are considered to have occurred. Timestamps are expressed as windows, because in a distributed system there is no one “true” time. For example, in the Bitcoin blockchain a block is rejected if it contains a timestamp: 1) lower than (or equal to) the median timestamp of the previous eleven blocks; and 2) greater than (or equal to) the “network-adjusted time” + 2 hours. Nevertheless, this isn’t a problem Page of 3148 in Overledger because there’s no need to compare transactions moving assets existing only in their blockchain domain, and therefore we don’t have conflicting transactions. The situation changes when we’ll introduce cross-ledger transactions (in Subsection 2.3). In this case, we’ll explain how we can compare some of the blocks of different chains and detect conflicting transactions. Cross-ledger transaction and block poset. Fig. 15 provides an example of a cross-ledger transaction. There are two blockchains: A “purple” and B “green”. Each block contains a set of transactions identified by the unique field serial and composed by a ’Coin’ field indicating the asset moved in the transaction, and a ’Public key’ field, showing which user’s moving the asset to whom. In block 2 of blockchain A (#2@A) the transaction indexed 2 is a cross-ledger transaction that moves the asset 3 of blockchain A (3@A) from the user U4 in blockchain A (U4@A) to the user U1 of blockchain B (U1@B). Fig.15: Cross-ledger and Overledger transaction representation. The same transaction appears according to blockchain B semantics into block (#3@B) at index 0. For the sake of simplicity, we assume the blockchain semantics are the same. These two transactions represent the same transfer. Therefore, it’s evident the two blocks containing these two transactions happen together, concerning the business logic in our example. However, since these two blocks can be added with different consensus methods, it’s very unlikely they’re added at the same time. Moreover, to avoid inconsistency, it’s mandatory to find a way to allow atomic cross-ledger transactions in the unfortunate case when only one of the two blockchains record the transaction. In this Overledger representation, even if the transactions of these two blocks happen at the same time, regarding our business logic, they’re added into subsequent over blocks. This choice will be explained later when we’ll introduce a protocol to achieve atomicity, as the user owning the asset proposes the first transfer (see Subsection 2.3). In Fig 16 there’s the Hasse diagram of the set of all blocks in the different blockchains, ordered by the binary relation, stating which block comes first according to the Overledger business logic. While in Fig. 14 it wasn’t possible to compare blocks in different blockchains, in the case of Fig. 15, we’re able to compare them because of the cross-ledger transaction. Namely, we can say that (#1A ≤ #4B) or (#2B≤#3A). Thus, we can model the Overledger as a chain containing blocks of the different chains. A block of the Overledger (over block) can include one or more blocks of different blockchains. Page of 3248 Fig. 16: Hasse diagram of Poset O(≤, S) where S are the blocks in the blockchains in Fig. 15. This poset has a set of minimal blocks for every block because of Zorn’s lemma and duality. Fig. 17 represents Overledger based on the cross-ledger transactions shown in Fig. 16. Fig. 17: Overledger modelled as a blockchain of block set 4.6. Note that the block 2 and 3 can be grouped together. Each Overledger block can contain many other blocks of different blockchains. Therefore, it includes the set of all transactions in those blocks. In the example shown in Fig. 15 we can model the Overledger block as a regular block with all the transactions, because we’re sure there’s no conflicts. Therefore, we can surmise they happen at the same time. Fig. 18: Transactions of the #N block of Overledger shown in Fig. 17. Page of 3348 Blockchain of Blockchains. If there are more blocks of the same blockchain, we can’t model all the transactions, since they were happening the same time as this, it may lead us to enter in the same set of conflicting transactions. In fact, a strict order relation exists between transactions in different blocks of the same blockchain. For this reason we consider them all equal. Fig. 19: Conflicting transactions in the same over block. Fig. 19 is a Hasse Diagram showing the order of the blocks which shows a cross-ledger transaction between the blocks #2A and #3B. In this case, the transaction in block #1B transfers the coin 1@B from U1@B to U2@B; the transaction in block #2B moves the same coin from U2@B to U3@B. Now there’s a clear, strict order relation between these two transactions. We can’t ignore this order and consider these transactions happened at the same moment, because the transfer that moves the coin from U2@B isn’t even valid, since U2@B doesn’t own the coin yet. Hence, Overledger treats the blocks, or transactions set, as a poset rather than a regular set. It leads the block in our model to contain a little piece of different chains. We obtain what in computer science is known as a list of lists, in this case, a blockchain of blockchains. Fig. 20: Blockchain of blockchains representation of Overledger whose Hasse Diagram is in Fig.19. Fork Issue on multi-ledger applications. We described blockchains as a list of valid blocks and we said there are common rules to accept whether a new block is valid or not. However, in some cases, a blockchain can suffer the fork problem [3]. A fork is a situation in which a blockchain splits into two (or more) separate chains temporarily or permanently. Forks naturally occur when miners unintentionally solve the PoW puzzle at nearly the same time and generate distinct blocks that succeed the same block. This is Page of 3448 an undesirable situation in which transactions in the two (or more) branches are not ordered and thus could be conflicting. The rule in such situations is the longer branch is the main chain (long-chain rule). After a fork forms, one branch quickly becomes longer, and is extended by all miners, thus the system’s state is agreed upon. Blocks in the shorter branch are pruned and their transactions are ignored, as if they never happened. However, forks can also occur as a consequence of the use of two distinct sets of rules trying to govern the same blockchain. In this case, the fork is permanent and can be either soft or hard [33]. Regardless of the reason, forks can compromise the blockchain business logic. For example, a branch containing a set of messages and another one containing a completely different set of messages, or with a different order. This problem is solved in single-ledger environments with other techniques, unfortunately not applicable in our context. In a fork situation, even if the branches are in conflict with each other, they’re consistently alone. Therefore, a way to solve this problem in a single-ledger environment is to have a clear and universally recognised set of rules (like the long-chain rule), independently allowing all users to univocally pick the valid branches among the various ones. Let’s imagine an Overledger application which interacts with two distinct blockchains, A and B (Fig. 21). If a fork happens after block 3 of blockchain A (#3@A). The Overledger application may not be aware of the fork and may append some transactions on block 4 (#4@A1). If we later discover the surviving branch doesn’t include block (#4@A1), the ordering, and therefore the business logic, is compromised. Even if single blockchain A is fork-resistant and can backup in a consistent state, we can’t be sure the restored consistent state is the one consistent with our business logic, and with the other blockchain, B, involved in the same Overledger application. Fig. 21: Example of a fork happening in one of the ledgers of Overledger, leading to inconsistency. 2.3 Cross-Ledger Transactions In a distributed environment, it’s challenging to build applications. On the one hand, we want our applications to guarantee validity in the event of failures and errors. On the other hand, we want high availability, security and openness. It becomes harder in an environment where nodes behave according to the BAR model (Byzantine, Altruistic Rational). In this context, one should develop a system that’s, at the same time, ACID compliant and Byzantine Fault tolerant (BFT). Achieving ACID and BFT in ledger logic is challenging because of failures, errors and malicious behaviour in all the sub chains and their Page of 3548 interactions. In the previous section we introduced cross-ledger transactions and studied their importance, to build an order between blocks in different blockchains and an order between transactions. 2.3.1 Blockchain and transaction properties In computer science, the acronym ACID stands for Atomicity, Consistency, Isolation and Durability [34]: ●Atomicity: All changes to data are performed as if they’re a single operation. That is, all changes are performed, or none of them are; ●Consistency: Data is in a consistent state when a transaction starts and when it ends; ●Isolation: The intermediate state of a transaction is invisible to other transactions. As a result, transactions that run concurrently appear to be serialised; and ●Durability: After a transaction successfully completes, changes to data persist and aren’t undone, even in the event of a system failure. These properties guarantee the validity and compliance of transactions to the business logic. It’s not easy to satisfy all these properties and systems requiring high availability of data and high scalability. It’s better to use the BASE property of eventual consistency (Basically Available, Soft State, Eventually Consistent). The BASE acronym takes its origins from the CAP theorem [35]. The CAP theorem states that a distributed computer system cannot guarantee all of the following three properties at the same time: ●Consistency: Every time a user manages to read data he will receive the most recent value of that data, but they’re not guaranteed to receive an answer; ●Availability: Every time a user will try to read data he will always receive a reply, but is not ensured he receives the most recent values; and ●Partition Tolerance: The system will work even after many messages were lost among two different partitions of the system. A BASE system gives up on consistency in exchange for availability. Basically Available indicates the system does guarantee availability, in terms of the CAP theorem. Soft State indicates the state of the system may change over time, even without input. This is because of the eventual consistency model. Eventual Consistency indicates the system will become consistent over time, given the system doesn’t receive input during that time. BASE architecture is used in domains where there’s a huge demand for data, and approximate answers can be tolerated as well as using stale data. E-commerce sites can show the last item in stock to many users, and it can happen that many users may buy the same item. Then it’s not an issue for the e- commerce site to sell the item to only one customer and to apologise to the others. In contexts where users are dealing with asset transfers, there’s a need to assure validity and all the ACID properties. Blockchains don’t guarantee, in a deterministic way, all the ACID properties, which we consider in the next section. 2.3.2 ACID and Blockchain Atomicity. Each transaction is not breakable into smaller operations, and its execution is binary. Either it succeeds or aborts. Blockchain always guarantees atomicity since a transaction can only be present or absent in a block. Therefore, there are no intermediate states where the operation can fail. This is also the Page of 3648 case for smart contracts, because even if it’s true there’s no precise state of those assets in the contract, the constraints ruling those assets are either committed or aborted. Consistency. Before an operation is executed, the system is in a state compliant with the business logic. After the execution of the operation, the system is in a different state, still compliant with the business logic. The changes in states shifts the focus to assure data integrity within the system is upheld. One should be aware, consistency has a different meaning from the consistency in the CAP theorem. Blockchain guarantees consistency, in fact, every time transactions are validated a block is appended. Appending a new block should not lead the blockchain to an invalid state because the consensus mechanism assures it’s a valid block that takes the blockchain to a valid newer state. Isolation. Each transaction must be executed in a way that won’t interfere with others having the same result of a system that executes all the transactions sequentially. A block’s strict order in the blockchain guarantees the isolation property. Durability. Committing a transaction produces changes that will be persistent. Blockchains with non- deterministic consensus agreement finality [29], like Bitcoin, don’t guarantee this property in a deterministic way, because the probability to disagree decreases over time. However, the probability of it incurring in a fork can’t be completely eliminated. Therefore, transactions within blocks are not persistent. However, blockchains with deterministic consensus agreement finality, like all those based on Lamport Byzantine Fault Tolerance [9], guarantee this property, because consensus converges with certainty and transactions are immediately confirmed/rejected in/from the ledger. 2.3.3 BASE and Blockchain Eventual Consistency. According to this model, different nodes can store different and conflicting states of the logic. In a sufficiently long enough period, nodes detect conflicts and solve them. This means nodes will eventually give the most updated version of data. This architecture enforces liveness because nodes don’t need to be sure their data version is the most update. They can directly answer the request with the best answer they can give. Strong eventual consistency (SEC). In some contexts, data updates bring the state from one point A to the same point B, regardless of the order of transactions. In other words, if two nodes receive the same messages, but in different order, they’re considered to be in the same state anyway. For the same logic, a counter that receives the same increment operations and decrement operations will be in the same state (value), regardless of the order of these operations. This property isn’t true for transactions and can lead to an invalid state, because the set of transactions is a poset and we can’t ignore the order, as shown in Fig. 19. However, blocks in the blockchain have the order that guarantees consistency among transactions embedded in their format. If a node receives the same blocks, but in a different order, it can rebuild the proper order by using hash pointers. This means blockchains can be considered as Strong Eventual Consistency (SEC) systems, that can be ACID (in the case of deterministic consensus), or converge in probability to ACID (in the case of non-deterministic consensus). In the last case, the probability can be estimated to be proportional to the number of confirmed blocks succeeding the block of interest. 2.3.4 Cross-Ledger Transaction and ACID Page of 3748 Atomicity. In cross-ledger transactions we need to record the data in all blockchains interested in the exchange of information. In the easiest case, like the one shown in Fig.15, the transaction needs to be recorded in both the domains of blockchain A and B. The transfer operation is no longer atomic, as for single-ledger operations, because it consists of two sub-operations. Consistency. For various reasons, it can happen that a cross-ledger transaction is recorded in only one of the blockchains and hence breaking the consistency among blockchains. In fact, if for example, blockchain A records the transfer of an asset into the domain of blockchain B, according to A, the asset will be considered to be in B. Conversely, blockchain B may consider that asset to be still in A. In that case, the two blockchains don’t agree, and since an asset can exist in only one domain there’s a data integrity violation. Isolation. Cross-ledger transactions don’t guarantee isolation. Let’s suppose on blockchain B there’s a transaction that moves an asset from A to user U1@B. Suppose this transfer failed on blockchain A. The user U1@B can use his partial information to move an asset he doesn’t own. This is an example of what can happen if acting upon uncommitted information. Durability. Since cross-ledger transactions are based on blockchains, the durability property is only guaranteed for blockchains based on deterministic consensus. Instead, for blockchains based on non- deterministic consensus, one could estimate a probability that’s the product of the confirmation probabilities of all blockchains. 2.3.5 Two-phase Commit and Cross-ledger Transactions In transaction processing, databases, and computer networking, the two-phase commit protocol (2PC) is a type of an atomic commitment protocol that validates transactions in distributed environments. It’s a distributed algorithm that coordinates all the processes participating in a
프로젝트로 돌아가기