# DeGate Legacy Markdown version of https://l2beat.com/layer2s/projects/degate ## Summary **Warning:** This project is archived and no longer maintained. **Warning:** This project is in shutdown mode and no longer active. - Stage: Stage 2 - Type: ZK Rollup - Purpose: Exchange - Host chain: Ethereum ### Risks - Sequencer failure: Force via L1 (sentiment: good) - State validation: Validity proofs (SN) (sentiment: good) - Data availability: Onchain (sentiment: good) - Exit window: ∞ (sentiment: good) - Proposer failure: Use escape hatch (sentiment: good) ### About DeGate Legacy is a shut down deployment of DeGate, an app-specific ZK Rollup that enables a trustless, fast and low-fee decentralized order book exchange, helping users to trade easy and sleep easy. DeGate smart contracts are forked from Loopring V3. ## Onchain costs Shown as an interactive chart or widget on [the HTML page](https://l2beat.com/layer2s/projects/degate#onchain-costs). ## Milestones & Incidents - 2023-05-03: [DeGate DEX Launches Mainnet Beta](https://medium.com/degate/degate-dex-launches-mainnet-beta-trade-easy-sleep-easy-603574bd3a46). DeGate launches mainnet beta with a deposit cap and a program to recover eventual user losses. ## Risk summary ### Users can be censored if 1. the operator refuses to include their transactions. However, there exists a mechanism to independently exit the system. ### MEV can be extracted if 2. the operator exploits their centralized position and frontruns user transactions. ## Risk analysis ### Sequencer failure Force via L1 (sentiment: good) Users can force the sequencer to include a withdrawal transaction by submitting a request through L1 with a 0.01 ETH fee. If the sequencer is down for more than 15d, users can use the exit hatch to withdraw their funds. The sequencer can censor individual deposits, but in such case after 15d users can get their funds back. ### State validation Validity proofs (SN) (sentiment: good) SNARKs are succinct zero knowledge proofs that ensure state correctness, but require trusted setup. ### Data availability Onchain (sentiment: good) All of the data needed for proof construction is published on Ethereum L1. ### Exit window ∞ (sentiment: good) Users can exit funds at any time because contracts are not upgradeable. ### Proposer failure Use escape hatch (sentiment: good) Users are able to trustlessly exit by submitting a Merkle proof of funds. ## Stage DeGate Legacy is a Stage 2 ZK Rollup. ### Stage 0 - [x] A complete and functional proof system is deployed. - [x] The project calls itself a rollup. - [x] State roots are posted to Ethereum L1. - [x] Inputs for the state transition function are posted to Ethereum L1. - [x] A source-available node exists that can recreate the state from Ethereum L1 data. Please note that the L2BEAT team has not verified the validity of the node source code. [View code](https://github.com/degatedev/degate-state-recover) ### Stage 1 - [x] Principle: Compromising ≥75% of the Security Council is the only way (other than bugs) for a rollup to indefinitely block an L2→L1 message (e.g. a withdrawal) or push an invalid L2→L1 message (e.g. an invalid withdrawal) with a <7d exit window. - [x] Users are able to exit without the help of the permissioned operators. ### Stage 2 - [x] Users have at least 30d to exit as the system cannot be upgraded. ## Data availability ### All data required for proofs is published onchain All the data that is used to construct the system state is published onchain in the form of cheap calldata. This ensures that it will always be available when needed. **References** - [Introduction - DeGate design doc](https://github.com/degatedev/protocols/blob/degate_mainnet/DeGate%20Protocol%20Specification%20Document.md#design-features) ## State derivation ### Node software Node software source code can be found [here](https://github.com/degatedev/degate-state-recover). ### Compression scheme No compression is used. ### Genesis state The system does not begin with a genesis state; instead, it initiates from a zero state, as referenced in [`CreateEmptyState`](https://github.com/degatedev/degate-state-recover/blob/main/statemanager/state.go#L28). ### Data format DeGate bundles off-chain transactions into [zkBlocks](https://github.com/degatedev/protocols/blob/degate_mainnet/Circuit%20Design.md#zkblock) and submits them to the blockchain. zkBlock data definition is documented [here](https://github.com/degatedev/protocols/blob/degate_mainnet/Smart%20Contract%20Design.md#zkblock-data-definition). ## State validation ### Validity proofs Each update to the system state must be accompanied by a ZK proof that ensures that the new state was derived by correctly applying a series of valid user transactions to the previous state. These proofs are then verified on Ethereum by a smart contract. **References** - [Operator - DeGate design doc](https://github.com/degatedev/protocols/blob/degate_mainnet/DeGate%20Protocol%20Specification%20Document.md#operator) ## Updates Shown as an interactive chart or widget on [the HTML page](https://l2beat.com/layer2s/projects/degate#updates). ## Operator ### The system has a centralized operator The operator is the only entity that can propose blocks. A live and trustworthy operator is vital to the health of the system. **Risks** - MEV can be extracted if the operator exploits their centralized position and frontruns user transactions. **References** - [ExchangeV3.sol#L341-L348 - DeGate source code](https://etherscan.io/address/0xe63602a9B3DFE983187525AC985Fec4F57B24eD5#code#F1#L341) - [LoopringIOExchangeOwner.sol#L98-L101 - DeGate source code](https://etherscan.io/address/0x6B937A5920726e70c5bF1d4d4E18EEeEd46FaE83#code#F1#L98) ### Users can force exit the system Force exit allows the users to escape censorship by withdrawing their funds. The system allows users to force the withdrawal of funds by submitting a request directly to the contract onchain. The request must be served within a defined time period. If this does not happen, the system will halt regular operation and permit trustless withdrawal of funds. **Risks** - Users can be censored if the operator refuses to include their transactions. However, there exists a mechanism to independently exit the system. **References** - [Forced Withdrawals - DeGate design doc](https://github.com/degatedev/protocols/blob/degate_mainnet/Smart%20Contract%20Design.md#force-withdrawal) ## Withdrawals ### Regular exit The user initiates the withdrawal by submitting a regular transaction on this chain. When the block containing that transaction is settled the funds become available for withdrawal on L1. ZK proofs are required to settle blocks. Finally the user submits an L1 transaction to claim the funds. **References** - [Withdraw - DeGate design doc](https://github.com/degatedev/protocols/blob/degate_mainnet/Smart%20Contract%20Design.md#normal-withdrawal) ### Forced exit If the user experiences censorship from the operator with regular exit they can submit their withdrawal requests directly on L1. The system is then obliged to service this request. Once the force operation is submitted and if the request is serviced, the operation follows the flow of a regular exit. **References** - [Forced Request Handling - DeGate design doc](https://github.com/degatedev/protocols/blob/degate_mainnet/Smart%20Contract%20Design.md#force-withdrawal) - [ExchangeV3.sol#L392 - DeGate source code, forceWithdraw function](https://etherscan.io/address/0xe63602a9B3DFE983187525AC985Fec4F57B24eD5#code#F1#L392) ### Emergency exit If the 15d deadline passes and the forced exit is still ignored the user can put the system into Withdrawal Mode, disallowing further state updates. In that case everybody can withdraw by submitting a merkle proof of their funds with their L1 transaction. **References** - [Forced Request Handling - DeGate design doc](https://github.com/degatedev/protocols/blob/degate_mainnet/Smart%20Contract%20Design.md#exodus-mode) - [ExchangeV3.sol#L420 - DeGate source code, withdrawFromMerkleTree function](https://etherscan.io/address/0xe63602a9B3DFE983187525AC985Fec4F57B24eD5#code#F1#L420) ## Permissions ### Ethereum #### Actors ##### DefaultDepositContract Owner Addresses: [0x2028834B2c0A36A918c10937EeA71BE4f932da52](https://etherscan.io/address/0x2028834B2c0A36A918c10937EeA71BE4f932da52) This address is the owner of the following contracts: LoopringIOExchangeOwner, LoopringV3, DefaultDepositContract. Can add or remove block submitters. Can change the forced withdrawal fee up to 0.25 ETH. Can change a way that balance is calculated per contract during the deposit, allowing the support of non-standard tokens. ##### BlockVerifier Owner Addresses: [0xd8C695DfAab475f55327Ce269096923EFECa2e0F](https://etherscan.io/address/0xd8C695DfAab475f55327Ce269096923EFECa2e0F) This address is the owner of the BlockVerifier contract. ##### 2 EOAs Addresses: [0x84A00D39C3c95e839202E19F892F17743d6370a0](https://etherscan.io/address/0x84A00D39C3c95e839202E19F892F17743d6370a0), [0xE9A37E8DDDbf4Bb3f5d6aCE6D01a137e484Db77C](https://etherscan.io/address/0xE9A37E8DDDbf4Bb3f5d6aCE6D01a137e484Db77C) Actors who can submit new blocks, updating the L2 state on L1. ## Smart contracts ### Ethereum #### ExchangeV3 Addresses: [0xe63602a9B3DFE983187525AC985Fec4F57B24eD5](https://etherscan.io/address/0xe63602a9B3DFE983187525AC985Fec4F57B24eD5#code) Main ExchangeV3 contract. #### LoopringIOExchangeOwner Addresses: [0x6B937A5920726e70c5bF1d4d4E18EEeEd46FaE83](https://etherscan.io/address/0x6B937A5920726e70c5bF1d4d4E18EEeEd46FaE83#code) Contract used by the Prover to submit exchange blocks with zkSNARK proofs that are later processed and verified by the BlockVerifier contract. #### DefaultDepositContract Addresses: [0x814d0c1903D69EB1c7ceB8F5190B20A06892d1dA](https://etherscan.io/address/0x814d0c1903D69EB1c7ceB8F5190B20A06892d1dA#code) ERC 20 token basic deposit contract. Handles user deposits and withdrawals. #### LoopringV3 Addresses: [0x4d707cae77c5E82a00BF9572A55d3ef3a4e0c458](https://etherscan.io/address/0x4d707cae77c5E82a00BF9572A55d3ef3a4e0c458#code) Contract for setting exchange fee parameters. #### BlockVerifier Addresses: [0x1c602313cDDC68C5789aCb7df0C92a93B0E04C9e](https://etherscan.io/address/0x1c602313cDDC68C5789aCb7df0C92a93B0E04C9e#code) zkSNARK Verifier based on ethsnarks library.