Zircuit 백서

Zircuit

원문

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

https://lh7-us.googleusercontent.com/QwdVd0mN5m0LXFpOdI0nNNK3fNTPMz1M9jESYbwMPKM3Y7J3fdAJDRSLdAoAMbsmLB0XuSxVgX6xjJM519rj66fT_aU7c0jtHHzIazQCC1Fs_k6HitkmQ_U3JQTwCjAtKLYldVJBdny8Ngpi1eruXo4" alt=""><figcaption><p>Withdrawals in Zircuit</p></figcaption></figure> The withdrawal can be completed when the state root containing the L2 withdrawal transaction is included on L1 with a corresponding proof. A proof is necessary to complete the withdrawal function, as it ensures that the account withdrawing the funds had the funds in the first place. When the batches have been proven, the resulting state root is pushed to L1 via the `L2OutputOracle` smart contract alongside a validity proof for the state transition from the last state root. Once the verifier verifies the proof, the state root is recorded as final. Any withdrawals that depend on it can be processed immediately. # Transaction Statuses Transactions on Zircuit pass through several stages before they are fully recorded on the blockchain, which are described on this page. ## Pending When a transaction is sent to the sequencer, it first appears as `pending`. At this stage, the transaction has been accepted by the sequencer but has not yet been added to a block. This initial status means the transaction is awaiting inclusion in a batch of transactions that will eventually be submitted to the layer one. During this time, the transaction is not yet part of the blockchain, and there is no guarantee that it will be included in the final blockchain. Pending transactions are held in a mempool (memory pool), where they await sequencing. The sequencer processes these transactions, prioritising them based on factors such as gas fees and the order of arrival. The transaction will remain in this state until the sequencer includes it in a block. To view all pending transactions, use the JSON-RPC method [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) with the param set to `pending`. Monitoring the pending state can help in diagnosing issues like transaction congestion or delays. It also allows users to cancel or replace transactions if they need to adjust gas fees to expedite processing. ## Quarantined {% hint style="info" icon="triangle-exclamation" %} ## Note that [SLS](https://docs.zircuit.com/info/architecture/sls) is not enabled while we [focus](https://www.zircuit.com/blog/a-new-chapter-for-zircuit-from-l2-to-defi) on Zircuit Finance. Zircuit Finance does not rely on the Zircuit chain. {% endhint %} Zircuit protects users at the sequencer level by monitoring the mempool for malicious transactions and preventing their inclusion into a block. This novel approach means that our sequencer scrutinises transactions for potential malicious intent before they are finalized on layer two. This functionality is described on the [Sequencer Level Security](/info/architecture/sls-deep-dive) page. Zircuit monitors the mempool for new transactions and if it finds out that a transaction is considered risky, it is quarantined. This means it will be blocked from being including in layer two blocks. As a result, any polling or wait for a receipt will eventually time out. This transaction's status will be `quarantined`. The quarantined transaction can either be released or retired depending on the matching criteria. Zircuit continuously monitors for release criteria which may result in the transaction's inclusion in layer two blocks. Release criteria are also described on the [Sequencer Level Security](/info/architecture/sls-deep-dive) page. To check, whether a transaction's status is quarantined, we have introduced an additional RPC call to the Geth client. `zirc_isQuarantined` takes a transaction hash as a parameter and outputs the quarantine status of the transaction. The RPC call can be done through any tool of choice, such as Foundry's `cast`: ```bash cast rpc zirc_isQuarantined --rpc-url https://zircuit1-mainnet.p2pify.com/ 0x9b629147b75dc0b275d478fa34d97c5d4a26926457540b15a5ce871df36c23fd ``` ```javascript { "IsQuarantined": true, "Quarantine": { "TransactionHash": "0x9b629147b75dc0b275d478fa34d97c5d4a26926457540b15a5ce871df36c23fd", "QuarantinedAt": "2024-07-24T13:15:22.644132Z", "ExpiresOn": "2024-07-25T13:15:22.644131Z", "ReleasedReason": "", "QuarantinedBy": "Oracle", "QuarantinedReason": "transaction simulation returned a risk", "ReleasedBy": "" } } ``` **Key points about "Quarantined" status:** 1. You can view the list of quarantined transactions on the [explorer](https://explorer.zircuit.com/transactions-quarantined) page. 2. The quarantined transaction can be automatically released or retried. Zircuit uses AI enabled features to quarantine a transaction and in some cases a genuine transaction can be quarantined as well. If you need help with releasing your transaction, please contact to us via [discord](https://discord.com/invite/zircuit). ## Sequencer Confirmed / Unsafe A transaction becomes "sequencer confirmed" or "unsafe" when the sequencer adds it to a block, but that block has not yet been published to layer one. This status means the transaction is included in a provisional block that resides on the layer two chain, but it hasn't been fully secured by being anchored to the underlying layer one. During this period, the transaction is more likely to be included in the blockchain, but it is not yet certain. At this stage, the block containing the transaction is stored locally by the sequencer and is accessible to users and applications interacting with the Zircuit. However, the block's contents can still be altered or discarded if the sequencer encounters issues or fails to publish the block within the defined sequencing window. To view the latest "sequencer confirmed" block, use the JSON-RPC method [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) with the parameter `safe` and compare this to the latest block number. If the safe block is not the most recent block, the next immediate block after the safe block is considered the earliest "sequencer confirmed" block. **Key points about the "sequencer confirmed" / "unsafe" status:** 1. The transaction is provisionally included in the layer two blockchain but has not yet been anchored to the underlying layer one. This means the transaction could be reversed if not published in time. 2. Applications should inform users about the provisional nature of this status to manage expectations about the transaction's finality. 3. There is a small window during which the transaction could be excluded if the block fails to be published to the underlying layer one within the required time frame. ## Published to Ethereum / Safe A transaction is deemed "safe" once it is included in a block by the sequencer and that block has been published to the underlying layer one, but not yet finalized. At this stage, the block containing the transaction has been posted to the underlying layer one, significantly increasing the likelihood that the transaction will be part of the final blockchain. However, there is still a slight chance that it could be excluded if the layer one blockchain undergoes a reorganisation. **Key points about the "Published to Ethereum / Safe" status:** 1. Although not yet finalized, the transaction is now highly likely to be included in the final blockchain, providing a higher degree of certainty. 2. Users and applications can interact with the transaction data with increased confidence, knowing it has been anchored to the underlying layer one. 3. Users can track the status of their transactions using various block explorers or by calling the JSON-RPC method [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) with `safe` as the block number to see the latest "safe" block. ## Finalized A transaction reaches the `finalized` status when it has been included in a block by the sequencer, that block has been published to the underlying layer one, and the block has been finalized. Finalisation provides the highest level of certainty that the transaction is immutably part of the Zircuit blockchain. This status guarantees that the transaction cannot be reversed or altered, providing complete assurance of its inclusion in the blockchain. **Key points about the "Finalized" status:** 1. Finalized transactions are permanently recorded in the blockchain and cannot be altered or removed, offering the highest level of security and certainty. 2. Applications and users requiring the utmost certainty for high-value or critical transactions should wait for this status before considering the transaction complete. 3. Users can verify the finalization of a transaction using various block explorers or by calling the JSON-RPC method [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) with `finalized` as the block number to see the latest "finalized" block. # (Deprecated) Sequencer Level Security (SLS) {% hint style="info" icon="triangle-exclamation" %} ## Note that [SLS](https://docs.zircuit.com/info/architecture/sls) is not enabled while we [focus](https://www.zircuit.com/blog/a-new-chapter-for-zircuit-from-l2-to-defi) on Zircuit Finance. Zircuit Finance does not rely on the Zircuit chain. {% endhint %} As a developer building on Zircuit, you benefit from our **Sequencer Level Security (SLS)** protocol that protects your applications and users at the infrastructure level. Unlike traditional blockchain security that relies on post-execution measures, we've built protection directly into our sequencer to prevent malicious transactions from ever reaching your smart contracts. ## What We've Built for You We've fundamentally reimagined blockchain security by moving protection upstream in the transaction lifecycle. Instead of dealing with malicious transactions after they've caused damage (requiring hard forks or block reversions), our sequencer actively monitors the mempool and prevents harmful transactions from being included in blocks in the first place. ## How Our SLS Protocol Works <figure><img src="https://3252263143-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp2pPzGBdConDaqw5tnHs%2Fuploads%2Fgit-blob-323c90cf587e689a6653c38a23251780e85db3d5%2Fflow-chart-dark-mode.png?alt=media" alt=""><figcaption></figcaption></figure> When you deploy on Zircuit, your applications automatically benefit from our three-layer security system: ### 1. Malice Detection We analyze every transaction before it reaches your contracts: * **Parallel Simulation**: We simulate each transaction against the current blockchain state * **Advanced Detection**: Our AI-powered algorithms use program analysis, machine learning, and rule-based methods to identify threats * **Dependency Analysis**: We understand how transactions interact with each other to detect complex, multi-step attacks * **Block-Level Analysis**: We evaluate the combined effects of all transactions within a proposed block ### 2. Quarantine System Rather than rejecting suspicious transactions outright, we quarantine them: * **Time-Based Release**: Transactions can be released after a specified period * **Failure Criterion**: Transactions that would fail due to state changes are safely released * **Administrative Override**: Our security experts can manually release false positives * **Smart Retirement**: Invalid transactions are automatically removed from the mempool ### 3. Controlled Execution We ensure smooth operation when quarantined transactions are released: * Released transactions follow standard sequencing rules * We prevent duplicate quarantining of resubmitted transactions * Your applications continue running without interruption ## Current Implementation Status We're currently operating with conservative quarantine periods and manual release processes. This cautious approach ensures maximum security as we prove our system's effectiveness in production. Contact us on Discord for assistance with quarantined deposits. ## Best Practices While we provide robust sequencer-level security, we recommend you continue following standard security practices: * Conduct thorough security audits of your smart contracts * Implement proper access controls and validation * Consider SLS as an additional security layer, not a replacement for good engineering ## Learn More {% content-ref url="/pages/mgzou1iadcViaTubiXgm" %} [(Deprecated) Sequencer Level Security Deep Dive](/info/architecture/sls-deep-dive) {% endcontent-ref %} # (Deprecated) Sequencer Level Security Deep Dive {% hint style="info" icon="triangle-exclamation" %} ## Note that [SLS](https://docs.zircuit.com/info/architecture/sls) is not enabled while we [focus](https://www.zircuit.com/blog/a-new-chapter-for-zircuit-from-l2-to-defi) on Zircuit Finance. Zircuit Finance does not rely on the Zircuit chain. {% endhint %} ## Overview Zircuit will protect users at the sequencer level by monitoring the mempool for malicious transactions and preventing their inclusion into a block. In comparison to typical security efforts that focus on the application and smart contract levels, Zircuit’s revolutionary approach goes directly to the underlying sequencer level. This approach is called "Sequencer Level Security" (SLS) and adds an extra layer of security to the Zircuit network. This novel approach means that our sequencer scrutinizes transactions for potential malicious intent before they are finalized on layer 2. By enabling early detection and quarantine of suspicious transactions, the SLS protocol enhances the security of smart contracts and the layer 2 without necessitating the contentious measures of hard forks or block reversion. ## Detailed Description Zircuit adds another layer of security at the sequencer level. The sequencer is a privileged node that collects users’ transactions, similar to Ethereum, and also orders them based on predefined rules. <figure><picture><source srcset="/files/Nntnykn1fGg8ixASxJzt" media="(prefers-color-scheme: dark)"><img src="https://3252263143-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp2pPzGBdConDaqw5tnHs%2Fuploads%2Fgit-blob-f81fd7dc5b171a3b8f32e6b29e3f6862fa8994b4%2Fflow-chart-light-mode.png?alt=media" alt=""></picture><figcaption><p>Overview of the SLS protocol</p></figcaption></figure> The figure above presents an overview of the protocol. It contains three main components: (1) Malice Detection, (2) Quarantine-Release Criterion, and (3) Transaction Execution. Upon arrival at the SLS sequencer, transactions from the mempool are initially routed to Malice Detection module. In our talks, we refer to this module as the “[oracle](https://en.wikipedia.org/wiki/Oracle_machine).” It identifies whether a transaction is benign or potentially malicious. Benign transactions are promptly queued for block inclusion, adhering to standard sequencing protocols. Conversely, transactions flagged as malicious are diverted to the Quarantine-Release Criterion module, which acts as an intermediary holding area. Here, they undergo a rigorous verification process against specific release criteria. Transactions that meet these criteria are then forwarded to the Transaction Execution module. The Transaction Execution module executes the transactions against the blockchain state at the forthcoming L2 block. Successfully executed transactions are cycled back to the SLS sequencer for inclusion in the forthcoming L2 block. ### Malice Detection Malice Detection is done via the following steps: 1. **Choosing Transactions by the Sequencer:** The sequencer selects a list of transactions for potential inclusion in the upcoming block. This step is the same as other standard sequencing protocols. This includes both transactions from the mempool, and deposit transactions that have origin on L1. 2. **Parallel Simulation on the Tip of the Chain:** Each transaction is independently simulated using the current state at the tip of the blockchain. This step allows for parallel processing of transactions. The outcomes of these simulations provide essential data for future dependency analysis and malice detection: (1) Simulation results of each transaction (2) The blockchain states read and written by each transaction. 3. **Transaction Dependency Analysis:** We perform the analysis on the state read and written by each transaction and identify the dependencies between all transactions. Informally, one transaction is dependent on another if executing one may change the outcome of executing the other. 4. **Parallel Detection for Independent Transactions and Sequential Detection for Dependent Transactions:** For any transaction that is not dependent (a.k.a. independent) on any other prior transaction, the sequencer can perform parallel detection on their simulation results. Other dependent transactions are queued for sequential simulation and detection within the block context. 5. **Block-Level Detection:** In addition to analyzing individual transactions, the sequencer also evaluates the combined effects of all transactions within the proposed block. This enables detection of multi-step attacks that rely on multiple transactions executing within the same block. 6. **Transaction Inclusion:** The sequencer finalizes the block by including all transactions identified as benign. Dependent transactions that could not be fully analyzed due to time constraints or complexity are deferred to the next cycle. The same detection process will be applied in the next round when these transactions are considered again for inclusion. The algorithms used by the sequencer to identify malicious include program analysis, machine learning, and rule-based methods. ### Quarantine-Release Criterion While in quarantine, the transaction does not get executed and cannot be included in the blocks. The sequencer maintains the information about when the transaction has been placed in the quarantine. The transaction will either be dropped from the mempool once it meets one of the retirement criteria or be released from the quarantine if it meets one of the release criteria. The exact retirement criteria and release criteria can be defined by the sequencer. **Mempool Retirement Criteria:** * **Nonce criterion.** This criterion is met if the transaction can no longer be included in a block because the nonce is no longer valid. * **Time criterion and memory constraints.** This criterion is met if the transaction clutters the mempool that the node maintains. Such a transaction can be resubmitted to the network and re-enter the mempool (in the quarantined state). The current implementation of Zircuit ensures that transactions in quarantine are being checked periodically on the retirement criteria by the sequencer. The following list of quarantine-release criteria are viable from the security standpoint. **Release Criteria:** * **Time criterion.** The time criterion represents the reaction time that the sequencer offers to the users to react to a malicious transaction. If the transaction has been quarantined for longer than required, it can be released and considered for block inclusion. The exact amount of time required for the transaction to stay in the quarantine is a configuration parameter. * **Failure criterion.** If a transaction fails due to changes in the chain’s state, it can be safely included in the block since it will result in a revert. Reverted transactions do not alter the blockchain state. * **Administrative criterion.** It is expected that the detection of malice will occasionally produce false positives. Under such circumstances, the sequencer operational team, comprising security experts, can administratively override decisions to release transactions. We refer to the [Sequencer-Level Security paper](https://arxiv.org/pdf/2405.01819) for other possible releas
프로젝트로 돌아가기