Gram 백서

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

k headers for TON blockchains. Usually, a block in a blockchain begins with a small header, containing the hash of the previous block, its creation time, the Merkle hash of the tree of all transactions con- tained in the block, and so on. Then the block hash is dened to be the hash of this small block header. Because the block header ultimately depends on all data included in the block, one cannot alter the block without changing its hash. In the bag of cells approach used by the blocks of TON blockchains, there is no designated block header. Instead, the block hash is dened as the (Merkle) hash of the root cell of the block. Therefore, the top (root) cell of the block might be considered a small header of this block. 43 2.6. Creating and V alidating New Blocks However, the root cell might not contain all the data usually expected from such a header. Essentially, one wants the header to contain some of the elds dened in the Block datatype. Normally, these elds will be contained in several cells, including the root. These are the cells that together constitute a Merkle proof for the values of the elds in question. One might insist that a block contain these header cells in the very beginning, before any other cells. Then one would need to download only the rst several bytes of a block serialization in order to obtain all of the header cells, and to learn all of the expected elds. 2.6 Creating and Validating New Blocks The TON Blockchain ultimately consists of shardchain and masterchain blocks. These blocks must be created, validated and propagated through the network to all parties concerned, in order for the system to function smoothly and correctly. 2.6.1. Validators. New blocks are created and validated by special desig- nated nodes, called validators . Essentially, any node wishing to become a validator may become one, provided it can deposit a suciently large stake (in TON coins, i.e., TON coins; cf. Appendix A ) into the masterchain. Val- idators obtain some rewards for good work, namely, the transaction, storage and gas fees from all transactions (messages) committed into newly gener- ated blocks, and some newly minted coins, reecting the gratitude of the whole community to the validators for keeping the TON Blockchain working. This income is distributed among all participating validators proportionally to their stakes. However, being a validator is a high responsibility. If a validator signs an invalid block, it can be punished by losing part or all of its stake, and by being temporarily or permanently excluded from the set of validators. If a validator does not participate in creating a block, it does not receive its share of the reward associated with that block. If a validator abstains from creating new blocks for a long time, it may lose part of its stake and be suspended or permanently excluded from the set of validators. All this means that the validator does not get its money for nothing. Indeed, it must keep track of the states of all or some shardchains (each validator is responsible for validating and creating new blocks in a certain subset of shardchains), perform all computations requested by smart con- 44 2.6. Creating and V alidating New Blocks tracts in these shardchains, receive updates about other shardchains and so on. This activity requires considerable disk space, computing power and network bandwidth. 2.6.2. Validators instead of miners. Recall that the TON Blockchain uses the Proof-of-Stake approach, instead of the Proof-of-Work approach adopted by Bitcoin, the current version of Ethereum, and most other cryptocurrencies. This means that one cannot mine a new block by presenting some proof-of- work (computing a lot of otherwise useless hashes) and obtain some new coins as a result. Instead, one must become a validator and spend one's computing resources to store and process TON Blockchain requests and data. In short, one must be a validator to mine new coins. In this respect, validators are the new miners. However, there are some other ways to earn coins apart from being a validator. 2.6.3. Nominators and mining pools. To become a validator, one would normally need to buy and install several high-performance servers and acquire a good Internet connection for them. This is not so expensive as the ASIC equipment currently required to mine Bitcoins. However, one denitely cannot mine new TON coins on a home computer, let alone a smartphone. In the Bitcoin, Ethereum and other Proof-of-Work cryptocurrency mining communities there is a notion of mining pools , where a lot of nodes, having insucient computing power to mine new blocks by themselves, combine their eorts and share the reward afterwards. A corresponding notion in the Proof-of-Stake world is that of a nominator . Essentially, this is a node lending its money to help a validator increase its stake; the validator then distributes the corresponding share of its reward (or some previously agreed fraction of itsay, 50%) to the nominator. In this way, a nominator can also take part in the mining and obtain some reward proportional to the amount of money it is willing to deposit for this purpose. It receives only a fraction of the corresponding share of the validator's reward, because it provides only the capital, but does not need to buy computing power, storage and network bandwidth. However, if the validator loses its stake because of invalid behavior, the nominator loses its share of the stake as well. In this sense the nominator shares the risk . It must choose its nominated validator wisely, otherwise it can lose money. In this sense, nominators make a weighted decision and vote for certain validators with their funds. 45 2.6. Creating and V alidating New Blocks On the other hand, this nominating or lending system enables one to become a validator without investing a large amount of money into TON coins rst. In other words, it prevents those keeping large amounts of TON coins from monopolizing the supply of validators. 2.6.4. Fishermen: obtaining money by pointing out others' mis- takes. Another way to obtain some rewards without being a validator is by becoming a sherman . Essentially, any node can become a sherman by making a small deposit in the masterchain. Then it can use special mas- terchain transactions to publish (Merkle) invalidity proofs of some (usually shardchain) blocks previously signed and published by validators. If other validators agree with this invalidity proof, the oending validators are pun- ished (by losing part of their stake), and the sherman obtains some reward (a fraction of coins conscated from the oending validators). Afterwards, the invalid (shardchain) block must be corrected as outlined in 2.1.17 . Cor- recting invalid masterchain blocks may involve creating vertical blocks on top of previously committed masterchain blocks (cf. 2.1.17 ); there is no need to create a fork of the masterchain. Normally, a sherman would need to become a full node for at least some shardchains, and spend some computing resources by running the code of at least some smart contracts. While a sherman does not need to have as much computing power as a validator, we think that a natural candidate to become a sherman is a would-be validator that is ready to process new blocks, but has not yet been elected as a validator (e.g., because of a failure to deposit a suciently large stake). 2.6.5. Collators: obtaining money by suggesting new blocks to val- idators. Yet another way to obtain some rewards without being a validator is by becoming a collator . This is a node that prepares and suggests to a validator new shardchain block candidates, complemented (collated) with data taken from the state of this shardchain and from other (usually neigh- boring) shardchains, along with suitable Merkle proofs. (This is necessary, for example, when some messages need to be forwarded from neighboring shardchains.) Then a validator can easily check the proposed block candi- date for validity, without having to download the complete state of this or other shardchains. Because a validator needs to submit new (collated) block candidates to obtain some (mining) rewards, it makes sense to pay some part of the reward to a collator willing to provide suitable block candidates. In this way, 46 2.6. Creating and V alidating New Blocks a validator may free itself from the necessity of watching the state of the neighboring shardchains, by outsourcing it to a collator. However, we expect that during the system's initial deployment phase there will be no separate designated collators, because all validators will be able to act as collators for themselves. 2.6.6. Collators or validators: obtaining money for including user transactions. Users can open micropayment channels to some collators or validators and pay small amounts of coins in exchange for the inclusion of their transactions in the shardchain. 2.6.7. Global validator set election. The global set of validators is elected once each month (actually, every 219 masterchain blocks). This set is determined and universally known one month in advance. In order to become a validator, a node must transfer some TON coins into the masterchain, and then send them to a special smart contract as its suggested stake s. Another parameter, sent along with the stake, is l≥ 1, the maximum validating load this node is willing to accept relative to the minimal possible. There is also a global upper bound (another congurable parameter) L on l, equal to, say, 10. Then the global set of validators is elected by this smart contract, simply by selecting up to T candidates with maximal suggested stakes and publishing their identities. Originally, the total number of validators is T = 100 ; we expect it to grow to 1000 as the load increases. It is a congurable parameter (cf. 2.1.21 ). The actual stake of each validator is computed as follows: If the top T proposed stakes are s1≥s2≥···≥ sT , the actual stake of i-th validator is set to s′i := min(si,l i·sT ). In this way, s′i/s′T≤li, so the i-th validator does not obtain more than li≤L times the load of the weakest validator (because the load is ultimately proportional to the stake). Then elected validators may withdraw the unused part of their stake, si−s′i. Unsuccessful validator candidates may withdraw all of their proposed stake. Each validator publishes its public signing key , not necessarily equal to the public key of the account the stake came from. 20 The stakes of the validators are frozen until the end of the period for which they have been elected, and one month more, in case new disputes 20 It makes sense to generate and use a new key pair for every validator election. 47 2.6. Creating and V alidating New Blocks arise (i.e., an invalid block signed by one of these validators is found). After that, the stake is returned, along with the validator's share of coins minted and fees from transactions processed during this time. 2.6.8. Election of validator task groups. The whole global set of val- idators (where each validator is considered present with multiplicity equal to its stakeotherwise a validator might be tempted to assume several identi- ties and split its stake among them) is used only to validate new masterchain blocks. The shardchain blocks are validated only by specially selected sub- sets of validators, taken from the global set of validators chosen as described in 2.6.7 . These validator subsets or task groups, dened for every shard, are rotated each hour (actually, every 210 masterchain blocks), and they are known one hour in advance, so that every validator knows which shards it will need to validate, and can prepare for that (e.g., by downloading missing shardchain data). The algorithm used to select validator task groups for each shard (w,s ) is deterministic pseudorandom. It uses pseudorandom numbers embedded by validators into each masterchain block (generated by a consensus using threshold signatures) to create a random seed, and then computes for ex- ample Hash (code (w). code (s).validator_id .rand_seed ) for each validator. Then validators are sorted by the value of this hash, and the rst several are selected, so as to have at least 20/T of the total validator stakes and consist of at least 5 validators. This selection could be done by a special smart contract. In that case, the selection algorithm would easily be upgradable without hard forks by the voting mechanism mentioned in 2.1.21 . All other constants mentioned so far (such as 219, 210, T , 20, and 5) are also congurable parameters. 2.6.9. Rotating priority order on each task group. There is a certain priority order imposed on the members of a shard task group, depending on the hash of the previous masterchain block and (shardchain) block sequence number. This order is determined by generating and sorting some hashes as described above. When a new shardchain block needs to be generated, the shard task group validator selected to create this block is normally the rst one with respect to this rotating priority order. If it fails to create the block, the second or third validator may do it. Essentially, all of them may suggest their block candidates, but the candidate suggested by the validator having the highest 48 2.6. Creating and V alidating New Blocks priority should win as the result of Byzantine Fault Tolerant (BFT) consensus protocol. 2.6.10. Propagation of shardchain block candidates. Because shard- chain task group membership is known one hour in advance, their members can use that time to build a dedicated shard validators multicast overlay net- work, using the general mechanisms of the TON Network (cf. 3.3 ). When a new shardchain block needs to be generatednormally one or two seconds after the most recent masterchain block has been propagatedeverybody knows who has the highest priority to generate the next block (cf. 2.6.9 ). This validator will create a new collated block candidate, either by itself or with the aid of a collator (cf. 2.6.5 ). The validator must check (validate) this block candidate (especially if it has been prepared by some collator) and sign it with its (validator) private key. Then the block candidate is propagated to the remainder of the task group using the prearranged multicast overlay network (the task group creates its own private overlay network as explained in 3.3 , and then uses a version of the streaming multicast protocol described in 3.3.15 to propagate block candidates). A truly BFT way of doing this would be to use a Byzantine multicast protocol, such as the one used in Honey Badger BFT [11]: encode the block candidate by an (N, 2N/3)-erasure code, send 1/N of the resulting data directly to each member of the group, and expect them to multicast directly their part of the data to all other members of the group. However, a faster and more straightforward way of doing this (cf. also 3.3.15 ) is to split the block candidate into a sequence of signed one-kilobyte blocks (chunks), augment their sequence by a ReedSolomon or a fountain code (such as the RaptorQ code [9] [14]), and start transmitting chunks to the neighbors in the multicast mesh (i.e., the overlay network), expecting them to propagate these chunks further. Once a validator obtains enough chunks to reconstruct the block candidate from them, it signs a conrmation receipt and propagates it through its neighbors to the whole of the group. Then its neighbors stop sending new chunks to it, but may continue to send the (original) signatures of these chunks, believing that this node can generate the subsequent chunks by applying the ReedSolomon or fountain code by itself (having all data necessary), combine them with signatures, and propagate to its neighbors that are not yet ready. If the multicast mesh (overlay network) remains connected after remov- ing all bad nodes (recall that up to one-third of nodes are allowed to be 49 2.6. Creating and V alidating New Blocks bad in a Byzantine way, i.e., behave in arbitrary malicious fashion), this algorithm will propagate the block candidate as quickly as possible. Not only the designated high-priority block creator may multicast its block candidate to the whole of the group. The second and third validator by priority may start multicasting their block candidates, either immediately or after failing to receive a block candidate from the top priority validator. However, normally only the block candidate with maximal priority will be signed by all (actually, by at least two-thirds of the task group) validators and committed as a new shardchain block. 2.6.11. Validation of block candidates. Once a block candidate is re- ceived by a validator and the signature of its originating validator is checked, the receiving validator checks the validity of this block candidate, by per- forming all transactions in it and checking that their result coincides with the one claimed. All messages imported from other blockchains must be sup- ported by suitable Merkle proofs in the collated data, otherwise the block candidate is deemed invalid (and, if a proof of this is committed to the mas- terchain, the validators having already signed this block candidate may be punished). On the other hand, if the block candidate is found to be valid, the receiving validator signs it and propagates its signature to other validators in the group, either through the mesh multicast network, or by direct network messages. We would like to emphasize that a validator does not need access to the states of this or neighboring shardchains in order to check the validity of a (collated) block candidate . 21 This allows the validation to proceed very quickly (without disk accesses), and lightens the computational and storage burden on the validators (especially if they are willing to accept the services of outside collators for creating block candidates). 2.6.12. Election of the next block candidate. Once a block candidate collects at least two-thirds (by stake) of the validity signatures of validators in the task group, it is eligible to be committed as the next shardchain block. A BFT protocol is run to achieve consensus on the block candidate chosen (there may be more than one proposed), with all good validators preferring the block candidate with the highest priority for this round. As a result of 21 A possible exception is the state of output queues of the neighboring shardchains, needed to guarantee the message ordering requirements described in 2.4.21 , because the size of Merkle proofs might become prohibitive in this case. 50 2.6. Creating and V alidating New Blocks running this protocol, the block is augmented by signatures of at least two- thirds of the validators (by stake). These signatures testify not only to the validity of the block in question, but also to its being elected by the BFT protocol. After that, the block (without collated data) is combined with these signatures, serialized in a deterministic way, and propagated through the network to all parties concerned. 2.6.13. Validators must keep the blocks they have signed. During their membership in the task group and for at least one hour (or rather 210 blocks) afterward, the validators are expected to keep the blocks they have signed and committed. The failure to provide a signed block to other validators may be punished. 2.6.14. Propagating the headers and signatures of new shardchain blocks to all validators. Validators propagate the headers and signatures of newly-generated shardchain blocks to the global set of validators, using a multicast mesh network similar to the one created for each task group. 2.6.15. Generation of new masterchain blocks. After all (or almost all) new shardchain blocks have been generated, a new masterchain block may be generated. The procedure is essentially the same as for shardchain blocks (cf. 2.6.12
프로젝트로 돌아가기