LayerZero 백서

LayerZero

원문

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

ized permis- sioned set of operating organization(s) results in the per- manent, unrecoverable failure of the whole protocol. Through permissionless operation of DVNs, Lay- erZero is able to provide a practically unbounded degree of fault tolerance. Even ifall existing DVNs lose liveness from software bugs, security breaches, natural disasters, and/or operational/governance concerns, OApp develop- ers can operate their own DVNs to continue operation of the protocol. OApps can seamlessly reroute traffic through Security Stack reconfiguration, enabling recov- ery from compromised offchain infrastructure (Figure 7). 3.4 Executors Implementing and updating extrinsically secure code is resource-intensive due to stringent security testing and auditing requirements. This engineering challenge stands in conflict with our goal of making LayerZero easily extensible to support the needs of a wide variety of omnichain applications. LayerZero solves this prob- lem by separating verification from execution; any code that is not security-critical is factored out into executors, which are permissionless and isolated from the packet Source Chain Destination Chain Burn lzSend Message Options:
 <lzReceive, gas, value> <lzCompose, gas, value> Mint Swap sendCompose lzComposelzReceive LayerZero Endpoint LayerZero Endpoint composeQueue Packet Composed Payload Figure 8: lzCompose enables chain-agnostic composi- tion with liveness and safety closures. verification scope. This separation between security- critical and “feature” code between MessageLib and ex- ecutors respectively provides two main benefits. First, it allows developers to use, implement, and compose fea- ture extensions without considering security; the End- point prevents executors from delivering unverified or non-lossless messages, completely isolating packet ex- ecution from verification. Second, it decouples security and liveness in LayerZero, ensuring that a faulty executor cannot unilaterally prevent message delivery. By isolat- ing the verification and execution layers in this manner, applications can easily debug which layer an error origi- nated from. When an OApp sends a LayerZero message, it spec- ifies all offchain workers (e.g., executors, DVNs, etc.) and corresponding arguments through a MessageLib- interpreted byte array called Message Options. The ex- ecutors then wait for the Security Stack to verify the packet before taking action based on the commands en- coded in Message Options. We purposely left Message Options unstructured (see Section 4), as a more restrictive API only serves to limit the potential capabilities of future onchain and offchain workers. At the protocol level, our primary objective is to provide the highest degree of extensibility, rather than creating an interface that is specialized to the needs of current applications. The isolation of executors from any verification- related code indirectly improves channel validity, and permissionless execution directly improves channel live- 10 ness. This design reduces the code footprint of Mes- sageLib and, by extension, minimizes the potential to introduce attack surfaces into security-critical code. In addition, permissionless operation of executors ensures that channel liveness can be recovered in the event of executor failure, and fully decouples the liveness of the protocol from any single organization or entity. Once a message is verified by the Security Stack, anyone willing to pay the gas cost can permissionlessly execute the mes- sage. This theoretically allows even end-users to manu- ally trigger OApp recovery following executor failure. 4 Extensions In this section, we illustrate the flexibility of LayerZero through several examples of how the protocol can be ex- tended with additional execution features. 4.1 Message Options While there is no single standard format for serializing arguments into Message Options, we do not expect de- velopers to write specialized code to support Message Options for every MessageLib. To address this, Lay- erZero currently defines three standardized formats for Message Options (see Table 4) to facilitate backwards- compatibility between library versions. Types 1 and 2 specify arguments for a single executor to execute commonly-required functionality, while type 3 encodes a list of (workerID, option) tuples to allow for an arbitrary number of arguments passed to an arbitrary number of workers. Any message delivered by a execu- tor has already been verified by the verification layer, al- lowing any number of executors to perform arbitrary ac- tions without compromising message integrity. 4.2 Semantically uniform composition LayerZero defines a universally standardized interface for cross-chain composition: lzCompose. Composing the destination chain delivery transaction with other con- tracts may seem trivial to those familiar only with EVM, which provides a native mechanism for arbitrary run- time dispatch. However, even existing MoveVM-based blockchains do not natively support this feature, inval- idating the universality of EVM-style runtime dispatch composition semantics. When composing contracts, the receiver first stores a composed payload into the end- point ( sendCompose), after which it is retrieved from the ledger and passed to the composed callback by call- ing lzCompose. This design, while superficially ineffi- cient on EVM-based chains, unifies composition seman- tics across all blockchains. Chain A / OApp Chain B / OApp Chain C / OApp lock 10Block 10A lock 10C Compromised mint = 10A mint = 10B mint = 10C Send malicious packet mint (+10)B Verify Invariants Maliciously return “true” Receive & Simulate Packet(s) mint += 10B Σ mint = 40 Simulate Global State Σ mint Σ lock= 40 = 30 Simulate Global State Verify Invariants Σ mint ≤Σ lock ? Verify Invariants Σ mint ≤Σ lock ? All Invariants fullfilled? DeliverHalt Pre-Crime Σ lock = 30 Figure 9: Pre-Crime rejects malicious and malformed messages by checking OApp-specified invariants. lzCompose provides a semantically universal stan- dard composition primitive that inherits the same only- once lossless execution semantics of LayerZero messag- ing, and allows OApps to define a single application ar- chitecture that universally scales to all existing and fu- ture blockchains. Figure 8 illustrates an example of us- ing lzCompose to bridge and swap a token in a single LayerZero transaction. The lzCompose primitive is a powerful tool for defin- ing closures for data validity and channel liveness, iso- lating each composed contract from potential integrity violations by other contracts. Once data is stored us- ing lzCompose, the liveness and integrity are “closed”, meaning errors in composed contracts can cause loss of liveness or data validity onlywithin the closure. Isolation of composed contract faults to the closure scope greatly simplifies reasoning about potential attack surfaces such as reentrancy. An additional benefit of lzCompose is a uniform in- terface for tracing and analysis of a potentially deep call stack for complex multihop omnichain transactions, giv- ing OApp developers a powerful tool to tackle the poten- tially daunting task of debugging omnichain code. 4.3 Application-level security It is impossible to use the Message Options interface to extend the verification scope to include additional data, but OApps can use it to detect and filter out verified-yet- malicious messages (e.g., buggy messages that would trigger OApp-level faults). We introduce our novel of- fchain application-level security mechanism called Pre- Crime, which provides an additional layer of application- 11 specific packet filtering on top of the existing LayerZero protocol. Pre-Crime enables any subset of peers (i.e., some or all of an OApp’s contracts) to enforce appli- cation security invariants after simulating the result of packet delivery. The invariant check results are collated by an offchain worker, which halts delivery of the corre- sponding packet if any peer reports a violated invariant. Figure 9 illustrates the example of checking the total outstanding token count in a 3-chain token bridge. To use Pre-Crime, the OApp encodes the DVN address and Pre-Crime specific arguments in Message Options. The OApp specifies the invariant that the total minted tokens across all chains ∑mint is less than or equal to the to- tal locked liquidity ∑lock. Initially, mintA = mintB = mintC = 10, and lockA = lockB = lockC = 10. Chain A is compromised and tries to request an additional mint of 10 tokens on chain B without locking any additional as- sets. Pre-Crime detects this after checking token counts for all chains, isolating the security breach to a single chain (chain A). The receiver can then skip the nonce if necessary by calling skip (Table 3). It is important to note that Pre-Crime does not add any additional proto- col security, and cannot protect data integrity (malicious DVNs or blockchain-level faults). Pre-Crime and lzCompose are just two examples of execution features that are supported by LayerZero. The flexibility of Message Options and the separation be- tween verification and execution enables a LayerZero to be extended to a wide variety of execution features. 5 Conclusion In this paper, we presented the design and implementa- tion of the LayerZero protocol. LayerZero provides in- trinsically secure cross-chain messaging with universal semantics to enable a fully connected omnichain mesh network that connects all blockchains within and across compatibility groups. By isolating intrinsic security from extrinsic security, LayerZero guarantees long-term stability of channel in- tegrity and gives OApps universal network semantics across the entire mesh network. LayerZero’s universal network semantics and intrinsic security guarantees en- able secure chain-agnostic interoperation. Our novel onchain verification module, MessageLib, implements extensible extrinsic security in an intrinsi- cally secure manner. Each OApp has exclusive permis- sion to modify its Security Stack, which defines the ex- trinsic security (MessageLib, DVNs) of their messaging channel. The immutability of existing MessageLibs en- sures that no entity, including the protocol administrator, can unilaterally compromise OApp security. LayerZero’s isolation of execution features from packet verification allows a near-unlimited degree of freedom to implement additional features without affect- ing security. In addition, the separation of execution and verification in LayerZero reduces engineering costs, attack surfaces, and improves overall protocol liveness. Together, these components create a highly extensible protocol that can provide universal messaging semantics across existing and future blockchains. LayerZero is the protocol that brings consistency and simplicity to a land- scape of scattered, ad-hoc messaging services, and lays the foundation for the fully-connected omnichain mesh network of the future. References [1] B EHNKE , R. Explained: The nomad hack (august 2022). https://www.halborn.com/blog/post/explained-the- nomad-hack-august-2022 . [2] G MYTRASIEWICZ , P. J., AND DURFEE , E. H. Decision-theoretic recursive modeling and the coordinated attack problem. In Pro- ceedings of the First International Conference on Artificial Intelli- gence Planning Systems(San Francisco, CA, USA, 1992), Morgan Kaufmann Publishers Inc., p. 88–95. [3] HAC XYK . Wormhole $10m bounty. https://twitter.com/ Hacxyk/status/1529389391818510337. [4] THORC HAIN . Post-mortem: Eth router exploits 1 & 2, and premature return to trading incident. https: //medium.com/thorchain/post-mortem-eth-router- exploits-1-2-and-premature-return-to-trading- incident-2908928c5fb. [5] Z AMYATIN , A., A L-BASSAM , M., Z INDROS , D., K OKORIS - KOGIAS , E., M ORENO -SANCHEZ , P., KIAYIAS , A., AND KNOT- TENBELT , W. J. Sok: Communication across distributed ledgers. Cryptology ePrint Archive, Paper 2019/1128, 2019. https:// eprint.iacr.org/2019/1128. [6] Z ARICK , R., P ELLEGRINO , B., AND BANISTER , C. Layerzero: Trustless omnichain interoperability proto- col. https://layerzero.network/pdf/LayerZero_ Whitepaper_Release.pdf. 12
프로젝트로 돌아가기