Gram 백서

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

f funds locked in such promises. This blockchainor the two workchains in the asynchronous casewill have to refer explicitly to the previous blocks by their hashes. Nevertheless, the general mechanism remains the same. 5.1.8. Challenges for the sophisticated payment channel smart con- tracts. Notice that, while the nal state of a sophisticated payment channel is still small, and the clean nalization is simple (if the two sides have agreed on their amounts due, and both have signed their agreement, nothing else remains to be done), the unilateral nalization method and the method for punishing fraudulent behavior need to be more complex. Indeed, they must be able to accept Merkle proofs of misbehavior, and to check whether the more sophisticated transactions of the payment channel blockchain have been processed correctly. In other words, the payment channel smart contract must be able to work with Merkle proofs, to check their hash validity, and must contain an implementation of ev_trans and ev_block functions (cf. 2.2.6 ) for the payment channel (virtual) blockchain. 5.1.9. TON VM support for smart payment channels. The TON VM, used to run the code of TON Blockchain smart contracts, is up to the challenge of executing the smart contracts required for smart, or sophisti- cated, payment channels (cf. 5.1.8 ). At this point the everything is a bag of cells paradigm (cf. 2.5.14 ) be- comes extremely convenient. Since all blocks (including the blocks of the ephemeral payment channel blockchain) are represented as bags of cells (and described by some algebraic data types), and the same holds for messages and Merkle proofs as well, a Merkle proof can easily be embedded into an 116 5.1. Payment Channels inbound message sent to the payment channel smart contract. The hash condition of the Merkle proof will be checked automatically, and when the smart contract accesses the Merkle proof presented, it will work with it as if it were a value of the corresponding algebraic data typealbeit incom- plete, with some subtrees of the tree replaced by special nodes containing the Merkle hash of the omitted subtree. Then the smart contract will work with that value, which might represent, for instance, a block of the payment chan- nel (virtual) blockchain along with its state, and will evaluate the ev_block function (cf. 2.2.6 ) of that blockchain on this block and the previous state. Then either the computation nishes, and the nal state can be compared with that asserted in the block, or an absent node exception is thrown while attempting to access an absent subtree, indicating that the Merkle proof is invalid. In this way, the implementation of the verication code for smart pay- ment channel blockchains turns out to be quite straightforward using TON Blockchain smart contracts. One might say that the TON Virtual Ma- chine comes with built-in support for checking the validity of other simple blockchains. The only limiting factor is the size of the Merkle proof to be incorporated into the inbound message to the smart contract (i.e., into the transaction). 5.1.10. Simple payment channel within a smart payment channel. We would like to discuss the possibility of creating a simple (synchronous or asynchronous) payment channel inside an existing payment channel. While this may seem somewhat convoluted, it is not much harder to un- derstand and implement than the promises discussed in 5.1.7 . Essentially, instead of promising to pay c coins to the other party if a solution to some hash problem is presented, A promises to pay up to c coins to B according to the nal settlement of some other (virtual) payment channel blockchain. Generally speaking, this other payment channel blockchain need not even be between A and B; it might involve some other parties, say, C and D, will- ing to commit c and d coins into their simple payment channel, respectively. (This possibility is exploited later in 5.2.5 .) If the encompassing payment channel is asymmetric, two promises need to be committed into the two workchains: A will promise to pay −δ coins to B if the nal settlement of the internal simple payment channel yields a negative nal imbalance δ with 0≤− δ≤ c; and B will have to promise to pay δ to A if δ is positive. On the other hand, if the encompassing 117 5.2. Payment Channel Network, or Lightning Network payment channel is symmetric, this can be done by committing a single simple payment channel creation transaction with parameters (c,d ) into the single payment channel blockchain by A (which would freeze c coins belonging to A), and then committing a special conrmation transaction by B (which would freeze d coins of B). We expect the internal payment channel to be extremely simple (e.g., the simple synchronous payment channel discussed in 5.1.3 ), to minimize the size of Merkle proofs to be submitted. The external payment channel will have to be smart in the sense described in 5.1.7 . 5.2 Payment Channel Network, or Lightning Network Now we are ready to discuss the lightning network of TON Payments that enables instant money transfers between any two participating nodes. 5.2.1. Limitations of payment channels. A payment channel is useful for parties who expect a lot of money transfers between them. However, if one needs to transfer money only once or twice to a particular recipient, creating a payment channel with her would be impractical. Among other things, this would imply freezing a signicant amount of money in the payment channel, and would require at least two blockchain transactions anyway. 5.2.2. Payment channel networks, or lightning networks. Payment channel networks overcome the limitations of payment channels by enabling money transfers along chains of payment channels. If A wants to transfer money to E, she does not need to establish a payment channel with E. It would be sucient to have a chain of payment channels linking A with E through several intermediate nodessay, four payment channels: from A to B, from B to C, from C to D and from D to E. 5.2.3. Overview of payment channel networks. Recall that a payment channel network , known also as a lightning network, consists of a collection of participating nodes, some of which have established long-lived payment channels between them. We will see in a moment that these payment channels will have to be smart in the sense of 5.1.7 . When a participating node A wants to transfer money to any other participating node E, she tries to nd a path linking A to E inside the payment channel network. When such a path is found, she performs a chain money transfer along this path. 118 5.2. Payment Channel Network, or Lightning Network 5.2.4. Chain money transfers. Suppose that there is a chain of payment channels from A to B, from B to C, from C to D, and from D to E. Suppose, further, that A wants to transfer x coins to E. A simplistic approach would be to transfer x coins to B along the existing payment channel, and ask him to forward the money further to C. However, it is not evident why B would not simply take the money for himself. There- fore, one must employ a more sophisticated approach, not requiring all parties involved to trust each other. This can be achieved as follows. A generates a large random number u and computes its hash v = Hash (u). Then she creates a promise to pay x coins to B if a number u with hash v is presented (cf. 5.1.7 ), inside her payment channel with B. This promise contains v, but not u, which is still kept secret. After that, B creates a similar promise to C in their payment channel. He is not afraid to give such a promise, because he is aware of the existence of a similar promise given to him by A. If C ever presents a solution of the hash problem to collect x coins promised by B, then B will immediately submit this solution to A to collect x coins from A. Then similar promises of C to D and of D to E are created. When the promises are all in place, A triggers the transfer by communicating the solution u to all parties involvedor just to E. Some minor details are omitted in this description. For example, these promises must have dierent expiration times, and the amount promised might slightly dier along the chain ( B might promise only x−ϵ coins to C, where ϵ is a small pre-agreed transit fee). We ignore such details for the time being, because they are not too relevant for understanding how payment channels work and how they can be implemented in TON. 5.2.5. Virtual payment channels inside a chain of payment channels. Now suppose that A and E expect to make a lot of payments to each other. They might create a new payment channel between them in the blockchain, but this would still be quite expensive, because some funds would be locked in this payment channel. Another option would be to use chain money transfers described in 5.2.4 for each payment. However, this would involve a lot of network activity and a lot of transactions in the virtual blockchains of all payment channels involved. An alternative is to create a virtual payment channel inside the chain linking A to E in the payment channel network. For this, A and E create 119 5.2. Payment Channel Network, or Lightning Network a (virtual) blockchain for their payments, as if they were going to create a payment channel in the blockchain. However, instead of creating a payment channel smart contract in the blockchain, they ask all intermediate payment channelsthose linking A to B, B to C, etc.to create simple payment channels inside them, bound to the virtual blockchain created by A and E (cf. 5.1.10 ). In other words, now a promise to transfer money according to the nal settlement between A and E exists inside every intermediate payment channel. If the virtual payment channel is unidirectional, such promises can be implemented quite easily, because the nal imbalance δ is going to be non- positive, so simple payment channels can be created inside intermediate pay- ment channels in the same order as described in 5.2.4 . Their expiration times can also be set in the same way. If the virtual payment channel is bidirectional, the situation is slightly more complicated. In that case, one should split the promise to transfer δ coins according to the nal settlement into two half-promises, as explained in 5.1.10 : to transfer δ− = max(0,−δ) coins in the forward direction, and to transfer δ+ = max(0,δ ) in the backward direction. These half-promises can be created in the intermediate payment channels independently, one chain of half-promises in the direction from A to E, and the other chain in the opposite direction. 5.2.6. Finding paths in the lightning network. One point remains undiscussed so far: how will A and E nd a path connecting them in the payment network? If the payment network is not too large, an OSPF-like protocol can be used: all nodes of the payment network create an overlay network (cf. 3.3.17 ), and then every node propagates all available link (i.e., participating payment channel) information to its neighbors by a gossip pro- tocol. Ultimately, all nodes will have a complete list of all payment channels participating in the payment network, and will be able to nd the shortest paths by themselvesfor example, by applying a version of Dijkstra's algo- rithm modied to take into account the capacities of the payment channels involved (i.e., the maximal amounts that can be transferred along them). Once a candidate path is found, it can be probed by a special ADNL data- gram containing the full path, and asking each intermediate node to conrm the existence of the payment channel in question, and to forward this data- gram further according to the path. After that, a chain can be constructed, and a protocol for chain transfers (cf. 5.2.4 ), or for creating a virtual payment 120 5.2. Payment Channel Network, or Lightning Network channel inside a chain of payment channels (cf. 5.2.5 ), can be run. 5.2.7. Optimizations. Some optimizations might be done here. For exam- ple, only transit nodes of the lightning network need to participate in the OSPF-like protocol discussed in 5.2.6 . Two leaf nodes wishing to connect through the lightning network would communicate to each other the lists of transit nodes they are connected to (i.e., with which they have established payment channels participating in the payment network). Then paths con- necting transit nodes from one list to transit nodes from the other list can be inspected as outlined above in 5.2.6 . 5.2.8. Conclusion. We have outlined how the blockchain and network technologies of the TON project are adequate to the task of creating TON Payments , a platform for o-chain instant money transfers and micropay- ments. This platform can be extremely useful for services residing in the TON ecosystem, allowing them to easily collect micropayments when and where required. 121 Conclusion Conclusion We have proposed a scalable multi-blockchain architecture capable of sup- porting a massively popular cryptocurrency and decentralized applications with user-friendly interfaces. To achieve the necessary scalability, we proposed the TON Blockchain , a tightly-coupled multi-blockchain system (cf. 2.8.14 ) with bottom-up ap- proach to sharding (cf. 2.8.12 and 2.1.2 ). To further increase potential per- formance, we introduced the 2-blockchain mechanism for replacing invalid blocks (cf. 2.1.17 ) and Instant Hypercube Routing for faster communication between shards (cf. 2.4.20 ). A brief comparison of the TON Blockchain to existing and proposed blockchain projects (cf. 2.8 and 2.9 ) highlights the benets of this approach for systems that seek to handle millions of transac- tions per second. The TON Network , described in Chapter 3 , covers the networking de- mands of the proposed multi-blockchain infrastructure. This network com- ponent may also be used in combination with the blockchain to create a wide spectrum of applications and services, impossible using the blockchain alone (cf. 2.9.13 ). These services, discussed in Chapter 4 , include TON DNS , a service for translating human-readable object identiers into their addresses; TON Storage , a distributed platform for storing arbitrary les; TON Proxy , a service for anonymizing network access and accessing TON-powered ser- vices; and TON Payments (cf. Chapter 5 ), a platform for instant o-chain money transfers across the TON ecosystem that applications may use for micropayments. The TON infrastructure allows for specialized light client wallet and ton- browser desktop and smartphone applications that enable a browser-like experience for the end user (cf. 4.3.23 ), making cryptocurrency payments and interaction with smart contracts and other services on the TON Platform accessible to the mass user. 122 References References [1] K. Birman , Reliable Distributed Systems: Technologies, Web Services and Applications , Springer, 2005. [2] V. Buterin , Ethereum: A next-generation smart contract and de- centralized application platform , https://github.com/ethereum/wiki/ wiki/White-Paper , 2013. [3] M. Ben-Or, B. Kelmer, T. Rabin , Asynchronous secure computa- tions with optimal resilience , in Proceedings of the thirteenth annual ACM symposium on Principles of distributed computing , p. 183192. ACM, 1994. [4] M. Castro, B. Liskov, et al. , Practical byzantine fault tolerance , Proceedings of the Third Symposium on Operating Systems Design and Implementation (1999), p. 173186, available at http://pmg.csail.mit. edu/papers/osdi99.pdf . [5] EOS.IO , EOS.IO technical white paper , https://github.com/EOSIO/ Documentation/blob/master/TechnicalWhitePaper.md , 2017. [6] D. Goldschlag, M. Reed, P. Syverson , Onion Routing for Anony- mous and Private Internet Connections , Communications of the ACM , 42 , num. 2 (1999), http://www.onion-router.net/Publications/ CACM-1999.pdf . [7] L. Lamport, R. Shostak, M. Pease , The byzantine generals problem , ACM Transactions on Programming Languages and Systems , 4/3 (1982), p. 382401. [8] S. Larimer , The history of BitShares , https://docs.bitshares.org/ bitshares/history.html , 2013. [9] M. Luby, A. Shokrollahi, et al. , RaptorQ forward error correction scheme for object delivery , IETF RFC 6330, https://tools.ietf.org/ html/rfc6330 , 2011. [10] P. Maymounkov, D. Mazières , Kademlia: A peer-to-peer infor- mation system based on the XOR metric , in IPTPS '01 revised pa- pers from the First International Workshop on Peer-to-Peer Systems , 123 References p. 5365, available at http://pdos.csail.mit.edu/~petar/papers/ maymounkov-kademlia-lncs.pdf , 2002. [11] A. Miller, Yu Xia, et al. , The honey badger of BFT protocols , Cryptology e-print archive 2016/99, https://eprint.iacr.org/2016/ 199.pdf , 2016. [12] S. Nakamoto , Bitcoin: A peer-to-peer electronic cash system , https: //bitcoin.org/bitcoin.pdf , 2008. [13] S. Peyton Jones , Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine , Journal of Functional Pro- gramming 2 (2), p. 127202, 1992. [14] A. Shokrollahi, M. Luby , Raptor Codes , IEEE Transactions on Information Theory 6 , no. 34 (2006), p. 212322. [15] M. v an Steen, A. Tanenbaum , Distributed Systems, 3rd ed. , 2017. [16] The Univ alent Foundations Program , Homotopy Type Theory: Univalent Foundations of Mathematics , Institute for Advanced Study, 2013, available at https://homotopytypetheory.org/book . [17] G. Wood , PolkaDot: vision for a heterogeneous multi-chain frame- work , draft 1, https://github.com/w3f/polkadot-white-paper/raw/ master/PolkaDotPaper.pdf , 2016. 124 Appendix A. The TON Coin A The TON Coin The principal cryptocurrency of the TON Blockchain, and in particular of its masterchain and basic workchain, is the TON Coin . It is used to make deposits required to become a validator; transaction fees, gas payments (i.e., smart-contract message processing fees) and persistent storage payments are also usually collected in TON coins. A.1. Subdivision and terminology. A TON coin is subdivided into one billion ( 109) smaller units, called nanotons , ntons or simply nanos . All trans- fers and account balances are expressed as non-negative integer multiples of nanos. Other units include: ˆ A nano , nton or nanoton is the smallest unit, equal to 10−9 TON coins. ˆ A micro or microton equals one thousand ( 103) nanos. ˆ A milli is one million ( 106) nanos, or one thousandth part ( 10−3) of a TON coin. ˆ A TON coin equals one billion ( 109) nanos. ˆ A kiloton , or kTon , equals one thousand ( 103) TON coins. ˆ A megaton , or MTon , equals one million ( 106) TON coins, or 1015 nanos. ˆ Finally, a gigaton , or GTon , equals one billion ( 109) TON coins, or 1018 nanos. There will be no need for larger units, because the initial supply of TON coins will be limited to ve billion ( 5· 109) TON coins (i.e., 5 Gigatons). A.2. Smaller units for expressing gas prices. If the necessity for smaller units arises, specks equal to 2−16 nanotons will be used. For example, gas prices may be indicated in specks. However, the actual fee to be paid, com- puted as the product of the gas price and the amount of gas consumed, will be always rounded down to the nearest multiple of 216 specks and expressed as an integer number of nanos. 125 Appendix A. The TON Coin A.3. Original supply, mining rewards and ination. The total supply of TON coins is originally limited to 5 Gigatons (i.e., ve billion TON coins or 5· 1018 nanos). This supply will increase very slowly, as rewards to validators for mining new masterchain and shardchain blocks accumulate. These rewards would amount to approximately 20% (the exact number may be adjusted in future) of the validator's stake per year, provided the validator diligently performs its duties, signs all blocks, never goes oine and never signs invalid blocks. In this way, the validators will have enough prot to invest into better and faster hardwar
프로젝트로 돌아가기