Celer Network 백서

Celer Network

원문

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

nough capital for channel deposits or fraud-proof bonds. Such a mismatch creates a huge hurdle for the mass adoption and technical evolution of o↵-chain operating networks. • Scalability vs. Availability . While o↵-chain scaling does not make any com- promise on the trust-free property of the blockchain, it does sacrifice the avail- ability guarantee. Each state channel or o↵-chain contract is associated with a dispute timeout, and the involved party will be at risk when staying o↵-line longer than the timeout, or when the local states are lost. Therefore, we need an incentive-compatible mechanism to provide sucient liquid- ity for entities which are capable of running a reliable and scalable o↵-chain service infrastructure, and to guarantee that the o↵-chain states are always available for pos- sible on-chain dispute. New cryptoeconomics. To complete the o↵-chain scaling solution, we introduce a suite of cryptoeconomic mechanisms, named cEconomy, that brings indispensable value and provides network e↵ect, stable liquidity, and high availability through the Celer Network’s protocol token (“CELR ”) and three tightly coupled components. • Proof of Liquidity Commitment(PoLC). PoLC is a virtual mining process that acquires abundant and stable liquidity for the o↵-chain ecosystem. To par- ticipate, one simply needs to commits (locks) his idle liquidity (in the form of 9 digital assets, including but not limited to cryptocurrencies and CELR) to the o↵-chain platform for a certain period of time with CELR rewarded as incentives to such users. • Liquidity Backing Auction (LiBA). LiBA enables o↵-chain service providers to solicit liquidity through “crowd lending” with negotiated interest rates. Lenders are ranked according to their “happiness scores” that are determined by the interest rate, the amount of provisioned liquidity and the amount of staked CELR. In particular, lenders who stake more CELR (as an indicator for their past contributions to the ecosystems) have higher priority to be selected to provide liquidity to o↵-chain service providers. • State Guardian Network (SGN). SGN is a special compact sidechain that guards the states when users are o✏ine so that the users’ states are always available for dispute. Guardians need to stake their CELR into SGN to earn guarding opportunities and service fees from the users. Section 5 introduces cEconomy mechanisms in detail with analysis of the CELR value and model incentive-compatibility. 2. cChannel: the Foundation of O↵-Chain Scaling Celer Network’s cChannel aims to provide a framework to enable a state channel and sidechain network with maximum flexibility and eciency. This section starts with the generalized channel construct and outlines the key elements to support arbitrary conditional dependency between on-chain verifiable states. We then expand the horizon beyond classic state channel and examine how to encapsulate sidechain into the same interface exposed to the upper layer. 2.1. Generalized State Channel 2.1.1. Key Idea and a Simple Example One major limitation of the existing payment network solutions is the lack of support for generalized state transitions. The need for generalized state transitions comes with the rise of smart contract platforms such as Ethereum. Smart contract enables asyn- chronous value transfer based on arbitrary contractual logic. To improve the scalability 10 of such blockchains using o↵-chain state channel concepts, on-chain state transitions should be put into o↵-chain state channels and the corresponding value transfer should be made aware of such state transitions. We use a simple example of conditional payment to illustrate the key idea about how to transform on-chain states transition to o↵-chain states transitions. Let’s say Alice and Carl want to play a board game while betting on the result of such game in a trust-free manner: Alice will pay Carl $1 if Carl wins and vice versa. This is a simple logic to implement on-chain. One could build a smart contract that holds Alice’s and Carl’s payment before the game starts. Alice and Carl will just play that game by calling the on-chain smart contract’s functions. When one of them loses the game, surrenders, or times out, the winner gets the loser’s deposit. The deposits can be seen as payments that are conditionally issued (i.e. condition on that the counterparty wins). Unfortunately, on-chain smart contract operations are extremely slow and expensive as every transaction involves an on-chain transaction. O↵-chain state channel can be used to significantly improve scalability while main- taining the same semantic. Let’s assume there is a payment channel between Alice and Carl. To enable the above semantic, we need to expand the functionality of channel’s state proof to include a conditional lock that depends on the game’s winner state. Alice can then send Carl an o↵-chain conditional payment e↵ectively saying: “I will pay Carl $1 if the game contract’s who is winner function says Carl wins”. The game state transitions can be also moved o↵-chain. The most straightforward way is to still have an on-chain contract governing the rule of the board game and that contract’s address is referenced in the conditional payment. All the state transitions are happen- ing o↵-chain via mutually signed game states that can be injected into the on-chain contract when necessary. But in fact, since there is no requirement for any kind of value bond for the program states, the entire game contract and the associated states can always stay o↵-chain as long as involved parties are collaborative. The only requirement is that the relevant game states are on-chain verifiable when need to be. An on-chain verifiable state means other contracts or objects can refer to it with no ambiguity. To realize that, we need to have a reference translator contract that maps o↵-chain references (such as the hash of contract code, constructor parameters, and nonce) to on-chain references (contract address). With these constructs, the game between Alice and Carl involves only one 11 long-term on-chain contract that is not specific to the game logic, and no on-chain operation or initialization for the gaming. The example above reflects a specialized and simple instance of o↵-chain design patterns and it can be much more sophisticated. The conditional payment can be more complicated than just simple Boolean conditions, and can be designed in a way to redistribute locked up liquidity based on arbitrary contractual logic. In fact, conditional payments is simply a special case of a more generalized conditional state transition. The channel dependency can also be more complicated than one-to-one dependency to realize the common pattern of multi-hop state relays. We detail out the technical specification in the followings sections. 2.1.2. Design Goals Our top goal is to achieve fast, flexible and trust-free o↵-chain interactions. We expect in most cases o↵-chain state transitions will stay o↵-chain until final resolution. There- fore, we aim to optimize commonly used o↵-chain patterns into succinct interactions with built-in support from on-chain components. Our second goal is to design data structure and object interaction logic that works for di↵erent blockchains. Celer Network aims to build a blockchain-agnostic platform and to run on di↵erent blockchains that support smart contracts. Therefore, a common data structure schema and a certain layer of indirection are required. Besides these two highlighted goals, we plan to employ formal specification of chan- nel state machines and verify the security properties along with the communication protocols that alter those states. We should also aim to provide an ecient on-chain resolution mechanism whenever possible. 2.1.3. General Specification In this section, we provide specifications for the core components of cChannel’s gen- eralized state channel with a top-down approach, and describes the Common State Channel Interface that applies to any state channel with value transfer and arbi- trary contractual logic. There could be extensive specialization and optimization for di↵erent concrete use cases, but the principles stay the same. Before the detailed specification of a generalized state channel, we first introduce several important notations and terms that will be used throughout this section. 12 • (State). Denote by s the state of a channel. For a bi-party payment channel, s represents the available balances of the two parties; for a board game, s represents the board state. • (State Proof ). State proof serves as a bridge data structure between on-chain contracts and o↵-chain communication protocols. A state proof sp contains the following fields sp = s, seq, merkle root, sigs , (1) where s denotes the accumulative state updates up until now. Note that given a base state s0 and a state update s, we can uniquely produce a new channel state s. For example, in a bi-party payment channel, the base state s0 corresponds to deposits of the two parties and the state update s is a mapping that indicates the amount of tokens transferred from one participant to the other participant. seq is the sequence number for the state proof. A state proof with a higher sequence number will disable state proofs with lower sequence numbers. merkle root is the root of the merkle tree of all pending condition groups and is crucial for creating conditional dependency between states in cChannel. Finally, sigs represents the signature from all parties on this state proof. State proof is valid only if all parties signatures are present. • (Condition). Condition cond is the data structure representing the basic unit of conditional dependency and this is where the conditional dependency DAGs are weaved. A condition can be specified as follows. cond = timeout, ⇤IsFinalized(args), ⇤QueryResult(args) (2) Here, timeout is the timeout after which the condition expires. For example, for a condition that depends on the results of a board game, timeout may correspond to the maximum duration of the board game (e.g., tens of minutes). Boolean function pointer IsFinalized(args) is used to check whether the condition has been resolved and settled before the condition timeout. The arguments for this function call are application-specific. For example, in the board game, the arguments could be as sim- ple as args =[ blocknumber] querying whether the game winner has been determined 13 before blocknumber. In addition, QueryResult(args) is a result query function pointer that returns arbitrary bytes as the condition’s resolving result. For exam- ple, in the board game, the arguments could be args =[ player1] querying whether player1 is the winner (boolean condition); in the second-price auction, the argu- ments could be args =[ participant1,p a r t i c i p a n t2, ··· ,p a r t i c i p a n t N]q u e r y i n gw h o is the winner and the amount of money each participant should pay (generic condi- tion). The resolution process for a condition is to first perform IsFinalized(args) and then perform result query QueryResult(args). • (Condition Group ). Condition group cond group is a higher-level abstraction for a group of conditions to express generalized state dependencies. A condition group can be specified as follows. cond group = ⇤, ResolveGroup(cond results) , (3) where ⇤ denotes a set of conditions contained in this condition group. Each condition cond 2 ⇤ resolves to an arbitrary bytes array (i.e., the output of cond.QueryResult(args)). These bytes array are handled by a group resolving function ResolveGroup(cond results) which takes the resolving results of all con- ditions as inputs and returns a state update s. For a payment channel, each con- dition group corresponds to a conditional payment. For example, a conditional pay- ment saying that “A pays B $1 if B wins the Gomoku game” corresponds to a condition group that contains two the conditions: the Hashed Time Lock condi- tion (for multi-hop relay) and the Gomoku game condition (“B wins the game”). The ResolveGroup function simply returns a transfer of $1 from A to B if both conditions are true. Now we are ready to specify the interface for a state channel. A state channel C can be specified as the following tuple: C = p, s0,s p ,s ,F,⌧ , (4) p = {p1,p 2,. . . ,pn} is the set of participants in this channel. s0 is the on-chain base state for this channel (e.g., initial deposits for each participant in a payment channel). sp represents the most updated known state proof for the channel. s is the updated 14 channel state after state proof sp is fully settled. ⌧ is the settlement timeout increment for the state proof that will be specified later. F contains a set of standard functions that should be implemented by every state channel: • ResolveStateProof(sp, cond groups). This function updates the current state proof by resolving attached condition groups. • GetUpdatedState(sp, s 0). This function is used to get the most updated state based on o↵-chain state proof sp and on-chain base states s0. • UpdateState(s). This function allows on-chain updates of state channel’s currently resolved state s. • IntendSettle(new sp). This function opens a challenge period before the settle- ment timeout. During the challenge period, this function takes a state proof as input and update the current state proof if the input is newer. • ConfirmSettle(sp). This function validates and confirms the current state proof as fully settled given the current time has exceeded the settlement timeout. • IsFinalized(args) and QueryResult(args) are the entry points for resolving con- ditional dependency. It accepts outside queries with necessary arguments for the querying contract to interpret accordingly. In fact, some patterns are used frequently enough, in cChannel’s implementation, we separate them into pre-defined function interfaces. • CloseStateChannel(s). This function terminates the life cycle of the state chan- nel and distributes necessary states out according the latest settled state s. Settlement timeout is determined based on time of last called ResolveStateProof or SettleStateProof and the settlement timeout increment is ⌧ . Dependency Constraints. When we create dependencies among di↵erent state channels, some constraints need to be enforced in order to guarantee a proper res- olution of the dependency DAG. Suppose state channel C1 depends on state channel C2. Then it is required that the participants of C1 should be a subset of the partici- pants of C2 such that the participants of C1 have the necessary information resolving its dependency on C1. 15 2.1.4. Common Utilities The above abstraction defines the common pattern for generalized state channel con- struction. In di↵erent blockchains, the actual implementation might be di↵erent. For example, in Ethereum, cross-contract calls contains return value but in Dfinity, cross- contract calls only trigger registered callbacks. Reviewing multiple blockchains’ imple- mentations on state transition VMs, we identify two common utilities that are essential for the operation of generalized state channel in practice as followings: • O↵-chain Address T ranslator (OA T). In the above abstraction, condition and condition group are associated with di↵erent functions. These functions should be the reference of on-chain contract’s functions, but since program (smart contract) states are not inherently bound to constraints on the blockchain, there should be no fundamental requirement to have an on-chain presence. The only barrier to moving them entirely o↵-chain is the possible ambiguity of reference for functions such as IsFinalized and QueryResult. To resolve this ambiguity, we can define an on-chain rule set to map o↵-chain references to on-chain references. O↵-chain Address Translator is built for that. For a contract with no value involved, it can be referenced by a unique identifier generated through its contract code, initial states, and a certain nonce. We call such unique identifier o↵-chain address. When resolving conditions on-chain, the referenced contracts need to be deployed and the corresponding functions (e.g., IsFinalized and QueryResult) should be able to translate o↵-chain addresses to on-chain addresses. To realize such functionality, OAT needs to be able to deploy contract code and initial states on-chain to get the on-chain contract and establish the mapping from o↵-chain address to on-chain address. • Hash Time Lock Registry(HTLR). Hash Time Lock is commonly used in the scenario where transactions involving multiple state channels need to happen atomically. For example, multi-hop relayed payment (unconditional or conditional), atomic swap between di↵erent tokens, cross-chain bridges and more. HTL can be implemented entirely o↵-chain, but as Sprite [5] has pointed out, this is an over- optimization that actually limits the o↵-chain scalability. Therefore, Sprite [5] pro- poses a central registry where all locks can refer to. We extend and modify Sprite to fit in cChannel’s common model. E↵ectively, HTLR provides dependency endpoints (IsFinalized, QueryResult) for conditions that act as locks. IsFinalized takes 16 a hash and block number and returns true if the corresponding pre-image has been registered before the block number. QueryResult takes a hash and returns true if the pre-image of the hash is registered. These two functions can be simplified further into one, but for the sake of generality, we can simply keep them as two separate functions. Note that HTLR, and associated IsFinalized and QueryResult,i s always on-chain. 2.1.5. Out-of-box Features In addition, we need to look into patterns that would be commonly used and enhance certain on-chain components with out-of-box features to simplify the corresponding o↵- chain interactions. Generalized Payment Channel (GPC) is a very good example of that. Generalized Payment Channel is payment channel that conforms to the general state channel specification and therefore can support various conditional payments based on further on-chain or o↵-chain objects. We first make the abstract model more concrete in the context of GPC. s0 represents the static deposit map for each party in p. s represents the final netted value each party owns. SubmitStateProof is the function to submit a state proof and trigger a timeout challenge period before SettleStateProof can be called and confirm the state proof. IsFinalized and QueryResult are functions to check whether the state of this payment channel has been finalized and query the current balances. One may wonder why a payment channel has an interface for outside query. This is because some other payments or states may depend on s or existence of certain conditional payment locked in sp. ResolveStateProofis the most interesting part as this is where a lot of specialized optimization will happen and greatly reduce the o↵-chain interaction complexity. GetUpdatedState is a straightforward function to compute the netted out payment for each party based on the initial deposit and the fully resolved sp. CloseStateChannel simply closes the channel and distributes the netted out the final balance for each party. With this basic model, we discuss how we can further optimize the GPC constructs to enable useful out-of-box features. • Cooperative Settling In most cases, counterparties of state channel applications are cooperative. As a result, it is added complexity and expense to go through the challenge period and then settle. Therefore, cChannel enables cooperative settling 17 where counterparties not only sign the most recent state proof, but also sign the resulting signature to show the agreement that the state update described in that state proof is indeed the final state. With this, the number of transactions to settle a state proof can reduce from 2 to 1. • Single-transaction Channel Opening Another optimization cChannel brings is to reduce the number of on-chain operation to open a
프로젝트로 돌아가기