Zircuit 백서

Zircuit

원문

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

e criteria. At the launch time, the Zircuit sequencer uses only the Time criterion set to a very long period of time (in the order of years). During this period, the sequencer waits for a privileged party to trigger the release criteria. Contact us on discord for assistance to claim quarantined deposits. ### Transaction Execution Upon releasing from the quarantine, the sequencer can consider including the transaction when forming the next block. This is subject to the regular sequencing Rules. For a transaction that was resubmitted due to being originally underpriced for the current chain state, the transaction should not be quarantined again. The SLS protocol has to use the account address, and the transaction data (the function selector and call data), and value, to establish whether a new incoming transaction is a duplicate of a transaction that has been already released from the quarantine. ### Requirements for Builders The SLS protocol is implemented in Zircuit natively. Therefore, every smart contract deployed on Zircuit is by default included and protected by the SLS. However, SLS is a best-effort service powered by AI, so it can make mistakes. The developers are therefore encouraged to follow best engineering practices and scrutinize the security of their code. The sequencer-level security protocol should be considered an added secondary security measure. SLS requires pricing information for detecting malice and protecting assets. Tokens natively deployed on Zircuit should be listed on [CoinGecko](https://www.coingecko.com/). The technology will automatically recognize such price feeds and tokens. Tokens that are deployed on other networks and bridged to Zircuit are advised to contact the Zircuit team via Discord to ensure rapid inclusion in the oracle’s pricing system. #### Building with SLS To build with SLS, we added two additional RPC calls to the Geth client, `zirc_isQuarantined` as well as `zirc_getQuarantined`. `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 ``` Using `zirc_getQuarantined`, you can also query all quarantined transactions and filter them by addresses. ```bash cast rpc zirc_getQuarantined --rpc-url https://zircuit1-mainnet.p2pify.com/ 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 ``` A quick overview of quarantined transactions is also available on the [Quarantined Transactions page](https://explorer.zircuit.com/transactions-quarantined) on the block explorer. It's important to note that a transaction that gets quarantined will also not return a transaction receipt, so if you are used to sending a transaction using the Ethers library and waiting for a receipt, but the transaction was put into quarantine, the `wait()` call will not terminate. ```typescript const sentTx = await signer.sendTransaction(txBody); console.log('Transaction sent:', sentTx.hash); // Waiting for transaction receipt, if TX gets quarantined this will time out // and quarantine status can be checked through zirc_isQuarantined RPC call const receipt = await sentTx.wait(); ``` In the more advanced code snippet below, we proactively check the quarantine status using the `zirc_isQuarantined` using two concurrent promises to either wait for a transaction receipt or a RPC call result, that the transaction is in fact quarantined. ```typescript let continueChecking = true; async function isQuarantined(txHash) { const response = await provider.send('zirc_isQuarantined', [txHash]); return response.IsQuarantined; } // Continuously check quarantine status (10 second timeout) async function checkQuarantine(txHash) { while (continueChecking) { if (await isQuarantined(txHash)) { throw new Error('Transaction is quarantined.'); } await new Promise(resolve => setTimeout(resolve, 10000)); // Check every 10 seconds } } // Main function to send TX async function sendTransaction() { try { const txResponse = await wallet.sendTransaction(tx); console.log('Transaction sent:', txResponse.hash); // Wait for either the transaction to be mined or for it to be quarantined const result = await Promise.race([ txResponse.wait().then(receipt => { continueChecking = false; // Stop the quarantine check to prevent infinite promise return receipt; }), // Waits for the transaction to be mined checkQuarantine(txResponse.hash) // Continuously checks if transaction is quarantined ]); console.log('Transaction mined:', result); } catch (error) { continueChecking = false; // Ensure the check is stopped in case of errors too console.error('Error:', error.message); } } sendTransaction(); ``` If your transaction is quarantined, refer to the mempool retirement and release criteria mentioned earlier. Security experts may release false positives (Administrative criterion), but you can also attempt to resubmit the transaction with a different gas limit to reevaluate its status. If you are sending the exact same transaction without any changes you will get an `already known` error response, so a simple retry is not enough to remove a false positive from the quarantine. In cases where a quarantined transaction is blocking subsequent ones—such as due to a nonce mismatch—you can resolve the issue by sending a zero-value transaction to yourself. This action can update the nonce and help release the quarantined transaction. You can perform this manually using MetaMask or programmatically using Ethereum libraries like Cast or Ethers.js. ```bash cast send 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --value 0ether --rpc-url https://zircuit1-mainnet.p2pify.com/ --private-key $yourPrivateKey ``` Using ethers, assuming you have set up a `signer` using RPC URL and private key. ```typescript const tx = { to: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", value: ethers.utils.parseEther("0"), gasLimit: 21000, // Standard gas limit for a basic transaction }; try { const transaction = await signer.sendTransaction(tx); console.log(`Transaction hash: ${transaction.hash}`); await transaction.wait(); console.log('Transaction confirmed'); } catch (error) { console.error('Error sending transaction:', error); } ``` ## Learn More Technical details can be found in our [pre-print](https://arxiv.org/pdf/2405.01819): {% file src="/files/JL5AuzWi3KnZbNPE4obm" %} Zircuit SLS preprint {% endfile %} You can also learn more by watching some of our [talks](/info/research/talks-and-panels) on the topic: * our [talk](https://www.youtube.com/watch?v=xpwhTC2G1WI) at ETH Prague 2024, * our [talk](https://youtu.be/IhmtmXuAFO8?si=c2yv0Ue_2sMVfZWa) at Ethereum Zurich 2024, or * our [talk](https://youtu.be/8RiLNXNEGs4?si=BnWntMoYGHUkNjIF) at ETH Denver 2024. # (Deprecated) Modular Prover Design Zircuit operates a comprehensive zero-knowledge proving system built on a modular architecture to efficiently process L2 blocks and submit proofs to L1. ## Core Architecture The **Proof Orchestrator** serves as the central coordinator, monitoring L2 blocks and organizing them into proving batches. It uses NATS as a message bus to queue blocks awaiting proof, stores proof artifacts in a database, and manages block traces in S3. The team is transitioning to a more modular, configuration-driven version that decouples the orchestrator from specific proving strategies. The **Proposer** handles the final step of submitting output roots and their corresponding proofs to L1 smart contracts. Running every 5 minutes, it consumes proofs from the orchestrator, forms transactions, signs them with a secure private key, and submits to L1 nodes via proxyd connections. ## Proving Technology Stack Zircuit has evolved from dedicated zkEVM circuits to a zkVM-based approach. This represents a significant architectural improvement, allowing any program to be proven by simply running it in the VM rather than requiring hardcoded circuit constraints. The system uses **Kona** (implementing Optimism's state transition) as the program being proven, with Zircuit-specific modifications layered on top. #### Two-Phase Proving Pipeline 1. **Range Proofs**: Generate proofs for multiple L2 blocks, ensuring correct state transitions, balance computations, and smart contract execution 2. **Aggregate Proofs**: Combine multiple range proofs to maximize the number of L2 transactions rolled up in a single L1 proof verification ## Advanced Components We use a zkVM abstraction layer enabling programs to run across interchangeable backends (currently SP1). It separates execution into three components: * **Program (P)**: Core computation running in the zkVM * **Host Program (HP)**: External setup, key generation, input preparation * **Guest Program (GP)**: In-zkVM execution reading hints and committing outputs The **Modular Orchestrator** represents the next-generation architecture with four key components: * **Dispatcher**: Processes individual messages and updates status * **Collector**: Groups messages using strategies (Sequential for blocks, Match for shared fields) * **Message Bus**: Handles message delivery and state management * **Executor**: Encapsulates actual execution logic (currently expects JSON input/output binaries) ## Development Considerations The architecture emphasizes modularity and flexibility, allowing for easy updates to proving strategies and backend systems without requiring complete infrastructure overhauls. This design supports our goal of maintaining cost-effective, frequent state root submissions while handling the computational demands of ZK proof generation. # Gas Pricing & Transaction Fees This page provides a detailed look at exactly how transaction fees work on Zircuit. Zircuit transaction fees are composed of an Execution Gas Fee and an L1 Data Fee. The total cost of a transaction is the sum of these two fees. The following paragraphs describe how the cost for each of these are derived. ### Execution Gas Fee A transaction's execution gas fee is exactly the same fee that you would pay for the same transaction on Ethereum. This fee is equal to the amount of gas used by the transaction multiplied by the gas price attached to the transaction. Like Ethereum, Zircuit uses the EIP-1559 mechanism to set the base fee for transactions. The total price per unit gas that a transaction pays is the sum of the base fee and the optional additional priority. The gas used by a transaction on Zircuit is exactly the same as the gas used by the same transaction on Ethereum. If a transaction costs 100,000 gas on Ethereum, it will also cost 100,000 on Zircuit. However, the gas **price** for that transaction is expected to be much lower on Zircuit than the gas price on Ethereum so you end up paying much less ETH in total. The EIP-1559 parameters used by Zircuit differ from those used by Ethereum as follows. <table><thead><tr><th>Parameter</th><th width="221">Zircuit value</th><th>Ethereum value (for reference)</th></tr></thead><tbody><tr><td>Block gas limit</td><td>30,000,000 gas</td><td>45,000,000 gas</td></tr><tr><td>Block gas target</td><td>3,000,000 gas</td><td>22,500,000 gas</td></tr><tr><td>EIP-1559 elasticity multiplier</td><td>10</td><td>2</td></tr><tr><td>EIP-1559 denominator</td><td>250</td><td>8</td></tr><tr><td>Block time in seconds</td><td>2</td><td>12</td></tr></tbody></table> #### Base Fee The base fee is the minimum price per unit of gas that a transaction must pay to be included in a block. Transactions must specify a maximum base fee higher than the block base fee to be included. The actual fee charged is the block base fee, even if the transaction specifies a higher maximum base fee. The Zircuit base fee behaves exactly like the Ethereum base fee with a few small parameter changes to account for shorter block times. #### Priority Fee Just like on Ethereum, Zircuit transactions can specify a **priority fee**. This priority fee is a price per unit of gas that is paid on top of the base fee. For example, if the block base fee is 1 gwei and the transaction specifies a priority fee of 1 gwei, the total price per unit of gas is 2 gwei. The priority fee is an optional component of the execution gas fee and can be set to 0. **The Zircuit sequencer will prioritize transactions with a higher priority fee** and execute them before any transactions with a lower priority fee. If transaction speed is important to your application, you may want to set a higher priority fee to ensure that your transaction is included more quickly. The [`eth_maxPriorityFeePerGas`](https://docs.alchemy.com/reference/eth-maxpriorityfeepergas) RPC method can be used to estimate a priority fee that will get your transaction included quickly. ### L1 Data Fee The L1 Data Fee is the only part of the Zircuit transaction fee that differs from the Ethereum transaction fee. This fee arises from the fact that the transaction data for all Zircuit transactions is published to Ethereum. This guarantees that the transaction data is available for nodes to download and execute. The L1 Data Fee accounts for the cost to publish a Zircuit transaction to Ethereum and is primarily determined by the current base fee on Ethereum. With the introduction of [blobs](https://www.eip4844.com/) on Ethereum, a new transaction type for posting this kind of data was introduced. The current Ethereum blob data gas price will largely determine the L1 data fee. #### Mechanism The L1 Data Fee is automatically charged for any transaction that is included in a Zircuit block. This fee is deducted directly from the address that sent the transaction. The exact amount paid depends on the estimated size of the transaction in bytes after compression, the current Ethereum blob gas price, and several small parameters. The L1 Data Fee is most heavily influenced by the Ethereum base fee that is continuously relayed from Ethereum to Zircuit. Short-term fluctuations of the L1 Data Fee are generally quite small and should not impact the average transaction. The L1 Data Fee is charged automatically. **It is currently not possible to limit the maximum L1 Data Fee that a transaction is willing to pay.** ### Formula #### Ecotone The pricing functions for the L1 Data Fee uses the following parameters: * The **signed** transaction serialized according to [the standard Ethereum transaction RLP encoding](https://github.com/ethereum-optimism/op-geth/blob/11a890f1ee0348a17687149abc72f394f9faa5ce/core/types/transaction.go#L131-L141). * The current Ethereum base fee and/or blob base fee. * Two new scalar parameters that independently scale the **base fee** and **blob base fee**. The L1 Data Fee calculation begins with counting the number of zero bytes and non-zero bytes in the transaction data. Each zero byte costs 4 gas and each non-zero byte costs 16 gas. This value, when divided by 16, can be thought of as a rough estimate of the size of the transaction data after compression. ```javascript tx_compressed_size = [(count_zero_bytes(tx_data)*4 + count_non_zero_bytes(tx_data)*16)] / 16 ``` Next, the two scalars are applied to the base fee and blob base fee parameters to compute a weighted gas price multiplier. ```javascript weighted_gas_price = 16*base_fee_scalar*base_fee + blob_base_fee_scalar*blob_base_fee ``` The L1 Data Fee is then: ```javascript l1_data_fee = tx_compressed_size * weighted_gas_price ``` ### Fjord The pricing function changes with the Fjord upgrade because of the FastLZ compression estimator, which more accurately charges for L1 data usage on a per-transaction basis. The updated function uses the following parameters: * The FastLZ-compressed size of the signed transaction. * The current Ethereum base fee and/or blob base fee (trustlessly relayed from Ethereum). The Fjord L1 Data Fee calculation begins with estimating the transaction size using a linear model over the FastLZ-compressed transaction size. ``` estimatedSizeScaled = max(minTransactionSize * 1e6, intercept + fastlzCoef*fastlzSize) ``` The model parameters `intercept` and `fastlzCoef` were determined by performing a linear regression analysis over a dataset of previous L2 transactions minimizing the root mean square error against the change in batch size, when compressed with Brotli, over historical OP mainnet data. These parameters are fixed in Fjord. The `minTransactionSize`, `intercept`, and `fastlzCoef` values are scaled by 1e6. Next, the two chain parameters **base fee scalar** and **blob base fee scalar** are used to compute a weighted gas price multiplier. ``` 1FeeScaled = baseFeeScalar * l1BaseFee * 16 + blobFeeScalar * l1BlobBaseFee ``` Both scalars are scaled by 1e6. The final L1 Data Fee is then ``` l1Cost = estimatedSizeScaled * l1FeeScaled / 1e12 ``` ### Operator Fee Zircuit supports an **Operator fee** in addition to the execution gas fee and the L1 data fee. Compute it as ``` operatorFee = (gasUsed × operatorFeeScalar ÷ 1e6) + operatorFeeConstant ``` where operatorFeeScalar (uint32, scaled by 1e6) and operatorFeeConstant (uint64) are chain parameters. The total transaction cost is then: ``` operatorFee + gasUsed × (baseFee + priorityFee) + l1Fee ``` Deposit transactions are not charged an operator fee. Clients/contracts can read the current parameters from the L1 Block Info contract at `0x4200000000000000000000000000000000000015` via the getters `operatorFeeScalar()` and `operatorFeeConstant()` . Transactions must have sufficient balance to cover worst-case costs (including the operator fee); any unused operator-fee amount is refunded after execution, and the spent portion is sent to the Operator Fee Vault. # L1 Data Fee Calculation (Fjord) This page describes how to calculate the L1 data fee for a specific transaction on a Zircuit network post Fjord upgrade. #### Retrieve the parameters To perform the calculation the following parameters are needed: * L1 base fee * L1 base fee scalar * L1 blob base fee * L1 blob base fee scalar They are available by calling the Gas Price Oracle smart contract predeployed on every Zircuit network on this address: `0x420000000000000000000000000000000000000F` To retrieve them we can use Foundry's cast. You will need the block number in which the transaction was included to retrieve the parameters from the right point in time. You will also need a valid RPC url. For example you'll find the RPC urls on this page: {% content-ref url="/pages/fEv1Wrfl0hPzbT380Xlr" %} [RPCs](/infra/rpcs) {% endcontent-ref %} L1 base fee: ```sh cast call 0x420000000000000000000000000000000000000F "l1BaseFee()(uint256)" --rpc-url $RPC_URL --block $BLOCK_NUMBER ``` L1 base fee scalar: ```sh cast call 0x420000000000000000000000000000000000000F "baseFeeScalar()(uint256)" --rpc-url $RPC_URL --block $BLOCK_NUMBER ``` L1 blob base fee: ```sh cast call 0x420000000000000000000000000000000000000F "blobBaseFee()(uint256)" --rpc-url $RPC_URL --block $BLOCK_NUMBER ``` L1 blob base fee scalar: ```sh cast call 0x420000000000000000000000000000000000000F "blobBaseFeeScalar()(uint256)" --rpc-url $RPC_URL --block $BLOCK_NUMBER ``` Get the raw RLP-encoded signed transaction: ```sh cast tx $TX_HASH --rpc-url $RPC_URL --raw ``` | intercept | -42\_585\_600 | Linear regression intercept (scaled by 1e6) | | ------------------ | ------------- | --------------------------------------------- | | fastlzCoef | 836\_500 | Linear regression coefficient (scaled by 1e6) | | minTransactionSize | 100 | Minimum transaction size in bytes | [fastLzSize](https://github.com/zircuit-labs/l2-geth-public/blob/main/core/types/rollup_cost.go#L684-L760) can be calculated using the bytes represented by the raw RLP-encoded signed transaction as the parameter. Now that you have all the info you need, you can just apply the following formula:
프로젝트로 돌아가기